From 95839b3bfc7ef243f91d9f7547aefe0f47a86f30 Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Tue, 16 Jun 2020 18:59:29 +0800 Subject: [PATCH] remove some libs --- sources/Box2D/Box2D.h | 70 - sources/Box2D/Box2DConfig.cmake.in | 31 - sources/Box2D/CMakeLists.txt | 218 - .../Box2D/Collision/Shapes/b2ChainShape.cpp | 193 - sources/Box2D/Collision/Shapes/b2ChainShape.h | 105 - .../Box2D/Collision/Shapes/b2CircleShape.cpp | 99 - .../Box2D/Collision/Shapes/b2CircleShape.h | 91 - .../Box2D/Collision/Shapes/b2EdgeShape.cpp | 138 - sources/Box2D/Collision/Shapes/b2EdgeShape.h | 74 - .../Box2D/Collision/Shapes/b2PolygonShape.cpp | 467 -- .../Box2D/Collision/Shapes/b2PolygonShape.h | 101 - sources/Box2D/Collision/Shapes/b2Shape.h | 101 - sources/Box2D/Collision/b2BroadPhase.cpp | 119 - sources/Box2D/Collision/b2BroadPhase.h | 257 - sources/Box2D/Collision/b2CollideCircle.cpp | 154 - sources/Box2D/Collision/b2CollideEdge.cpp | 698 -- sources/Box2D/Collision/b2CollidePolygon.cpp | 239 - sources/Box2D/Collision/b2Collision.cpp | 252 - sources/Box2D/Collision/b2Collision.h | 277 - sources/Box2D/Collision/b2Distance.cpp | 603 -- sources/Box2D/Collision/b2Distance.h | 141 - sources/Box2D/Collision/b2DynamicTree.cpp | 778 -- sources/Box2D/Collision/b2DynamicTree.h | 289 - sources/Box2D/Collision/b2TimeOfImpact.cpp | 486 -- sources/Box2D/Collision/b2TimeOfImpact.h | 58 - sources/Box2D/Common/b2BlockAllocator.cpp | 215 - sources/Box2D/Common/b2BlockAllocator.h | 62 - sources/Box2D/Common/b2Draw.cpp | 44 - sources/Box2D/Common/b2Draw.h | 88 - sources/Box2D/Common/b2GrowableStack.h | 85 - sources/Box2D/Common/b2Math.cpp | 94 - sources/Box2D/Common/b2Math.h | 720 -- sources/Box2D/Common/b2Settings.cpp | 44 - sources/Box2D/Common/b2Settings.h | 151 - sources/Box2D/Common/b2StackAllocator.cpp | 83 - sources/Box2D/Common/b2StackAllocator.h | 60 - sources/Box2D/Common/b2Timer.cpp | 101 - sources/Box2D/Common/b2Timer.h | 50 - .../Contacts/b2ChainAndCircleContact.cpp | 53 - .../Contacts/b2ChainAndCircleContact.h | 39 - .../Contacts/b2ChainAndPolygonContact.cpp | 53 - .../Contacts/b2ChainAndPolygonContact.h | 39 - .../Dynamics/Contacts/b2CircleContact.cpp | 52 - .../Box2D/Dynamics/Contacts/b2CircleContact.h | 39 - sources/Box2D/Dynamics/Contacts/b2Contact.cpp | 249 - sources/Box2D/Dynamics/Contacts/b2Contact.h | 349 - .../Dynamics/Contacts/b2ContactSolver.cpp | 838 -- .../Box2D/Dynamics/Contacts/b2ContactSolver.h | 95 - .../Contacts/b2EdgeAndCircleContact.cpp | 49 - .../Contacts/b2EdgeAndCircleContact.h | 39 - .../Contacts/b2EdgeAndPolygonContact.cpp | 49 - .../Contacts/b2EdgeAndPolygonContact.h | 39 - .../Contacts/b2PolygonAndCircleContact.cpp | 49 - .../Contacts/b2PolygonAndCircleContact.h | 38 - .../Dynamics/Contacts/b2PolygonContact.cpp | 52 - .../Dynamics/Contacts/b2PolygonContact.h | 39 - .../Box2D/Dynamics/Joints/b2DistanceJoint.cpp | 260 - .../Box2D/Dynamics/Joints/b2DistanceJoint.h | 169 - .../Box2D/Dynamics/Joints/b2FrictionJoint.cpp | 251 - .../Box2D/Dynamics/Joints/b2FrictionJoint.h | 119 - sources/Box2D/Dynamics/Joints/b2GearJoint.cpp | 419 - sources/Box2D/Dynamics/Joints/b2GearJoint.h | 125 - sources/Box2D/Dynamics/Joints/b2Joint.cpp | 213 - sources/Box2D/Dynamics/Joints/b2Joint.h | 226 - .../Box2D/Dynamics/Joints/b2MotorJoint.cpp | 304 - sources/Box2D/Dynamics/Joints/b2MotorJoint.h | 133 - .../Box2D/Dynamics/Joints/b2MouseJoint.cpp | 222 - sources/Box2D/Dynamics/Joints/b2MouseJoint.h | 129 - .../Dynamics/Joints/b2PrismaticJoint.cpp | 629 -- .../Box2D/Dynamics/Joints/b2PrismaticJoint.h | 196 - .../Box2D/Dynamics/Joints/b2PulleyJoint.cpp | 348 - sources/Box2D/Dynamics/Joints/b2PulleyJoint.h | 152 - .../Box2D/Dynamics/Joints/b2RevoluteJoint.cpp | 502 -- .../Box2D/Dynamics/Joints/b2RevoluteJoint.h | 204 - sources/Box2D/Dynamics/Joints/b2RopeJoint.cpp | 241 - sources/Box2D/Dynamics/Joints/b2RopeJoint.h | 114 - sources/Box2D/Dynamics/Joints/b2WeldJoint.cpp | 344 - sources/Box2D/Dynamics/Joints/b2WeldJoint.h | 126 - .../Box2D/Dynamics/Joints/b2WheelJoint.cpp | 419 - sources/Box2D/Dynamics/Joints/b2WheelJoint.h | 211 - sources/Box2D/Dynamics/b2Body.cpp | 549 -- sources/Box2D/Dynamics/b2Body.h | 860 --- sources/Box2D/Dynamics/b2ContactManager.cpp | 296 - sources/Box2D/Dynamics/b2ContactManager.h | 52 - sources/Box2D/Dynamics/b2Fixture.cpp | 310 - sources/Box2D/Dynamics/b2Fixture.h | 345 - sources/Box2D/Dynamics/b2Island.cpp | 539 -- sources/Box2D/Dynamics/b2Island.h | 93 - sources/Box2D/Dynamics/b2TimeStep.h | 70 - sources/Box2D/Dynamics/b2World.cpp | 1343 ---- sources/Box2D/Dynamics/b2World.h | 354 - sources/Box2D/Dynamics/b2WorldCallbacks.cpp | 36 - sources/Box2D/Dynamics/b2WorldCallbacks.h | 155 - sources/Box2D/Rope/b2Rope.cpp | 259 - sources/Box2D/Rope/b2Rope.h | 115 - sources/Box2D/UseBox2D.cmake | 9 - sources/Box2D/b2ObjectDestroyNotifier.cpp | 16 - sources/Box2D/b2ObjectDestroyNotifier.h | 18 - sources/Box2D/proj.win32/libBox2D.vcxproj | 198 - .../Box2D/proj.win32/libBox2D.vcxproj.filters | 326 - sources/cjson/CMakeLists.txt | 12 - sources/cjson/fpconv.c | 205 - sources/cjson/fpconv.h | 28 - sources/cjson/lua_cjson.c | 1456 ---- sources/cjson/lua_cjson.h | 12 - sources/cjson/strbuf.c | 251 - sources/cjson/strbuf.h | 160 - sources/clipper/CMakeLists.txt | 7 - sources/clipper/clipper.cpp | 4610 ----------- sources/clipper/clipper.hpp | 398 - sources/firefox/GLConsts.h | 6825 ----------------- sources/firefox/WebGLFormats.cpp | 1205 --- sources/firefox/WebGLFormats.h | 387 - sources/firefox/WebGLTexelConversions.cpp | 435 -- sources/firefox/WebGLTexelConversions.h | 1354 ---- sources/firefox/WebGLTypes.h | 228 - sources/firefox/mozilla/Assertions.cpp | 66 - sources/firefox/mozilla/Assertions.h | 659 -- sources/firefox/mozilla/Atomics.h | 563 -- sources/firefox/mozilla/Attributes.h | 747 -- sources/firefox/mozilla/Casting.h | 256 - sources/firefox/mozilla/CheckedInt.h | 791 -- sources/firefox/mozilla/Compiler.h | 113 - sources/firefox/mozilla/IntegerTypeTraits.h | 143 - sources/firefox/mozilla/Likely.h | 23 - sources/firefox/mozilla/MacroArgs.h | 93 - sources/firefox/mozilla/Move.h | 238 - sources/firefox/mozilla/Pair.h | 219 - .../firefox/mozilla/StaticAnalysisFunctions.h | 59 - sources/firefox/mozilla/TypeTraits.h | 1314 ---- sources/firefox/mozilla/Types.h | 139 - sources/firefox/mozilla/UniquePtr.h | 697 -- sources/poly2tri/common/shapes.cc | 365 - sources/poly2tri/common/shapes.h | 323 - sources/poly2tri/common/utils.h | 127 - sources/poly2tri/poly2tri.h | 38 - sources/poly2tri/sweep/advancing_front.cc | 108 - sources/poly2tri/sweep/advancing_front.h | 118 - sources/poly2tri/sweep/cdt.cc | 71 - sources/poly2tri/sweep/cdt.h | 105 - sources/poly2tri/sweep/sweep.cc | 794 -- sources/poly2tri/sweep/sweep.h | 285 - sources/poly2tri/sweep/sweep_context.cc | 211 - sources/poly2tri/sweep/sweep_context.h | 186 - 144 files changed, 48419 deletions(-) delete mode 100755 sources/Box2D/Box2D.h delete mode 100755 sources/Box2D/Box2DConfig.cmake.in delete mode 100755 sources/Box2D/CMakeLists.txt delete mode 100755 sources/Box2D/Collision/Shapes/b2ChainShape.cpp delete mode 100755 sources/Box2D/Collision/Shapes/b2ChainShape.h delete mode 100755 sources/Box2D/Collision/Shapes/b2CircleShape.cpp delete mode 100755 sources/Box2D/Collision/Shapes/b2CircleShape.h delete mode 100755 sources/Box2D/Collision/Shapes/b2EdgeShape.cpp delete mode 100755 sources/Box2D/Collision/Shapes/b2EdgeShape.h delete mode 100755 sources/Box2D/Collision/Shapes/b2PolygonShape.cpp delete mode 100755 sources/Box2D/Collision/Shapes/b2PolygonShape.h delete mode 100755 sources/Box2D/Collision/Shapes/b2Shape.h delete mode 100755 sources/Box2D/Collision/b2BroadPhase.cpp delete mode 100755 sources/Box2D/Collision/b2BroadPhase.h delete mode 100755 sources/Box2D/Collision/b2CollideCircle.cpp delete mode 100755 sources/Box2D/Collision/b2CollideEdge.cpp delete mode 100755 sources/Box2D/Collision/b2CollidePolygon.cpp delete mode 100755 sources/Box2D/Collision/b2Collision.cpp delete mode 100755 sources/Box2D/Collision/b2Collision.h delete mode 100755 sources/Box2D/Collision/b2Distance.cpp delete mode 100755 sources/Box2D/Collision/b2Distance.h delete mode 100755 sources/Box2D/Collision/b2DynamicTree.cpp delete mode 100755 sources/Box2D/Collision/b2DynamicTree.h delete mode 100755 sources/Box2D/Collision/b2TimeOfImpact.cpp delete mode 100755 sources/Box2D/Collision/b2TimeOfImpact.h delete mode 100755 sources/Box2D/Common/b2BlockAllocator.cpp delete mode 100755 sources/Box2D/Common/b2BlockAllocator.h delete mode 100755 sources/Box2D/Common/b2Draw.cpp delete mode 100755 sources/Box2D/Common/b2Draw.h delete mode 100755 sources/Box2D/Common/b2GrowableStack.h delete mode 100755 sources/Box2D/Common/b2Math.cpp delete mode 100755 sources/Box2D/Common/b2Math.h delete mode 100755 sources/Box2D/Common/b2Settings.cpp delete mode 100755 sources/Box2D/Common/b2Settings.h delete mode 100755 sources/Box2D/Common/b2StackAllocator.cpp delete mode 100755 sources/Box2D/Common/b2StackAllocator.h delete mode 100755 sources/Box2D/Common/b2Timer.cpp delete mode 100755 sources/Box2D/Common/b2Timer.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2CircleContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2CircleContact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2Contact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2Contact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2ContactSolver.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2ContactSolver.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h delete mode 100755 sources/Box2D/Dynamics/Contacts/b2PolygonContact.cpp delete mode 100755 sources/Box2D/Dynamics/Contacts/b2PolygonContact.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2DistanceJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2DistanceJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2FrictionJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2FrictionJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2GearJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2GearJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2Joint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2Joint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2MotorJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2MotorJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2MouseJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2MouseJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2PrismaticJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2PulleyJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2PulleyJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2RevoluteJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2RopeJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2RopeJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2WeldJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2WeldJoint.h delete mode 100755 sources/Box2D/Dynamics/Joints/b2WheelJoint.cpp delete mode 100755 sources/Box2D/Dynamics/Joints/b2WheelJoint.h delete mode 100755 sources/Box2D/Dynamics/b2Body.cpp delete mode 100755 sources/Box2D/Dynamics/b2Body.h delete mode 100755 sources/Box2D/Dynamics/b2ContactManager.cpp delete mode 100755 sources/Box2D/Dynamics/b2ContactManager.h delete mode 100755 sources/Box2D/Dynamics/b2Fixture.cpp delete mode 100755 sources/Box2D/Dynamics/b2Fixture.h delete mode 100755 sources/Box2D/Dynamics/b2Island.cpp delete mode 100755 sources/Box2D/Dynamics/b2Island.h delete mode 100755 sources/Box2D/Dynamics/b2TimeStep.h delete mode 100755 sources/Box2D/Dynamics/b2World.cpp delete mode 100755 sources/Box2D/Dynamics/b2World.h delete mode 100755 sources/Box2D/Dynamics/b2WorldCallbacks.cpp delete mode 100755 sources/Box2D/Dynamics/b2WorldCallbacks.h delete mode 100755 sources/Box2D/Rope/b2Rope.cpp delete mode 100755 sources/Box2D/Rope/b2Rope.h delete mode 100755 sources/Box2D/UseBox2D.cmake delete mode 100644 sources/Box2D/b2ObjectDestroyNotifier.cpp delete mode 100644 sources/Box2D/b2ObjectDestroyNotifier.h delete mode 100644 sources/Box2D/proj.win32/libBox2D.vcxproj delete mode 100644 sources/Box2D/proj.win32/libBox2D.vcxproj.filters delete mode 100644 sources/cjson/CMakeLists.txt delete mode 100644 sources/cjson/fpconv.c delete mode 100644 sources/cjson/fpconv.h delete mode 100644 sources/cjson/lua_cjson.c delete mode 100644 sources/cjson/lua_cjson.h delete mode 100644 sources/cjson/strbuf.c delete mode 100644 sources/cjson/strbuf.h delete mode 100644 sources/clipper/CMakeLists.txt delete mode 100644 sources/clipper/clipper.cpp delete mode 100755 sources/clipper/clipper.hpp delete mode 100644 sources/firefox/GLConsts.h delete mode 100644 sources/firefox/WebGLFormats.cpp delete mode 100644 sources/firefox/WebGLFormats.h delete mode 100644 sources/firefox/WebGLTexelConversions.cpp delete mode 100644 sources/firefox/WebGLTexelConversions.h delete mode 100644 sources/firefox/WebGLTypes.h delete mode 100644 sources/firefox/mozilla/Assertions.cpp delete mode 100755 sources/firefox/mozilla/Assertions.h delete mode 100644 sources/firefox/mozilla/Atomics.h delete mode 100644 sources/firefox/mozilla/Attributes.h delete mode 100644 sources/firefox/mozilla/Casting.h delete mode 100644 sources/firefox/mozilla/CheckedInt.h delete mode 100644 sources/firefox/mozilla/Compiler.h delete mode 100644 sources/firefox/mozilla/IntegerTypeTraits.h delete mode 100644 sources/firefox/mozilla/Likely.h delete mode 100644 sources/firefox/mozilla/MacroArgs.h delete mode 100644 sources/firefox/mozilla/Move.h delete mode 100644 sources/firefox/mozilla/Pair.h delete mode 100644 sources/firefox/mozilla/StaticAnalysisFunctions.h delete mode 100644 sources/firefox/mozilla/TypeTraits.h delete mode 100644 sources/firefox/mozilla/Types.h delete mode 100644 sources/firefox/mozilla/UniquePtr.h delete mode 100644 sources/poly2tri/common/shapes.cc delete mode 100644 sources/poly2tri/common/shapes.h delete mode 100644 sources/poly2tri/common/utils.h delete mode 100644 sources/poly2tri/poly2tri.h delete mode 100644 sources/poly2tri/sweep/advancing_front.cc delete mode 100644 sources/poly2tri/sweep/advancing_front.h delete mode 100644 sources/poly2tri/sweep/cdt.cc delete mode 100644 sources/poly2tri/sweep/cdt.h delete mode 100644 sources/poly2tri/sweep/sweep.cc delete mode 100644 sources/poly2tri/sweep/sweep.h delete mode 100644 sources/poly2tri/sweep/sweep_context.cc delete mode 100644 sources/poly2tri/sweep/sweep_context.h diff --git a/sources/Box2D/Box2D.h b/sources/Box2D/Box2D.h deleted file mode 100755 index b43aa6aa..00000000 --- a/sources/Box2D/Box2D.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 BOX2D_H -#define BOX2D_H - -/** -\mainpage Box2D API Documentation - -\section intro_sec Getting Started - -For documentation please see http://box2d.org/documentation.html - -For discussion please visit http://box2d.org/forum -*/ - -// These include files constitute the main Box2D API - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#endif diff --git a/sources/Box2D/Box2DConfig.cmake.in b/sources/Box2D/Box2DConfig.cmake.in deleted file mode 100755 index 55d62f6c..00000000 --- a/sources/Box2D/Box2DConfig.cmake.in +++ /dev/null @@ -1,31 +0,0 @@ -# -*- cmake -*- -# -# Box2dConfig.cmake(.in) -# - -# Use the following variables to compile and link against Box2d: -# BOX2D_FOUND - True if Box2d was found on your system -# BOX2D_USE_FILE - The file making Box2d usable -# BOX2D_DEFINITIONS - Definitions needed to build with Box2d -# BOX2D_INCLUDE_DIR - Box2d headers location -# BOX2D_INCLUDE_DIRS - List of directories where Box2d header file are -# BOX2D_LIBRARY - Library name -# BOX2D_LIBRARIES - List of libraries to link against -# BOX2D_LIBRARY_DIRS - List of directories containing Box2d libraries -# BOX2D_ROOT_DIR - The base directory of Box2d -# BOX2D_VERSION_STRING - A human-readable string containing the version - -set ( BOX2D_FOUND 1 ) -set ( BOX2D_USE_FILE "@BOX2D_USE_FILE@" ) - -set ( BOX2D_DEFINITIONS "@BOX2D_DEFINITIONS@" ) -set ( BOX2D_INCLUDE_DIR "@BOX2D_INCLUDE_DIR@" ) -set ( Box2D_INCLUDE_DIRS "@BOX2D_INCLUDE_DIRS@" ) # deprecated -set ( BOX2D_INCLUDE_DIRS "@BOX2D_INCLUDE_DIRS@" ) -set ( BOX2D_LIBRARY "@BOX2D_LIBRARY@" ) -set ( BOX2D_LIBRARIES "@BOX2D_LIBRARIES@" ) -set ( BOX2D_LIBRARY_DIRS "@BOX2D_LIBRARY_DIRS@" ) -set ( BOX2D_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" ) - -set ( BOX2D_VERSION_STRING "@BOX2D_VERSION@" ) - diff --git a/sources/Box2D/CMakeLists.txt b/sources/Box2D/CMakeLists.txt deleted file mode 100755 index 05087d3e..00000000 --- a/sources/Box2D/CMakeLists.txt +++ /dev/null @@ -1,218 +0,0 @@ -set(BOX2D_Collision_SRCS - Collision/b2BroadPhase.cpp - Collision/b2CollideCircle.cpp - Collision/b2CollideEdge.cpp - Collision/b2CollidePolygon.cpp - Collision/b2Collision.cpp - Collision/b2Distance.cpp - Collision/b2DynamicTree.cpp - Collision/b2TimeOfImpact.cpp -) -set(BOX2D_Collision_HDRS - Collision/b2BroadPhase.h - Collision/b2Collision.h - Collision/b2Distance.h - Collision/b2DynamicTree.h - Collision/b2TimeOfImpact.h -) -set(BOX2D_Shapes_SRCS - Collision/Shapes/b2CircleShape.cpp - Collision/Shapes/b2EdgeShape.cpp - Collision/Shapes/b2ChainShape.cpp - Collision/Shapes/b2PolygonShape.cpp -) -set(BOX2D_Shapes_HDRS - Collision/Shapes/b2CircleShape.h - Collision/Shapes/b2EdgeShape.h - Collision/Shapes/b2ChainShape.h - Collision/Shapes/b2PolygonShape.h - Collision/Shapes/b2Shape.h -) -set(BOX2D_Common_SRCS - Common/b2BlockAllocator.cpp - Common/b2Draw.cpp - Common/b2Math.cpp - Common/b2Settings.cpp - Common/b2StackAllocator.cpp - Common/b2Timer.cpp -) -set(BOX2D_Common_HDRS - Common/b2BlockAllocator.h - Common/b2Draw.h - Common/b2GrowableStack.h - Common/b2Math.h - Common/b2Settings.h - Common/b2StackAllocator.h - Common/b2Timer.h -) -set(BOX2D_Dynamics_SRCS - Dynamics/b2Body.cpp - Dynamics/b2ContactManager.cpp - Dynamics/b2Fixture.cpp - Dynamics/b2Island.cpp - Dynamics/b2World.cpp - Dynamics/b2WorldCallbacks.cpp -) -set(BOX2D_Dynamics_HDRS - Dynamics/b2Body.h - Dynamics/b2ContactManager.h - Dynamics/b2Fixture.h - Dynamics/b2Island.h - Dynamics/b2TimeStep.h - Dynamics/b2World.h - Dynamics/b2WorldCallbacks.h -) -set(BOX2D_Contacts_SRCS - Dynamics/Contacts/b2CircleContact.cpp - Dynamics/Contacts/b2Contact.cpp - Dynamics/Contacts/b2ContactSolver.cpp - Dynamics/Contacts/b2PolygonAndCircleContact.cpp - Dynamics/Contacts/b2EdgeAndCircleContact.cpp - Dynamics/Contacts/b2EdgeAndPolygonContact.cpp - Dynamics/Contacts/b2ChainAndCircleContact.cpp - Dynamics/Contacts/b2ChainAndPolygonContact.cpp - Dynamics/Contacts/b2PolygonContact.cpp -) -set(BOX2D_Contacts_HDRS - Dynamics/Contacts/b2CircleContact.h - Dynamics/Contacts/b2Contact.h - Dynamics/Contacts/b2ContactSolver.h - Dynamics/Contacts/b2PolygonAndCircleContact.h - Dynamics/Contacts/b2EdgeAndCircleContact.h - Dynamics/Contacts/b2EdgeAndPolygonContact.h - Dynamics/Contacts/b2ChainAndCircleContact.h - Dynamics/Contacts/b2ChainAndPolygonContact.h - Dynamics/Contacts/b2PolygonContact.h -) -set(BOX2D_Joints_SRCS - Dynamics/Joints/b2DistanceJoint.cpp - Dynamics/Joints/b2FrictionJoint.cpp - Dynamics/Joints/b2GearJoint.cpp - Dynamics/Joints/b2Joint.cpp - Dynamics/Joints/b2MotorJoint.cpp - Dynamics/Joints/b2MouseJoint.cpp - Dynamics/Joints/b2PrismaticJoint.cpp - Dynamics/Joints/b2PulleyJoint.cpp - Dynamics/Joints/b2RevoluteJoint.cpp - Dynamics/Joints/b2RopeJoint.cpp - Dynamics/Joints/b2WeldJoint.cpp - Dynamics/Joints/b2WheelJoint.cpp -) -set(BOX2D_Joints_HDRS - Dynamics/Joints/b2DistanceJoint.h - Dynamics/Joints/b2FrictionJoint.h - Dynamics/Joints/b2GearJoint.h - Dynamics/Joints/b2Joint.h - Dynamics/Joints/b2MotorJoint.h - Dynamics/Joints/b2MouseJoint.h - Dynamics/Joints/b2PrismaticJoint.h - Dynamics/Joints/b2PulleyJoint.h - Dynamics/Joints/b2RevoluteJoint.h - Dynamics/Joints/b2RopeJoint.h - Dynamics/Joints/b2WeldJoint.h - Dynamics/Joints/b2WheelJoint.h -) -set(BOX2D_Rope_SRCS - Rope/b2Rope.cpp -) -set(BOX2D_Rope_HDRS - Rope/b2Rope.h -) -set(BOX2D_General_HDRS - Box2D.h -) -include_directories( ../ ) - -if(BOX2D_BUILD_SHARED) - add_library(Box2D_shared SHARED - ${BOX2D_General_HDRS} - ${BOX2D_Joints_SRCS} - ${BOX2D_Joints_HDRS} - ${BOX2D_Contacts_SRCS} - ${BOX2D_Contacts_HDRS} - ${BOX2D_Dynamics_SRCS} - ${BOX2D_Dynamics_HDRS} - ${BOX2D_Common_SRCS} - ${BOX2D_Common_HDRS} - ${BOX2D_Shapes_SRCS} - ${BOX2D_Shapes_HDRS} - ${BOX2D_Collision_SRCS} - ${BOX2D_Collision_HDRS} - ${BOX2D_Rope_SRCS} - ${BOX2D_Rope_HDRS} - ) - set_target_properties(Box2D_shared PROPERTIES - OUTPUT_NAME "Box2D" - CLEAN_DIRECT_OUTPUT 1 - VERSION ${BOX2D_VERSION} - ) -endif() - -if(BOX2D_BUILD_STATIC) - add_library(Box2D STATIC - ${BOX2D_General_HDRS} - ${BOX2D_Joints_SRCS} - ${BOX2D_Joints_HDRS} - ${BOX2D_Contacts_SRCS} - ${BOX2D_Contacts_HDRS} - ${BOX2D_Dynamics_SRCS} - ${BOX2D_Dynamics_HDRS} - ${BOX2D_Common_SRCS} - ${BOX2D_Common_HDRS} - ${BOX2D_Shapes_SRCS} - ${BOX2D_Shapes_HDRS} - ${BOX2D_Collision_SRCS} - ${BOX2D_Collision_HDRS} - ${BOX2D_Rope_SRCS} - ${BOX2D_Rope_HDRS} - ) - set_target_properties(Box2D PROPERTIES - CLEAN_DIRECT_OUTPUT 1 - VERSION ${BOX2D_VERSION} - ) -endif() - -# These are used to create visual studio folders. -source_group(Collision FILES ${BOX2D_Collision_SRCS} ${BOX2D_Collision_HDRS}) -source_group(Collision\\Shapes FILES ${BOX2D_Shapes_SRCS} ${BOX2D_Shapes_HDRS}) -source_group(Common FILES ${BOX2D_Common_SRCS} ${BOX2D_Common_HDRS}) -source_group(Dynamics FILES ${BOX2D_Dynamics_SRCS} ${BOX2D_Dynamics_HDRS}) -source_group(Dynamics\\Contacts FILES ${BOX2D_Contacts_SRCS} ${BOX2D_Contacts_HDRS}) -source_group(Dynamics\\Joints FILES ${BOX2D_Joints_SRCS} ${BOX2D_Joints_HDRS}) -source_group(Include FILES ${BOX2D_General_HDRS}) -source_group(Rope FILES ${BOX2D_Rope_SRCS} ${BOX2D_Rope_HDRS}) - -if(BOX2D_INSTALL) - # install headers - install(FILES ${BOX2D_General_HDRS} DESTINATION include/Box2D) - install(FILES ${BOX2D_Collision_HDRS} DESTINATION include/Box2D/Collision) - install(FILES ${BOX2D_Shapes_HDRS} DESTINATION include/Box2D/Collision/Shapes) - install(FILES ${BOX2D_Common_HDRS} DESTINATION include/Box2D/Common) - install(FILES ${BOX2D_Dynamics_HDRS} DESTINATION include/Box2D/Dynamics) - install(FILES ${BOX2D_Contacts_HDRS} DESTINATION include/Box2D/Dynamics/Contacts) - install(FILES ${BOX2D_Joints_HDRS} DESTINATION include/Box2D/Dynamics/Joints) - install(FILES ${BOX2D_Rope_HDRS} DESTINATION include/Box2D/Rope) - - # install libraries - if(BOX2D_BUILD_SHARED) - install(TARGETS Box2D_shared EXPORT Box2D-targets - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} - RUNTIME DESTINATION bin) - endif() - if(BOX2D_BUILD_STATIC) - install(TARGETS Box2D EXPORT Box2D-targets DESTINATION ${LIB_INSTALL_DIR}) - endif() - - # install build system hooks for third-party apps - install(EXPORT Box2D-targets DESTINATION ${LIB_INSTALL_DIR}/Box2D) - - set (BOX2D_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include) - set (BOX2D_INCLUDE_DIRS ${BOX2D_INCLUDE_DIR} ) - set (BOX2D_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}) - set (BOX2D_LIBRARY Box2D) - set (BOX2D_LIBRARIES ${BOX2D_LIBRARY}) - set (BOX2D_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/Box2D/UseBox2D.cmake) - configure_file(Box2DConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Box2DConfig.cmake @ONLY ESCAPE_QUOTES) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Box2DConfig.cmake UseBox2D.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/Box2D) -endif(BOX2D_INSTALL) diff --git a/sources/Box2D/Collision/Shapes/b2ChainShape.cpp b/sources/Box2D/Collision/Shapes/b2ChainShape.cpp deleted file mode 100755 index a9c2e1d5..00000000 --- a/sources/Box2D/Collision/Shapes/b2ChainShape.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include - -b2ChainShape::~b2ChainShape() -{ - Clear(); -} - -void b2ChainShape::Clear() -{ - b2Free(m_vertices); - m_vertices = NULL; - m_count = 0; -} - -void b2ChainShape::CreateLoop(const b2Vec2* vertices, int32 count) -{ - b2Assert(m_vertices == NULL && m_count == 0); - b2Assert(count >= 3); - for (int32 i = 1; i < count; ++i) - { - b2Vec2 v1 = vertices[i-1]; - b2Vec2 v2 = vertices[i]; - // If the code crashes here, it means your vertices are too close together. - b2Assert(b2DistanceSquared(v1, v2) > b2_linearSlop * b2_linearSlop); - } - - m_count = count + 1; - m_vertices = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2)); - memcpy(m_vertices, vertices, count * sizeof(b2Vec2)); - m_vertices[count] = m_vertices[0]; - m_prevVertex = m_vertices[m_count - 2]; - m_nextVertex = m_vertices[1]; - m_hasPrevVertex = true; - m_hasNextVertex = true; -} - -void b2ChainShape::CreateChain(const b2Vec2* vertices, int32 count) -{ - b2Assert(m_vertices == NULL && m_count == 0); - b2Assert(count >= 2); - for (int32 i = 1; i < count; ++i) - { - // If the code crashes here, it means your vertices are too close together. - b2Assert(b2DistanceSquared(vertices[i-1], vertices[i]) > b2_linearSlop * b2_linearSlop); - } - - m_count = count; - m_vertices = (b2Vec2*)b2Alloc(count * sizeof(b2Vec2)); - memcpy(m_vertices, vertices, m_count * sizeof(b2Vec2)); - - m_hasPrevVertex = false; - m_hasNextVertex = false; - - m_prevVertex.SetZero(); - m_nextVertex.SetZero(); -} - -void b2ChainShape::SetPrevVertex(const b2Vec2& prevVertex) -{ - m_prevVertex = prevVertex; - m_hasPrevVertex = true; -} - -void b2ChainShape::SetNextVertex(const b2Vec2& nextVertex) -{ - m_nextVertex = nextVertex; - m_hasNextVertex = true; -} - -b2Shape* b2ChainShape::Clone(b2BlockAllocator* allocator) const -{ - void* mem = allocator->Allocate(sizeof(b2ChainShape)); - b2ChainShape* clone = new (mem) b2ChainShape; - clone->CreateChain(m_vertices, m_count); - clone->m_prevVertex = m_prevVertex; - clone->m_nextVertex = m_nextVertex; - clone->m_hasPrevVertex = m_hasPrevVertex; - clone->m_hasNextVertex = m_hasNextVertex; - return clone; -} - -int32 b2ChainShape::GetChildCount() const -{ - // edge count = vertex count - 1 - return m_count - 1; -} - -void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const -{ - b2Assert(0 <= index && index < m_count - 1); - edge->m_type = b2Shape::e_edge; - edge->m_radius = m_radius; - - edge->m_vertex1 = m_vertices[index + 0]; - edge->m_vertex2 = m_vertices[index + 1]; - - if (index > 0) - { - edge->m_vertex0 = m_vertices[index - 1]; - edge->m_hasVertex0 = true; - } - else - { - edge->m_vertex0 = m_prevVertex; - edge->m_hasVertex0 = m_hasPrevVertex; - } - - if (index < m_count - 2) - { - edge->m_vertex3 = m_vertices[index + 2]; - edge->m_hasVertex3 = true; - } - else - { - edge->m_vertex3 = m_nextVertex; - edge->m_hasVertex3 = m_hasNextVertex; - } -} - -bool b2ChainShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const -{ - B2_NOT_USED(xf); - B2_NOT_USED(p); - return false; -} - -bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& xf, int32 childIndex) const -{ - b2Assert(childIndex < m_count); - - b2EdgeShape edgeShape; - - int32 i1 = childIndex; - int32 i2 = childIndex + 1; - if (i2 == m_count) - { - i2 = 0; - } - - edgeShape.m_vertex1 = m_vertices[i1]; - edgeShape.m_vertex2 = m_vertices[i2]; - - return edgeShape.RayCast(output, input, xf, 0); -} - -void b2ChainShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const -{ - b2Assert(childIndex < m_count); - - int32 i1 = childIndex; - int32 i2 = childIndex + 1; - if (i2 == m_count) - { - i2 = 0; - } - - b2Vec2 v1 = b2Mul(xf, m_vertices[i1]); - b2Vec2 v2 = b2Mul(xf, m_vertices[i2]); - - aabb->lowerBound = b2Min(v1, v2); - aabb->upperBound = b2Max(v1, v2); -} - -void b2ChainShape::ComputeMass(b2MassData* massData, float32 density) const -{ - B2_NOT_USED(density); - - massData->mass = 0.0f; - massData->center.SetZero(); - massData->I = 0.0f; -} diff --git a/sources/Box2D/Collision/Shapes/b2ChainShape.h b/sources/Box2D/Collision/Shapes/b2ChainShape.h deleted file mode 100755 index 8b378bc8..00000000 --- a/sources/Box2D/Collision/Shapes/b2ChainShape.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CHAIN_SHAPE_H -#define B2_CHAIN_SHAPE_H - -#include - -class b2EdgeShape; - -/// A chain shape is a free form sequence of line segments. -/// The chain has two-sided collision, so you can use inside and outside collision. -/// Therefore, you may use any winding order. -/// Since there may be many vertices, they are allocated using b2Alloc. -/// Connectivity information is used to create smooth collisions. -/// WARNING: The chain will not collide properly if there are self-intersections. -class b2ChainShape : public b2Shape -{ -public: - b2ChainShape(); - - /// The destructor frees the vertices using b2Free. - ~b2ChainShape(); - - /// Clear all data. - void Clear(); - - /// Create a loop. This automatically adjusts connectivity. - /// @param vertices an array of vertices, these are copied - /// @param count the vertex count - void CreateLoop(const b2Vec2* vertices, int32 count); - - /// Create a chain with isolated end vertices. - /// @param vertices an array of vertices, these are copied - /// @param count the vertex count - void CreateChain(const b2Vec2* vertices, int32 count); - - /// Establish connectivity to a vertex that precedes the first vertex. - /// Don't call this for loops. - void SetPrevVertex(const b2Vec2& prevVertex); - - /// Establish connectivity to a vertex that follows the last vertex. - /// Don't call this for loops. - void SetNextVertex(const b2Vec2& nextVertex); - - /// Implement b2Shape. Vertices are cloned using b2Alloc. - b2Shape* Clone(b2BlockAllocator* allocator) const; - - /// @see b2Shape::GetChildCount - int32 GetChildCount() const; - - /// Get a child edge. - void GetChildEdge(b2EdgeShape* edge, int32 index) const; - - /// This always return false. - /// @see b2Shape::TestPoint - bool TestPoint(const b2Transform& transform, const b2Vec2& p) const; - - /// Implement b2Shape. - bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeAABB - void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const; - - /// Chains have zero mass. - /// @see b2Shape::ComputeMass - void ComputeMass(b2MassData* massData, float32 density) const; - - /// The vertices. Owned by this class. - b2Vec2* m_vertices; - - /// The vertex count. - int32 m_count; - - b2Vec2 m_prevVertex, m_nextVertex; - bool m_hasPrevVertex, m_hasNextVertex; -}; - -inline b2ChainShape::b2ChainShape() -{ - m_type = e_chain; - m_radius = b2_polygonRadius; - m_vertices = NULL; - m_count = 0; - m_hasPrevVertex = false; - m_hasNextVertex = false; -} - -#endif diff --git a/sources/Box2D/Collision/Shapes/b2CircleShape.cpp b/sources/Box2D/Collision/Shapes/b2CircleShape.cpp deleted file mode 100755 index 47e5b372..00000000 --- a/sources/Box2D/Collision/Shapes/b2CircleShape.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -b2Shape* b2CircleShape::Clone(b2BlockAllocator* allocator) const -{ - void* mem = allocator->Allocate(sizeof(b2CircleShape)); - b2CircleShape* clone = new (mem) b2CircleShape; - *clone = *this; - return clone; -} - -int32 b2CircleShape::GetChildCount() const -{ - return 1; -} - -bool b2CircleShape::TestPoint(const b2Transform& transform, const b2Vec2& p) const -{ - b2Vec2 center = transform.p + b2Mul(transform.q, m_p); - b2Vec2 d = p - center; - return b2Dot(d, d) <= m_radius * m_radius; -} - -// Collision Detection in Interactive 3D Environments by Gino van den Bergen -// From Section 3.1.2 -// x = s + a * r -// norm(x) = radius -bool b2CircleShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& transform, int32 childIndex) const -{ - B2_NOT_USED(childIndex); - - b2Vec2 position = transform.p + b2Mul(transform.q, m_p); - b2Vec2 s = input.p1 - position; - float32 b = b2Dot(s, s) - m_radius * m_radius; - - // Solve quadratic equation. - b2Vec2 r = input.p2 - input.p1; - float32 c = b2Dot(s, r); - float32 rr = b2Dot(r, r); - float32 sigma = c * c - rr * b; - - // Check for negative discriminant and short segment. - if (sigma < 0.0f || rr < b2_epsilon) - { - return false; - } - - // Find the point of intersection of the line with the circle. - float32 a = -(c + b2Sqrt(sigma)); - - // Is the intersection point on the segment? - if (0.0f <= a && a <= input.maxFraction * rr) - { - a /= rr; - output->fraction = a; - output->normal = s + a * r; - output->normal.Normalize(); - return true; - } - - return false; -} - -void b2CircleShape::ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const -{ - B2_NOT_USED(childIndex); - - b2Vec2 p = transform.p + b2Mul(transform.q, m_p); - aabb->lowerBound.Set(p.x - m_radius, p.y - m_radius); - aabb->upperBound.Set(p.x + m_radius, p.y + m_radius); -} - -void b2CircleShape::ComputeMass(b2MassData* massData, float32 density) const -{ - massData->mass = density * b2_pi * m_radius * m_radius; - massData->center = m_p; - - // inertia about the local origin - massData->I = massData->mass * (0.5f * m_radius * m_radius + b2Dot(m_p, m_p)); -} diff --git a/sources/Box2D/Collision/Shapes/b2CircleShape.h b/sources/Box2D/Collision/Shapes/b2CircleShape.h deleted file mode 100755 index 6c1fd543..00000000 --- a/sources/Box2D/Collision/Shapes/b2CircleShape.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CIRCLE_SHAPE_H -#define B2_CIRCLE_SHAPE_H - -#include - -/// A circle shape. -class b2CircleShape : public b2Shape -{ -public: - b2CircleShape(); - - /// Implement b2Shape. - b2Shape* Clone(b2BlockAllocator* allocator) const; - - /// @see b2Shape::GetChildCount - int32 GetChildCount() const; - - /// Implement b2Shape. - bool TestPoint(const b2Transform& transform, const b2Vec2& p) const; - - /// Implement b2Shape. - bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeAABB - void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeMass - void ComputeMass(b2MassData* massData, float32 density) const; - - /// Get the supporting vertex index in the given direction. - int32 GetSupport(const b2Vec2& d) const; - - /// Get the supporting vertex in the given direction. - const b2Vec2& GetSupportVertex(const b2Vec2& d) const; - - /// Get the vertex count. - int32 GetVertexCount() const { return 1; } - - /// Get a vertex by index. Used by b2Distance. - const b2Vec2& GetVertex(int32 index) const; - - /// Position - b2Vec2 m_p; -}; - -inline b2CircleShape::b2CircleShape() -{ - m_type = e_circle; - m_radius = 0.0f; - m_p.SetZero(); -} - -inline int32 b2CircleShape::GetSupport(const b2Vec2 &d) const -{ - B2_NOT_USED(d); - return 0; -} - -inline const b2Vec2& b2CircleShape::GetSupportVertex(const b2Vec2 &d) const -{ - B2_NOT_USED(d); - return m_p; -} - -inline const b2Vec2& b2CircleShape::GetVertex(int32 index) const -{ - B2_NOT_USED(index); - b2Assert(index == 0); - return m_p; -} - -#endif diff --git a/sources/Box2D/Collision/Shapes/b2EdgeShape.cpp b/sources/Box2D/Collision/Shapes/b2EdgeShape.cpp deleted file mode 100755 index 3514b2ed..00000000 --- a/sources/Box2D/Collision/Shapes/b2EdgeShape.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -void b2EdgeShape::Set(const b2Vec2& v1, const b2Vec2& v2) -{ - m_vertex1 = v1; - m_vertex2 = v2; - m_hasVertex0 = false; - m_hasVertex3 = false; -} - -b2Shape* b2EdgeShape::Clone(b2BlockAllocator* allocator) const -{ - void* mem = allocator->Allocate(sizeof(b2EdgeShape)); - b2EdgeShape* clone = new (mem) b2EdgeShape; - *clone = *this; - return clone; -} - -int32 b2EdgeShape::GetChildCount() const -{ - return 1; -} - -bool b2EdgeShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const -{ - B2_NOT_USED(xf); - B2_NOT_USED(p); - return false; -} - -// p = p1 + t * d -// v = v1 + s * e -// p1 + t * d = v1 + s * e -// s * e - t * d = p1 - v1 -bool b2EdgeShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& xf, int32 childIndex) const -{ - B2_NOT_USED(childIndex); - - // Put the ray into the edge's frame of reference. - b2Vec2 p1 = b2MulT(xf.q, input.p1 - xf.p); - b2Vec2 p2 = b2MulT(xf.q, input.p2 - xf.p); - b2Vec2 d = p2 - p1; - - b2Vec2 v1 = m_vertex1; - b2Vec2 v2 = m_vertex2; - b2Vec2 e = v2 - v1; - b2Vec2 normal(e.y, -e.x); - normal.Normalize(); - - // q = p1 + t * d - // dot(normal, q - v1) = 0 - // dot(normal, p1 - v1) + t * dot(normal, d) = 0 - float32 numerator = b2Dot(normal, v1 - p1); - float32 denominator = b2Dot(normal, d); - - if (denominator == 0.0f) - { - return false; - } - - float32 t = numerator / denominator; - if (t < 0.0f || input.maxFraction < t) - { - return false; - } - - b2Vec2 q = p1 + t * d; - - // q = v1 + s * r - // s = dot(q - v1, r) / dot(r, r) - b2Vec2 r = v2 - v1; - float32 rr = b2Dot(r, r); - if (rr == 0.0f) - { - return false; - } - - float32 s = b2Dot(q - v1, r) / rr; - if (s < 0.0f || 1.0f < s) - { - return false; - } - - output->fraction = t; - if (numerator > 0.0f) - { - output->normal = -b2Mul(xf.q, normal); - } - else - { - output->normal = b2Mul(xf.q, normal); - } - return true; -} - -void b2EdgeShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const -{ - B2_NOT_USED(childIndex); - - b2Vec2 v1 = b2Mul(xf, m_vertex1); - b2Vec2 v2 = b2Mul(xf, m_vertex2); - - b2Vec2 lower = b2Min(v1, v2); - b2Vec2 upper = b2Max(v1, v2); - - b2Vec2 r(m_radius, m_radius); - aabb->lowerBound = lower - r; - aabb->upperBound = upper + r; -} - -void b2EdgeShape::ComputeMass(b2MassData* massData, float32 density) const -{ - B2_NOT_USED(density); - - massData->mass = 0.0f; - massData->center = 0.5f * (m_vertex1 + m_vertex2); - massData->I = 0.0f; -} diff --git a/sources/Box2D/Collision/Shapes/b2EdgeShape.h b/sources/Box2D/Collision/Shapes/b2EdgeShape.h deleted file mode 100755 index 99f822be..00000000 --- a/sources/Box2D/Collision/Shapes/b2EdgeShape.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_EDGE_SHAPE_H -#define B2_EDGE_SHAPE_H - -#include - -/// A line segment (edge) shape. These can be connected in chains or loops -/// to other edge shapes. The connectivity information is used to ensure -/// correct contact normals. -class b2EdgeShape : public b2Shape -{ -public: - b2EdgeShape(); - - /// Set this as an isolated edge. - void Set(const b2Vec2& v1, const b2Vec2& v2); - - /// Implement b2Shape. - b2Shape* Clone(b2BlockAllocator* allocator) const; - - /// @see b2Shape::GetChildCount - int32 GetChildCount() const; - - /// @see b2Shape::TestPoint - bool TestPoint(const b2Transform& transform, const b2Vec2& p) const; - - /// Implement b2Shape. - bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeAABB - void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeMass - void ComputeMass(b2MassData* massData, float32 density) const; - - /// These are the edge vertices - b2Vec2 m_vertex1, m_vertex2; - - /// Optional adjacent vertices. These are used for smooth collision. - b2Vec2 m_vertex0, m_vertex3; - bool m_hasVertex0, m_hasVertex3; -}; - -inline b2EdgeShape::b2EdgeShape() -{ - m_type = e_edge; - m_radius = b2_polygonRadius; - m_vertex0.x = 0.0f; - m_vertex0.y = 0.0f; - m_vertex3.x = 0.0f; - m_vertex3.y = 0.0f; - m_hasVertex0 = false; - m_hasVertex3 = false; -} - -#endif diff --git a/sources/Box2D/Collision/Shapes/b2PolygonShape.cpp b/sources/Box2D/Collision/Shapes/b2PolygonShape.cpp deleted file mode 100755 index 2ef6529d..00000000 --- a/sources/Box2D/Collision/Shapes/b2PolygonShape.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -b2Shape* b2PolygonShape::Clone(b2BlockAllocator* allocator) const -{ - void* mem = allocator->Allocate(sizeof(b2PolygonShape)); - b2PolygonShape* clone = new (mem) b2PolygonShape; - *clone = *this; - return clone; -} - -void b2PolygonShape::SetAsBox(float32 hx, float32 hy) -{ - m_count = 4; - m_vertices[0].Set(-hx, -hy); - m_vertices[1].Set( hx, -hy); - m_vertices[2].Set( hx, hy); - m_vertices[3].Set(-hx, hy); - m_normals[0].Set(0.0f, -1.0f); - m_normals[1].Set(1.0f, 0.0f); - m_normals[2].Set(0.0f, 1.0f); - m_normals[3].Set(-1.0f, 0.0f); - m_centroid.SetZero(); -} - -void b2PolygonShape::SetAsBox(float32 hx, float32 hy, const b2Vec2& center, float32 angle) -{ - m_count = 4; - m_vertices[0].Set(-hx, -hy); - m_vertices[1].Set( hx, -hy); - m_vertices[2].Set( hx, hy); - m_vertices[3].Set(-hx, hy); - m_normals[0].Set(0.0f, -1.0f); - m_normals[1].Set(1.0f, 0.0f); - m_normals[2].Set(0.0f, 1.0f); - m_normals[3].Set(-1.0f, 0.0f); - m_centroid = center; - - b2Transform xf; - xf.p = center; - xf.q.Set(angle); - - // Transform vertices and normals. - for (int32 i = 0; i < m_count; ++i) - { - m_vertices[i] = b2Mul(xf, m_vertices[i]); - m_normals[i] = b2Mul(xf.q, m_normals[i]); - } -} - -int32 b2PolygonShape::GetChildCount() const -{ - return 1; -} - -static b2Vec2 ComputeCentroid(const b2Vec2* vs, int32 count) -{ - b2Assert(count >= 3); - - b2Vec2 c; c.Set(0.0f, 0.0f); - float32 area = 0.0f; - - // pRef is the reference point for forming triangles. - // It's location doesn't change the result (except for rounding error). - b2Vec2 pRef(0.0f, 0.0f); -#if 0 - // This code would put the reference point inside the polygon. - for (int32 i = 0; i < count; ++i) - { - pRef += vs[i]; - } - pRef *= 1.0f / count; -#endif - - const float32 inv3 = 1.0f / 3.0f; - - for (int32 i = 0; i < count; ++i) - { - // Triangle vertices. - b2Vec2 p1 = pRef; - b2Vec2 p2 = vs[i]; - b2Vec2 p3 = i + 1 < count ? vs[i+1] : vs[0]; - - b2Vec2 e1 = p2 - p1; - b2Vec2 e2 = p3 - p1; - - float32 D = b2Cross(e1, e2); - - float32 triangleArea = 0.5f * D; - area += triangleArea; - - // Area weighted centroid - c += triangleArea * inv3 * (p1 + p2 + p3); - } - - // Centroid - b2Assert(area > b2_epsilon); - c *= 1.0f / area; - return c; -} - -void b2PolygonShape::Set(const b2Vec2* vertices, int32 count) -{ - b2Assert(3 <= count && count <= b2_maxPolygonVertices); - if (count < 3) - { - SetAsBox(1.0f, 1.0f); - return; - } - - int32 n = b2Min(count, b2_maxPolygonVertices); - - // Perform welding and copy vertices into local buffer. - b2Vec2 ps[b2_maxPolygonVertices]; - int32 tempCount = 0; - for (int32 i = 0; i < n; ++i) - { - b2Vec2 v = vertices[i]; - - bool unique = true; - for (int32 j = 0; j < tempCount; ++j) - { - if (b2DistanceSquared(v, ps[j]) < 0.5f * b2_linearSlop) - { - unique = false; - break; - } - } - - if (unique) - { - ps[tempCount++] = v; - } - } - - n = tempCount; - if (n < 3) - { - // Polygon is degenerate. - b2Assert(false); - SetAsBox(1.0f, 1.0f); - return; - } - - // Create the convex hull using the Gift wrapping algorithm - // http://en.wikipedia.org/wiki/Gift_wrapping_algorithm - - // Find the right most point on the hull - int32 i0 = 0; - float32 x0 = ps[0].x; - for (int32 i = 1; i < n; ++i) - { - float32 x = ps[i].x; - if (x > x0 || (x == x0 && ps[i].y < ps[i0].y)) - { - i0 = i; - x0 = x; - } - } - - int32 hull[b2_maxPolygonVertices]; - int32 m = 0; - int32 ih = i0; - - for (;;) - { - hull[m] = ih; - - int32 ie = 0; - for (int32 j = 1; j < n; ++j) - { - if (ie == ih) - { - ie = j; - continue; - } - - b2Vec2 r = ps[ie] - ps[hull[m]]; - b2Vec2 v = ps[j] - ps[hull[m]]; - float32 c = b2Cross(r, v); - if (c < 0.0f) - { - ie = j; - } - - // Collinearity check - if (c == 0.0f && v.LengthSquared() > r.LengthSquared()) - { - ie = j; - } - } - - ++m; - ih = ie; - - if (ie == i0) - { - break; - } - } - - if (m < 3) - { - // Polygon is degenerate. - b2Assert(false); - SetAsBox(1.0f, 1.0f); - return; - } - - m_count = m; - - // Copy vertices. - for (int32 i = 0; i < m; ++i) - { - m_vertices[i] = ps[hull[i]]; - } - - // Compute normals. Ensure the edges have non-zero length. - for (int32 i = 0; i < m; ++i) - { - int32 i1 = i; - int32 i2 = i + 1 < m ? i + 1 : 0; - b2Vec2 edge = m_vertices[i2] - m_vertices[i1]; - b2Assert(edge.LengthSquared() > b2_epsilon * b2_epsilon); - m_normals[i] = b2Cross(edge, 1.0f); - m_normals[i].Normalize(); - } - - // Compute the polygon centroid. - m_centroid = ComputeCentroid(m_vertices, m); -} - -bool b2PolygonShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const -{ - b2Vec2 pLocal = b2MulT(xf.q, p - xf.p); - - for (int32 i = 0; i < m_count; ++i) - { - float32 dot = b2Dot(m_normals[i], pLocal - m_vertices[i]); - if (dot > 0.0f) - { - return false; - } - } - - return true; -} - -bool b2PolygonShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& xf, int32 childIndex) const -{ - B2_NOT_USED(childIndex); - - // Put the ray into the polygon's frame of reference. - b2Vec2 p1 = b2MulT(xf.q, input.p1 - xf.p); - b2Vec2 p2 = b2MulT(xf.q, input.p2 - xf.p); - b2Vec2 d = p2 - p1; - - float32 lower = 0.0f, upper = input.maxFraction; - - int32 index = -1; - - for (int32 i = 0; i < m_count; ++i) - { - // p = p1 + a * d - // dot(normal, p - v) = 0 - // dot(normal, p1 - v) + a * dot(normal, d) = 0 - float32 numerator = b2Dot(m_normals[i], m_vertices[i] - p1); - float32 denominator = b2Dot(m_normals[i], d); - - if (denominator == 0.0f) - { - if (numerator < 0.0f) - { - return false; - } - } - else - { - // Note: we want this predicate without division: - // lower < numerator / denominator, where denominator < 0 - // Since denominator < 0, we have to flip the inequality: - // lower < numerator / denominator <==> denominator * lower > numerator. - if (denominator < 0.0f && numerator < lower * denominator) - { - // Increase lower. - // The segment enters this half-space. - lower = numerator / denominator; - index = i; - } - else if (denominator > 0.0f && numerator < upper * denominator) - { - // Decrease upper. - // The segment exits this half-space. - upper = numerator / denominator; - } - } - - // The use of epsilon here causes the assert on lower to trip - // in some cases. Apparently the use of epsilon was to make edge - // shapes work, but now those are handled separately. - //if (upper < lower - b2_epsilon) - if (upper < lower) - { - return false; - } - } - - b2Assert(0.0f <= lower && lower <= input.maxFraction); - - if (index >= 0) - { - output->fraction = lower; - output->normal = b2Mul(xf.q, m_normals[index]); - return true; - } - - return false; -} - -void b2PolygonShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const -{ - B2_NOT_USED(childIndex); - - b2Vec2 lower = b2Mul(xf, m_vertices[0]); - b2Vec2 upper = lower; - - for (int32 i = 1; i < m_count; ++i) - { - b2Vec2 v = b2Mul(xf, m_vertices[i]); - lower = b2Min(lower, v); - upper = b2Max(upper, v); - } - - b2Vec2 r(m_radius, m_radius); - aabb->lowerBound = lower - r; - aabb->upperBound = upper + r; -} - -void b2PolygonShape::ComputeMass(b2MassData* massData, float32 density) const -{ - // Polygon mass, centroid, and inertia. - // Let rho be the polygon density in mass per unit area. - // Then: - // mass = rho * int(dA) - // centroid.x = (1/mass) * rho * int(x * dA) - // centroid.y = (1/mass) * rho * int(y * dA) - // I = rho * int((x*x + y*y) * dA) - // - // We can compute these integrals by summing all the integrals - // for each triangle of the polygon. To evaluate the integral - // for a single triangle, we make a change of variables to - // the (u,v) coordinates of the triangle: - // x = x0 + e1x * u + e2x * v - // y = y0 + e1y * u + e2y * v - // where 0 <= u && 0 <= v && u + v <= 1. - // - // We integrate u from [0,1-v] and then v from [0,1]. - // We also need to use the Jacobian of the transformation: - // D = cross(e1, e2) - // - // Simplification: triangle centroid = (1/3) * (p1 + p2 + p3) - // - // The rest of the derivation is handled by computer algebra. - - b2Assert(m_count >= 3); - - b2Vec2 center; center.Set(0.0f, 0.0f); - float32 area = 0.0f; - float32 I = 0.0f; - - // s is the reference point for forming triangles. - // It's location doesn't change the result (except for rounding error). - b2Vec2 s(0.0f, 0.0f); - - // This code would put the reference point inside the polygon. - for (int32 i = 0; i < m_count; ++i) - { - s += m_vertices[i]; - } - s *= 1.0f / m_count; - - const float32 k_inv3 = 1.0f / 3.0f; - - for (int32 i = 0; i < m_count; ++i) - { - // Triangle vertices. - b2Vec2 e1 = m_vertices[i] - s; - b2Vec2 e2 = i + 1 < m_count ? m_vertices[i+1] - s : m_vertices[0] - s; - - float32 D = b2Cross(e1, e2); - - float32 triangleArea = 0.5f * D; - area += triangleArea; - - // Area weighted centroid - center += triangleArea * k_inv3 * (e1 + e2); - - float32 ex1 = e1.x, ey1 = e1.y; - float32 ex2 = e2.x, ey2 = e2.y; - - float32 intx2 = ex1*ex1 + ex2*ex1 + ex2*ex2; - float32 inty2 = ey1*ey1 + ey2*ey1 + ey2*ey2; - - I += (0.25f * k_inv3 * D) * (intx2 + inty2); - } - - // Total mass - massData->mass = density * area; - - // Center of mass - b2Assert(area > b2_epsilon); - center *= 1.0f / area; - massData->center = center + s; - - // Inertia tensor relative to the local origin (point s). - massData->I = density * I; - - // Shift to center of mass then to original body origin. - massData->I += massData->mass * (b2Dot(massData->center, massData->center) - b2Dot(center, center)); -} - -bool b2PolygonShape::Validate() const -{ - for (int32 i = 0; i < m_count; ++i) - { - int32 i1 = i; - int32 i2 = i < m_count - 1 ? i1 + 1 : 0; - b2Vec2 p = m_vertices[i1]; - b2Vec2 e = m_vertices[i2] - p; - - for (int32 j = 0; j < m_count; ++j) - { - if (j == i1 || j == i2) - { - continue; - } - - b2Vec2 v = m_vertices[j] - p; - float32 c = b2Cross(e, v); - if (c < 0.0f) - { - return false; - } - } - } - - return true; -} diff --git a/sources/Box2D/Collision/Shapes/b2PolygonShape.h b/sources/Box2D/Collision/Shapes/b2PolygonShape.h deleted file mode 100755 index d5c0e742..00000000 --- a/sources/Box2D/Collision/Shapes/b2PolygonShape.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_POLYGON_SHAPE_H -#define B2_POLYGON_SHAPE_H - -#include - -/// A convex polygon. It is assumed that the interior of the polygon is to -/// the left of each edge. -/// Polygons have a maximum number of vertices equal to b2_maxPolygonVertices. -/// In most cases you should not need many vertices for a convex polygon. -class b2PolygonShape : public b2Shape -{ -public: - b2PolygonShape(); - - /// Implement b2Shape. - b2Shape* Clone(b2BlockAllocator* allocator) const; - - /// @see b2Shape::GetChildCount - int32 GetChildCount() const; - - /// Create a convex hull from the given array of local points. - /// The count must be in the range [3, b2_maxPolygonVertices]. - /// @warning the points may be re-ordered, even if they form a convex polygon - /// @warning collinear points are handled but not removed. Collinear points - /// may lead to poor stacking behavior. - void Set(const b2Vec2* points, int32 count); - - /// Build vertices to represent an axis-aligned box centered on the local origin. - /// @param hx the half-width. - /// @param hy the half-height. - void SetAsBox(float32 hx, float32 hy); - - /// Build vertices to represent an oriented box. - /// @param hx the half-width. - /// @param hy the half-height. - /// @param center the center of the box in local coordinates. - /// @param angle the rotation of the box in local coordinates. - void SetAsBox(float32 hx, float32 hy, const b2Vec2& center, float32 angle); - - /// @see b2Shape::TestPoint - bool TestPoint(const b2Transform& transform, const b2Vec2& p) const; - - /// Implement b2Shape. - bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeAABB - void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const; - - /// @see b2Shape::ComputeMass - void ComputeMass(b2MassData* massData, float32 density) const; - - /// Get the vertex count. - int32 GetVertexCount() const { return m_count; } - - /// Get a vertex by index. - const b2Vec2& GetVertex(int32 index) const; - - /// Validate convexity. This is a very time consuming operation. - /// @returns true if valid - bool Validate() const; - - b2Vec2 m_centroid; - b2Vec2 m_vertices[b2_maxPolygonVertices]; - b2Vec2 m_normals[b2_maxPolygonVertices]; - int32 m_count; -}; - -inline b2PolygonShape::b2PolygonShape() -{ - m_type = e_polygon; - m_radius = b2_polygonRadius; - m_count = 0; - m_centroid.SetZero(); -} - -inline const b2Vec2& b2PolygonShape::GetVertex(int32 index) const -{ - b2Assert(0 <= index && index < m_count); - return m_vertices[index]; -} - -#endif diff --git a/sources/Box2D/Collision/Shapes/b2Shape.h b/sources/Box2D/Collision/Shapes/b2Shape.h deleted file mode 100755 index fd7de262..00000000 --- a/sources/Box2D/Collision/Shapes/b2Shape.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_SHAPE_H -#define B2_SHAPE_H - -#include -#include -#include - -/// This holds the mass data computed for a shape. -struct b2MassData -{ - /// The mass of the shape, usually in kilograms. - float32 mass; - - /// The position of the shape's centroid relative to the shape's origin. - b2Vec2 center; - - /// The rotational inertia of the shape about the local origin. - float32 I; -}; - -/// A shape is used for collision detection. You can create a shape however you like. -/// Shapes used for simulation in b2World are created automatically when a b2Fixture -/// is created. Shapes may encapsulate a one or more child shapes. -class b2Shape -{ -public: - - enum Type - { - e_circle = 0, - e_edge = 1, - e_polygon = 2, - e_chain = 3, - e_typeCount = 4 - }; - - virtual ~b2Shape() {} - - /// Clone the concrete shape using the provided allocator. - virtual b2Shape* Clone(b2BlockAllocator* allocator) const = 0; - - /// Get the type of this shape. You can use this to down cast to the concrete shape. - /// @return the shape type. - Type GetType() const; - - /// Get the number of child primitives. - virtual int32 GetChildCount() const = 0; - - /// Test a point for containment in this shape. This only works for convex shapes. - /// @param xf the shape world transform. - /// @param p a point in world coordinates. - virtual bool TestPoint(const b2Transform& xf, const b2Vec2& p) const = 0; - - /// Cast a ray against a child shape. - /// @param output the ray-cast results. - /// @param input the ray-cast input parameters. - /// @param transform the transform to be applied to the shape. - /// @param childIndex the child shape index - virtual bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, - const b2Transform& transform, int32 childIndex) const = 0; - - /// Given a transform, compute the associated axis aligned bounding box for a child shape. - /// @param aabb returns the axis aligned box. - /// @param xf the world transform of the shape. - /// @param childIndex the child shape - virtual void ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const = 0; - - /// Compute the mass properties of this shape using its dimensions and density. - /// The inertia tensor is computed about the local origin. - /// @param massData returns the mass data for this shape. - /// @param density the density in kilograms per meter squared. - virtual void ComputeMass(b2MassData* massData, float32 density) const = 0; - - Type m_type; - float32 m_radius; -}; - -inline b2Shape::Type b2Shape::GetType() const -{ - return m_type; -} - -#endif diff --git a/sources/Box2D/Collision/b2BroadPhase.cpp b/sources/Box2D/Collision/b2BroadPhase.cpp deleted file mode 100755 index 6cddf719..00000000 --- a/sources/Box2D/Collision/b2BroadPhase.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 - -b2BroadPhase::b2BroadPhase() -{ - m_proxyCount = 0; - - m_pairCapacity = 16; - m_pairCount = 0; - m_pairBuffer = (b2Pair*)b2Alloc(m_pairCapacity * sizeof(b2Pair)); - - m_moveCapacity = 16; - m_moveCount = 0; - m_moveBuffer = (int32*)b2Alloc(m_moveCapacity * sizeof(int32)); -} - -b2BroadPhase::~b2BroadPhase() -{ - b2Free(m_moveBuffer); - b2Free(m_pairBuffer); -} - -int32 b2BroadPhase::CreateProxy(const b2AABB& aabb, void* userData) -{ - int32 proxyId = m_tree.CreateProxy(aabb, userData); - ++m_proxyCount; - BufferMove(proxyId); - return proxyId; -} - -void b2BroadPhase::DestroyProxy(int32 proxyId) -{ - UnBufferMove(proxyId); - --m_proxyCount; - m_tree.DestroyProxy(proxyId); -} - -void b2BroadPhase::MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement) -{ - bool buffer = m_tree.MoveProxy(proxyId, aabb, displacement); - if (buffer) - { - BufferMove(proxyId); - } -} - -void b2BroadPhase::TouchProxy(int32 proxyId) -{ - BufferMove(proxyId); -} - -void b2BroadPhase::BufferMove(int32 proxyId) -{ - if (m_moveCount == m_moveCapacity) - { - int32* oldBuffer = m_moveBuffer; - m_moveCapacity *= 2; - m_moveBuffer = (int32*)b2Alloc(m_moveCapacity * sizeof(int32)); - memcpy(m_moveBuffer, oldBuffer, m_moveCount * sizeof(int32)); - b2Free(oldBuffer); - } - - m_moveBuffer[m_moveCount] = proxyId; - ++m_moveCount; -} - -void b2BroadPhase::UnBufferMove(int32 proxyId) -{ - for (int32 i = 0; i < m_moveCount; ++i) - { - if (m_moveBuffer[i] == proxyId) - { - m_moveBuffer[i] = e_nullProxy; - } - } -} - -// This is called from b2DynamicTree::Query when we are gathering pairs. -bool b2BroadPhase::QueryCallback(int32 proxyId) -{ - // A proxy cannot form a pair with itself. - if (proxyId == m_queryProxyId) - { - return true; - } - - // Grow the pair buffer as needed. - if (m_pairCount == m_pairCapacity) - { - b2Pair* oldBuffer = m_pairBuffer; - m_pairCapacity *= 2; - m_pairBuffer = (b2Pair*)b2Alloc(m_pairCapacity * sizeof(b2Pair)); - memcpy(m_pairBuffer, oldBuffer, m_pairCount * sizeof(b2Pair)); - b2Free(oldBuffer); - } - - m_pairBuffer[m_pairCount].proxyIdA = b2Min(proxyId, m_queryProxyId); - m_pairBuffer[m_pairCount].proxyIdB = b2Max(proxyId, m_queryProxyId); - ++m_pairCount; - - return true; -} diff --git a/sources/Box2D/Collision/b2BroadPhase.h b/sources/Box2D/Collision/b2BroadPhase.h deleted file mode 100755 index 49057104..00000000 --- a/sources/Box2D/Collision/b2BroadPhase.h +++ /dev/null @@ -1,257 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_BROAD_PHASE_H -#define B2_BROAD_PHASE_H - -#include -#include -#include -#include - -struct b2Pair -{ - int32 proxyIdA; - int32 proxyIdB; -}; - -/// The broad-phase is used for computing pairs and performing volume queries and ray casts. -/// This broad-phase does not persist pairs. Instead, this reports potentially new pairs. -/// It is up to the client to consume the new pairs and to track subsequent overlap. -class b2BroadPhase -{ -public: - - enum - { - e_nullProxy = -1 - }; - - b2BroadPhase(); - ~b2BroadPhase(); - - /// Create a proxy with an initial AABB. Pairs are not reported until - /// UpdatePairs is called. - int32 CreateProxy(const b2AABB& aabb, void* userData); - - /// Destroy a proxy. It is up to the client to remove any pairs. - void DestroyProxy(int32 proxyId); - - /// Call MoveProxy as many times as you like, then when you are done - /// call UpdatePairs to finalized the proxy pairs (for your time step). - void MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement); - - /// Call to trigger a re-processing of it's pairs on the next call to UpdatePairs. - void TouchProxy(int32 proxyId); - - /// Get the fat AABB for a proxy. - const b2AABB& GetFatAABB(int32 proxyId) const; - - /// Get user data from a proxy. Returns NULL if the id is invalid. - void* GetUserData(int32 proxyId) const; - - /// Test overlap of fat AABBs. - bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const; - - /// Get the number of proxies. - int32 GetProxyCount() const; - - /// Update the pairs. This results in pair callbacks. This can only add pairs. - template - void UpdatePairs(T* callback); - - /// Query an AABB for overlapping proxies. The callback class - /// is called for each proxy that overlaps the supplied AABB. - template - void Query(T* callback, const b2AABB& aabb) const; - - /// Ray-cast against the proxies in the tree. This relies on the callback - /// to perform a exact ray-cast in the case were the proxy contains a shape. - /// The callback also performs the any collision filtering. This has performance - /// roughly equal to k * log(n), where k is the number of collisions and n is the - /// number of proxies in the tree. - /// @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). - /// @param callback a callback class that is called for each proxy that is hit by the ray. - template - void RayCast(T* callback, const b2RayCastInput& input) const; - - /// Get the height of the embedded tree. - int32 GetTreeHeight() const; - - /// Get the balance of the embedded tree. - int32 GetTreeBalance() const; - - /// Get the quality metric of the embedded tree. - float32 GetTreeQuality() const; - - /// Shift the world origin. Useful for large worlds. - /// The shift formula is: position -= newOrigin - /// @param newOrigin the new origin with respect to the old origin - void ShiftOrigin(const b2Vec2& newOrigin); - -private: - - friend class b2DynamicTree; - - void BufferMove(int32 proxyId); - void UnBufferMove(int32 proxyId); - - bool QueryCallback(int32 proxyId); - - b2DynamicTree m_tree; - - int32 m_proxyCount; - - int32* m_moveBuffer; - int32 m_moveCapacity; - int32 m_moveCount; - - b2Pair* m_pairBuffer; - int32 m_pairCapacity; - int32 m_pairCount; - - int32 m_queryProxyId; -}; - -/// This is used to sort pairs. -inline bool b2PairLessThan(const b2Pair& pair1, const b2Pair& pair2) -{ - if (pair1.proxyIdA < pair2.proxyIdA) - { - return true; - } - - if (pair1.proxyIdA == pair2.proxyIdA) - { - return pair1.proxyIdB < pair2.proxyIdB; - } - - return false; -} - -inline void* b2BroadPhase::GetUserData(int32 proxyId) const -{ - return m_tree.GetUserData(proxyId); -} - -inline bool b2BroadPhase::TestOverlap(int32 proxyIdA, int32 proxyIdB) const -{ - const b2AABB& aabbA = m_tree.GetFatAABB(proxyIdA); - const b2AABB& aabbB = m_tree.GetFatAABB(proxyIdB); - return b2TestOverlap(aabbA, aabbB); -} - -inline const b2AABB& b2BroadPhase::GetFatAABB(int32 proxyId) const -{ - return m_tree.GetFatAABB(proxyId); -} - -inline int32 b2BroadPhase::GetProxyCount() const -{ - return m_proxyCount; -} - -inline int32 b2BroadPhase::GetTreeHeight() const -{ - return m_tree.GetHeight(); -} - -inline int32 b2BroadPhase::GetTreeBalance() const -{ - return m_tree.GetMaxBalance(); -} - -inline float32 b2BroadPhase::GetTreeQuality() const -{ - return m_tree.GetAreaRatio(); -} - -template -void b2BroadPhase::UpdatePairs(T* callback) -{ - // Reset pair buffer - m_pairCount = 0; - - // Perform tree queries for all moving proxies. - for (int32 i = 0; i < m_moveCount; ++i) - { - m_queryProxyId = m_moveBuffer[i]; - if (m_queryProxyId == e_nullProxy) - { - continue; - } - - // We have to query the tree with the fat AABB so that - // we don't fail to create a pair that may touch later. - const b2AABB& fatAABB = m_tree.GetFatAABB(m_queryProxyId); - - // Query tree, create pairs and add them pair buffer. - m_tree.Query(this, fatAABB); - } - - // Reset move buffer - m_moveCount = 0; - - // Sort the pair buffer to expose duplicates. - std::sort(m_pairBuffer, m_pairBuffer + m_pairCount, b2PairLessThan); - - // Send the pairs back to the client. - int32 i = 0; - while (i < m_pairCount) - { - b2Pair* primaryPair = m_pairBuffer + i; - void* userDataA = m_tree.GetUserData(primaryPair->proxyIdA); - void* userDataB = m_tree.GetUserData(primaryPair->proxyIdB); - - callback->AddPair(userDataA, userDataB); - ++i; - - // Skip any duplicate pairs. - while (i < m_pairCount) - { - b2Pair* pair = m_pairBuffer + i; - if (pair->proxyIdA != primaryPair->proxyIdA || pair->proxyIdB != primaryPair->proxyIdB) - { - break; - } - ++i; - } - } - - // Try to keep the tree balanced. - //m_tree.Rebalance(4); -} - -template -inline void b2BroadPhase::Query(T* callback, const b2AABB& aabb) const -{ - m_tree.Query(callback, aabb); -} - -template -inline void b2BroadPhase::RayCast(T* callback, const b2RayCastInput& input) const -{ - m_tree.RayCast(callback, input); -} - -inline void b2BroadPhase::ShiftOrigin(const b2Vec2& newOrigin) -{ - m_tree.ShiftOrigin(newOrigin); -} - -#endif diff --git a/sources/Box2D/Collision/b2CollideCircle.cpp b/sources/Box2D/Collision/b2CollideCircle.cpp deleted file mode 100755 index e60b2086..00000000 --- a/sources/Box2D/Collision/b2CollideCircle.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -void b2CollideCircles( - b2Manifold* manifold, - const b2CircleShape* circleA, const b2Transform& xfA, - const b2CircleShape* circleB, const b2Transform& xfB) -{ - manifold->pointCount = 0; - - b2Vec2 pA = b2Mul(xfA, circleA->m_p); - b2Vec2 pB = b2Mul(xfB, circleB->m_p); - - b2Vec2 d = pB - pA; - float32 distSqr = b2Dot(d, d); - float32 rA = circleA->m_radius, rB = circleB->m_radius; - float32 radius = rA + rB; - if (distSqr > radius * radius) - { - return; - } - - manifold->type = b2Manifold::e_circles; - manifold->localPoint = circleA->m_p; - manifold->localNormal.SetZero(); - manifold->pointCount = 1; - - manifold->points[0].localPoint = circleB->m_p; - manifold->points[0].id.key = 0; -} - -void b2CollidePolygonAndCircle( - b2Manifold* manifold, - const b2PolygonShape* polygonA, const b2Transform& xfA, - const b2CircleShape* circleB, const b2Transform& xfB) -{ - manifold->pointCount = 0; - - // Compute circle position in the frame of the polygon. - b2Vec2 c = b2Mul(xfB, circleB->m_p); - b2Vec2 cLocal = b2MulT(xfA, c); - - // Find the min separating edge. - int32 normalIndex = 0; - float32 separation = -b2_maxFloat; - float32 radius = polygonA->m_radius + circleB->m_radius; - int32 vertexCount = polygonA->m_count; - const b2Vec2* vertices = polygonA->m_vertices; - const b2Vec2* normals = polygonA->m_normals; - - for (int32 i = 0; i < vertexCount; ++i) - { - float32 s = b2Dot(normals[i], cLocal - vertices[i]); - - if (s > radius) - { - // Early out. - return; - } - - if (s > separation) - { - separation = s; - normalIndex = i; - } - } - - // Vertices that subtend the incident face. - int32 vertIndex1 = normalIndex; - int32 vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0; - b2Vec2 v1 = vertices[vertIndex1]; - b2Vec2 v2 = vertices[vertIndex2]; - - // If the center is inside the polygon ... - if (separation < b2_epsilon) - { - manifold->pointCount = 1; - manifold->type = b2Manifold::e_faceA; - manifold->localNormal = normals[normalIndex]; - manifold->localPoint = 0.5f * (v1 + v2); - manifold->points[0].localPoint = circleB->m_p; - manifold->points[0].id.key = 0; - return; - } - - // Compute barycentric coordinates - float32 u1 = b2Dot(cLocal - v1, v2 - v1); - float32 u2 = b2Dot(cLocal - v2, v1 - v2); - if (u1 <= 0.0f) - { - if (b2DistanceSquared(cLocal, v1) > radius * radius) - { - return; - } - - manifold->pointCount = 1; - manifold->type = b2Manifold::e_faceA; - manifold->localNormal = cLocal - v1; - manifold->localNormal.Normalize(); - manifold->localPoint = v1; - manifold->points[0].localPoint = circleB->m_p; - manifold->points[0].id.key = 0; - } - else if (u2 <= 0.0f) - { - if (b2DistanceSquared(cLocal, v2) > radius * radius) - { - return; - } - - manifold->pointCount = 1; - manifold->type = b2Manifold::e_faceA; - manifold->localNormal = cLocal - v2; - manifold->localNormal.Normalize(); - manifold->localPoint = v2; - manifold->points[0].localPoint = circleB->m_p; - manifold->points[0].id.key = 0; - } - else - { - b2Vec2 faceCenter = 0.5f * (v1 + v2); - float32 separation = b2Dot(cLocal - faceCenter, normals[vertIndex1]); - if (separation > radius) - { - return; - } - - manifold->pointCount = 1; - manifold->type = b2Manifold::e_faceA; - manifold->localNormal = normals[vertIndex1]; - manifold->localPoint = faceCenter; - manifold->points[0].localPoint = circleB->m_p; - manifold->points[0].id.key = 0; - } -} diff --git a/sources/Box2D/Collision/b2CollideEdge.cpp b/sources/Box2D/Collision/b2CollideEdge.cpp deleted file mode 100755 index c8276be7..00000000 --- a/sources/Box2D/Collision/b2CollideEdge.cpp +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright (c) 2007-2009 Erin Catto http://www.box2d.org - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as 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 -#include -#include -#include - - -// Compute contact points for edge versus circle. -// This accounts for edge connectivity. -void b2CollideEdgeAndCircle(b2Manifold* manifold, - const b2EdgeShape* edgeA, const b2Transform& xfA, - const b2CircleShape* circleB, const b2Transform& xfB) -{ - manifold->pointCount = 0; - - // Compute circle in frame of edge - b2Vec2 Q = b2MulT(xfA, b2Mul(xfB, circleB->m_p)); - - b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_vertex2; - b2Vec2 e = B - A; - - // Barycentric coordinates - float32 u = b2Dot(e, B - Q); - float32 v = b2Dot(e, Q - A); - - float32 radius = edgeA->m_radius + circleB->m_radius; - - b2ContactFeature cf; - cf.indexB = 0; - cf.typeB = b2ContactFeature::e_vertex; - - // Region A - if (v <= 0.0f) - { - b2Vec2 P = A; - b2Vec2 d = Q - P; - float32 dd = b2Dot(d, d); - if (dd > radius * radius) - { - return; - } - - // Is there an edge connected to A? - if (edgeA->m_hasVertex0) - { - b2Vec2 A1 = edgeA->m_vertex0; - b2Vec2 B1 = A; - b2Vec2 e1 = B1 - A1; - float32 u1 = b2Dot(e1, B1 - Q); - - // Is the circle in Region AB of the previous edge? - if (u1 > 0.0f) - { - return; - } - } - - cf.indexA = 0; - cf.typeA = b2ContactFeature::e_vertex; - manifold->pointCount = 1; - manifold->type = b2Manifold::e_circles; - manifold->localNormal.SetZero(); - manifold->localPoint = P; - manifold->points[0].id.key = 0; - manifold->points[0].id.cf = cf; - manifold->points[0].localPoint = circleB->m_p; - return; - } - - // Region B - if (u <= 0.0f) - { - b2Vec2 P = B; - b2Vec2 d = Q - P; - float32 dd = b2Dot(d, d); - if (dd > radius * radius) - { - return; - } - - // Is there an edge connected to B? - if (edgeA->m_hasVertex3) - { - b2Vec2 B2 = edgeA->m_vertex3; - b2Vec2 A2 = B; - b2Vec2 e2 = B2 - A2; - float32 v2 = b2Dot(e2, Q - A2); - - // Is the circle in Region AB of the next edge? - if (v2 > 0.0f) - { - return; - } - } - - cf.indexA = 1; - cf.typeA = b2ContactFeature::e_vertex; - manifold->pointCount = 1; - manifold->type = b2Manifold::e_circles; - manifold->localNormal.SetZero(); - manifold->localPoint = P; - manifold->points[0].id.key = 0; - manifold->points[0].id.cf = cf; - manifold->points[0].localPoint = circleB->m_p; - return; - } - - // Region AB - float32 den = b2Dot(e, e); - b2Assert(den > 0.0f); - b2Vec2 P = (1.0f / den) * (u * A + v * B); - b2Vec2 d = Q - P; - float32 dd = b2Dot(d, d); - if (dd > radius * radius) - { - return; - } - - b2Vec2 n(-e.y, e.x); - if (b2Dot(n, Q - A) < 0.0f) - { - n.Set(-n.x, -n.y); - } - n.Normalize(); - - cf.indexA = 0; - cf.typeA = b2ContactFeature::e_face; - manifold->pointCount = 1; - manifold->type = b2Manifold::e_faceA; - manifold->localNormal = n; - manifold->localPoint = A; - manifold->points[0].id.key = 0; - manifold->points[0].id.cf = cf; - manifold->points[0].localPoint = circleB->m_p; -} - -// This structure is used to keep track of the best separating axis. -struct b2EPAxis -{ - enum Type - { - e_unknown, - e_edgeA, - e_edgeB - }; - - Type type; - int32 index; - float32 separation; -}; - -// This holds polygon B expressed in frame A. -struct b2TempPolygon -{ - b2Vec2 vertices[b2_maxPolygonVertices]; - b2Vec2 normals[b2_maxPolygonVertices]; - int32 count; -}; - -// Reference face used for clipping -struct b2ReferenceFace -{ - int32 i1, i2; - - b2Vec2 v1, v2; - - b2Vec2 normal; - - b2Vec2 sideNormal1; - float32 sideOffset1; - - b2Vec2 sideNormal2; - float32 sideOffset2; -}; - -// This class collides and edge and a polygon, taking into account edge adjacency. -struct b2EPCollider -{ - void Collide(b2Manifold* manifold, const b2EdgeShape* edgeA, const b2Transform& xfA, - const b2PolygonShape* polygonB, const b2Transform& xfB); - b2EPAxis ComputeEdgeSeparation(); - b2EPAxis ComputePolygonSeparation(); - - enum VertexType - { - e_isolated, - e_concave, - e_convex - }; - - b2TempPolygon m_polygonB; - - b2Transform m_xf; - b2Vec2 m_centroidB; - b2Vec2 m_v0, m_v1, m_v2, m_v3; - b2Vec2 m_normal0, m_normal1, m_normal2; - b2Vec2 m_normal; - VertexType m_type1, m_type2; - b2Vec2 m_lowerLimit, m_upperLimit; - float32 m_radius; - bool m_front; -}; - -// Algorithm: -// 1. Classify v1 and v2 -// 2. Classify polygon centroid as front or back -// 3. Flip normal if necessary -// 4. Initialize normal range to [-pi, pi] about face normal -// 5. Adjust normal range according to adjacent edges -// 6. Visit each separating axes, only accept axes within the range -// 7. Return if _any_ axis indicates separation -// 8. Clip -void b2EPCollider::Collide(b2Manifold* manifold, const b2EdgeShape* edgeA, const b2Transform& xfA, - const b2PolygonShape* polygonB, const b2Transform& xfB) -{ - m_xf = b2MulT(xfA, xfB); - - m_centroidB = b2Mul(m_xf, polygonB->m_centroid); - - m_v0 = edgeA->m_vertex0; - m_v1 = edgeA->m_vertex1; - m_v2 = edgeA->m_vertex2; - m_v3 = edgeA->m_vertex3; - - bool hasVertex0 = edgeA->m_hasVertex0; - bool hasVertex3 = edgeA->m_hasVertex3; - - b2Vec2 edge1 = m_v2 - m_v1; - edge1.Normalize(); - m_normal1.Set(edge1.y, -edge1.x); - float32 offset1 = b2Dot(m_normal1, m_centroidB - m_v1); - float32 offset0 = 0.0f, offset2 = 0.0f; - bool convex1 = false, convex2 = false; - - // Is there a preceding edge? - if (hasVertex0) - { - b2Vec2 edge0 = m_v1 - m_v0; - edge0.Normalize(); - m_normal0.Set(edge0.y, -edge0.x); - convex1 = b2Cross(edge0, edge1) >= 0.0f; - offset0 = b2Dot(m_normal0, m_centroidB - m_v0); - } - - // Is there a following edge? - if (hasVertex3) - { - b2Vec2 edge2 = m_v3 - m_v2; - edge2.Normalize(); - m_normal2.Set(edge2.y, -edge2.x); - convex2 = b2Cross(edge1, edge2) > 0.0f; - offset2 = b2Dot(m_normal2, m_centroidB - m_v2); - } - - // Determine front or back collision. Determine collision normal limits. - if (hasVertex0 && hasVertex3) - { - if (convex1 && convex2) - { - m_front = offset0 >= 0.0f || offset1 >= 0.0f || offset2 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = m_normal0; - m_upperLimit = m_normal2; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = -m_normal1; - m_upperLimit = -m_normal1; - } - } - else if (convex1) - { - m_front = offset0 >= 0.0f || (offset1 >= 0.0f && offset2 >= 0.0f); - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = m_normal0; - m_upperLimit = m_normal1; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = -m_normal2; - m_upperLimit = -m_normal1; - } - } - else if (convex2) - { - m_front = offset2 >= 0.0f || (offset0 >= 0.0f && offset1 >= 0.0f); - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = m_normal1; - m_upperLimit = m_normal2; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = -m_normal1; - m_upperLimit = -m_normal0; - } - } - else - { - m_front = offset0 >= 0.0f && offset1 >= 0.0f && offset2 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = m_normal1; - m_upperLimit = m_normal1; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = -m_normal2; - m_upperLimit = -m_normal0; - } - } - } - else if (hasVertex0) - { - if (convex1) - { - m_front = offset0 >= 0.0f || offset1 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = m_normal0; - m_upperLimit = -m_normal1; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = m_normal1; - m_upperLimit = -m_normal1; - } - } - else - { - m_front = offset0 >= 0.0f && offset1 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = m_normal1; - m_upperLimit = -m_normal1; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = m_normal1; - m_upperLimit = -m_normal0; - } - } - } - else if (hasVertex3) - { - if (convex2) - { - m_front = offset1 >= 0.0f || offset2 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = -m_normal1; - m_upperLimit = m_normal2; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = -m_normal1; - m_upperLimit = m_normal1; - } - } - else - { - m_front = offset1 >= 0.0f && offset2 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = -m_normal1; - m_upperLimit = m_normal1; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = -m_normal2; - m_upperLimit = m_normal1; - } - } - } - else - { - m_front = offset1 >= 0.0f; - if (m_front) - { - m_normal = m_normal1; - m_lowerLimit = -m_normal1; - m_upperLimit = -m_normal1; - } - else - { - m_normal = -m_normal1; - m_lowerLimit = m_normal1; - m_upperLimit = m_normal1; - } - } - - // Get polygonB in frameA - m_polygonB.count = polygonB->m_count; - for (int32 i = 0; i < polygonB->m_count; ++i) - { - m_polygonB.vertices[i] = b2Mul(m_xf, polygonB->m_vertices[i]); - m_polygonB.normals[i] = b2Mul(m_xf.q, polygonB->m_normals[i]); - } - - m_radius = 2.0f * b2_polygonRadius; - - manifold->pointCount = 0; - - b2EPAxis edgeAxis = ComputeEdgeSeparation(); - - // If no valid normal can be found than this edge should not collide. - if (edgeAxis.type == b2EPAxis::e_unknown) - { - return; - } - - if (edgeAxis.separation > m_radius) - { - return; - } - - b2EPAxis polygonAxis = ComputePolygonSeparation(); - if (polygonAxis.type != b2EPAxis::e_unknown && polygonAxis.separation > m_radius) - { - return; - } - - // Use hysteresis for jitter reduction. - const float32 k_relativeTol = 0.98f; - const float32 k_absoluteTol = 0.001f; - - b2EPAxis primaryAxis; - if (polygonAxis.type == b2EPAxis::e_unknown) - { - primaryAxis = edgeAxis; - } - else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) - { - primaryAxis = polygonAxis; - } - else - { - primaryAxis = edgeAxis; - } - - b2ClipVertex ie[2]; - b2ReferenceFace rf; - if (primaryAxis.type == b2EPAxis::e_edgeA) - { - manifold->type = b2Manifold::e_faceA; - - // Search for the polygon normal that is most anti-parallel to the edge normal. - int32 bestIndex = 0; - float32 bestValue = b2Dot(m_normal, m_polygonB.normals[0]); - for (int32 i = 1; i < m_polygonB.count; ++i) - { - float32 value = b2Dot(m_normal, m_polygonB.normals[i]); - if (value < bestValue) - { - bestValue = value; - bestIndex = i; - } - } - - int32 i1 = bestIndex; - int32 i2 = i1 + 1 < m_polygonB.count ? i1 + 1 : 0; - - ie[0].v = m_polygonB.vertices[i1]; - ie[0].id.cf.indexA = 0; - ie[0].id.cf.indexB = static_cast(i1); - ie[0].id.cf.typeA = b2ContactFeature::e_face; - ie[0].id.cf.typeB = b2ContactFeature::e_vertex; - - ie[1].v = m_polygonB.vertices[i2]; - ie[1].id.cf.indexA = 0; - ie[1].id.cf.indexB = static_cast(i2); - ie[1].id.cf.typeA = b2ContactFeature::e_face; - ie[1].id.cf.typeB = b2ContactFeature::e_vertex; - - if (m_front) - { - rf.i1 = 0; - rf.i2 = 1; - rf.v1 = m_v1; - rf.v2 = m_v2; - rf.normal = m_normal1; - } - else - { - rf.i1 = 1; - rf.i2 = 0; - rf.v1 = m_v2; - rf.v2 = m_v1; - rf.normal = -m_normal1; - } - } - else - { - manifold->type = b2Manifold::e_faceB; - - ie[0].v = m_v1; - ie[0].id.cf.indexA = 0; - ie[0].id.cf.indexB = static_cast(primaryAxis.index); - ie[0].id.cf.typeA = b2ContactFeature::e_vertex; - ie[0].id.cf.typeB = b2ContactFeature::e_face; - - ie[1].v = m_v2; - ie[1].id.cf.indexA = 0; - ie[1].id.cf.indexB = static_cast(primaryAxis.index); - ie[1].id.cf.typeA = b2ContactFeature::e_vertex; - ie[1].id.cf.typeB = b2ContactFeature::e_face; - - rf.i1 = primaryAxis.index; - rf.i2 = rf.i1 + 1 < m_polygonB.count ? rf.i1 + 1 : 0; - rf.v1 = m_polygonB.vertices[rf.i1]; - rf.v2 = m_polygonB.vertices[rf.i2]; - rf.normal = m_polygonB.normals[rf.i1]; - } - - rf.sideNormal1.Set(rf.normal.y, -rf.normal.x); - rf.sideNormal2 = -rf.sideNormal1; - rf.sideOffset1 = b2Dot(rf.sideNormal1, rf.v1); - rf.sideOffset2 = b2Dot(rf.sideNormal2, rf.v2); - - // Clip incident edge against extruded edge1 side edges. - b2ClipVertex clipPoints1[2]; - b2ClipVertex clipPoints2[2]; - int32 np; - - // Clip to box side 1 - np = b2ClipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1); - - if (np < b2_maxManifoldPoints) - { - return; - } - - // Clip to negative box side 1 - np = b2ClipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2); - - if (np < b2_maxManifoldPoints) - { - return; - } - - // Now clipPoints2 contains the clipped points. - if (primaryAxis.type == b2EPAxis::e_edgeA) - { - manifold->localNormal = rf.normal; - manifold->localPoint = rf.v1; - } - else - { - manifold->localNormal = polygonB->m_normals[rf.i1]; - manifold->localPoint = polygonB->m_vertices[rf.i1]; - } - - int32 pointCount = 0; - for (int32 i = 0; i < b2_maxManifoldPoints; ++i) - { - float32 separation; - - separation = b2Dot(rf.normal, clipPoints2[i].v - rf.v1); - - if (separation <= m_radius) - { - b2ManifoldPoint* cp = manifold->points + pointCount; - - if (primaryAxis.type == b2EPAxis::e_edgeA) - { - cp->localPoint = b2MulT(m_xf, clipPoints2[i].v); - cp->id = clipPoints2[i].id; - } - else - { - cp->localPoint = clipPoints2[i].v; - cp->id.cf.typeA = clipPoints2[i].id.cf.typeB; - cp->id.cf.typeB = clipPoints2[i].id.cf.typeA; - cp->id.cf.indexA = clipPoints2[i].id.cf.indexB; - cp->id.cf.indexB = clipPoints2[i].id.cf.indexA; - } - - ++pointCount; - } - } - - manifold->pointCount = pointCount; -} - -b2EPAxis b2EPCollider::ComputeEdgeSeparation() -{ - b2EPAxis axis; - axis.type = b2EPAxis::e_edgeA; - axis.index = m_front ? 0 : 1; - axis.separation = FLT_MAX; - - for (int32 i = 0; i < m_polygonB.count; ++i) - { - float32 s = b2Dot(m_normal, m_polygonB.vertices[i] - m_v1); - if (s < axis.separation) - { - axis.separation = s; - } - } - - return axis; -} - -b2EPAxis b2EPCollider::ComputePolygonSeparation() -{ - b2EPAxis axis; - axis.type = b2EPAxis::e_unknown; - axis.index = -1; - axis.separation = -FLT_MAX; - - b2Vec2 perp(-m_normal.y, m_normal.x); - - for (int32 i = 0; i < m_polygonB.count; ++i) - { - b2Vec2 n = -m_polygonB.normals[i]; - - float32 s1 = b2Dot(n, m_polygonB.vertices[i] - m_v1); - float32 s2 = b2Dot(n, m_polygonB.vertices[i] - m_v2); - float32 s = b2Min(s1, s2); - - if (s > m_radius) - { - // No collision - axis.type = b2EPAxis::e_edgeB; - axis.index = i; - axis.separation = s; - return axis; - } - - // Adjacency - if (b2Dot(n, perp) >= 0.0f) - { - if (b2Dot(n - m_upperLimit, m_normal) < -b2_angularSlop) - { - continue; - } - } - else - { - if (b2Dot(n - m_lowerLimit, m_normal) < -b2_angularSlop) - { - continue; - } - } - - if (s > axis.separation) - { - axis.type = b2EPAxis::e_edgeB; - axis.index = i; - axis.separation = s; - } - } - - return axis; -} - -void b2CollideEdgeAndPolygon( b2Manifold* manifold, - const b2EdgeShape* edgeA, const b2Transform& xfA, - const b2PolygonShape* polygonB, const b2Transform& xfB) -{ - b2EPCollider collider; - collider.Collide(manifold, edgeA, xfA, polygonB, xfB); -} diff --git a/sources/Box2D/Collision/b2CollidePolygon.cpp b/sources/Box2D/Collision/b2CollidePolygon.cpp deleted file mode 100755 index b24d01e7..00000000 --- a/sources/Box2D/Collision/b2CollidePolygon.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -// Find the max separation between poly1 and poly2 using edge normals from poly1. -static float32 b2FindMaxSeparation(int32* edgeIndex, - const b2PolygonShape* poly1, const b2Transform& xf1, - const b2PolygonShape* poly2, const b2Transform& xf2) -{ - int32 count1 = poly1->m_count; - int32 count2 = poly2->m_count; - const b2Vec2* n1s = poly1->m_normals; - const b2Vec2* v1s = poly1->m_vertices; - const b2Vec2* v2s = poly2->m_vertices; - b2Transform xf = b2MulT(xf2, xf1); - - int32 bestIndex = 0; - float32 maxSeparation = -b2_maxFloat; - for (int32 i = 0; i < count1; ++i) - { - // Get poly1 normal in frame2. - b2Vec2 n = b2Mul(xf.q, n1s[i]); - b2Vec2 v1 = b2Mul(xf, v1s[i]); - - // Find deepest point for normal i. - float32 si = b2_maxFloat; - for (int32 j = 0; j < count2; ++j) - { - float32 sij = b2Dot(n, v2s[j] - v1); - if (sij < si) - { - si = sij; - } - } - - if (si > maxSeparation) - { - maxSeparation = si; - bestIndex = i; - } - } - - *edgeIndex = bestIndex; - return maxSeparation; -} - -static void b2FindIncidentEdge(b2ClipVertex c[2], - const b2PolygonShape* poly1, const b2Transform& xf1, int32 edge1, - const b2PolygonShape* poly2, const b2Transform& xf2) -{ - const b2Vec2* normals1 = poly1->m_normals; - - int32 count2 = poly2->m_count; - const b2Vec2* vertices2 = poly2->m_vertices; - const b2Vec2* normals2 = poly2->m_normals; - - b2Assert(0 <= edge1 && edge1 < poly1->m_count); - - // Get the normal of the reference edge in poly2's frame. - b2Vec2 normal1 = b2MulT(xf2.q, b2Mul(xf1.q, normals1[edge1])); - - // Find the incident edge on poly2. - int32 index = 0; - float32 minDot = b2_maxFloat; - for (int32 i = 0; i < count2; ++i) - { - float32 dot = b2Dot(normal1, normals2[i]); - if (dot < minDot) - { - minDot = dot; - index = i; - } - } - - // Build the clip vertices for the incident edge. - int32 i1 = index; - int32 i2 = i1 + 1 < count2 ? i1 + 1 : 0; - - c[0].v = b2Mul(xf2, vertices2[i1]); - c[0].id.cf.indexA = (uint8)edge1; - c[0].id.cf.indexB = (uint8)i1; - c[0].id.cf.typeA = b2ContactFeature::e_face; - c[0].id.cf.typeB = b2ContactFeature::e_vertex; - - c[1].v = b2Mul(xf2, vertices2[i2]); - c[1].id.cf.indexA = (uint8)edge1; - c[1].id.cf.indexB = (uint8)i2; - c[1].id.cf.typeA = b2ContactFeature::e_face; - c[1].id.cf.typeB = b2ContactFeature::e_vertex; -} - -// Find edge normal of max separation on A - return if separating axis is found -// Find edge normal of max separation on B - return if separation axis is found -// Choose reference edge as min(minA, minB) -// Find incident edge -// Clip - -// The normal points from 1 to 2 -void b2CollidePolygons(b2Manifold* manifold, - const b2PolygonShape* polyA, const b2Transform& xfA, - const b2PolygonShape* polyB, const b2Transform& xfB) -{ - manifold->pointCount = 0; - float32 totalRadius = polyA->m_radius + polyB->m_radius; - - int32 edgeA = 0; - float32 separationA = b2FindMaxSeparation(&edgeA, polyA, xfA, polyB, xfB); - if (separationA > totalRadius) - return; - - int32 edgeB = 0; - float32 separationB = b2FindMaxSeparation(&edgeB, polyB, xfB, polyA, xfA); - if (separationB > totalRadius) - return; - - const b2PolygonShape* poly1; // reference polygon - const b2PolygonShape* poly2; // incident polygon - b2Transform xf1, xf2; - int32 edge1; // reference edge - uint8 flip; - const float32 k_tol = 0.1f * b2_linearSlop; - - if (separationB > separationA + k_tol) - { - poly1 = polyB; - poly2 = polyA; - xf1 = xfB; - xf2 = xfA; - edge1 = edgeB; - manifold->type = b2Manifold::e_faceB; - flip = 1; - } - else - { - poly1 = polyA; - poly2 = polyB; - xf1 = xfA; - xf2 = xfB; - edge1 = edgeA; - manifold->type = b2Manifold::e_faceA; - flip = 0; - } - - b2ClipVertex incidentEdge[2]; - b2FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2); - - int32 count1 = poly1->m_count; - const b2Vec2* vertices1 = poly1->m_vertices; - - int32 iv1 = edge1; - int32 iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0; - - b2Vec2 v11 = vertices1[iv1]; - b2Vec2 v12 = vertices1[iv2]; - - b2Vec2 localTangent = v12 - v11; - localTangent.Normalize(); - - b2Vec2 localNormal = b2Cross(localTangent, 1.0f); - b2Vec2 planePoint = 0.5f * (v11 + v12); - - b2Vec2 tangent = b2Mul(xf1.q, localTangent); - b2Vec2 normal = b2Cross(tangent, 1.0f); - - v11 = b2Mul(xf1, v11); - v12 = b2Mul(xf1, v12); - - // Face offset. - float32 frontOffset = b2Dot(normal, v11); - - // Side offsets, extended by polytope skin thickness. - float32 sideOffset1 = -b2Dot(tangent, v11) + totalRadius; - float32 sideOffset2 = b2Dot(tangent, v12) + totalRadius; - - // Clip incident edge against extruded edge1 side edges. - b2ClipVertex clipPoints1[2]; - b2ClipVertex clipPoints2[2]; - int np; - - // Clip to box side 1 - np = b2ClipSegmentToLine(clipPoints1, incidentEdge, -tangent, sideOffset1, iv1); - - if (np < 2) - return; - - // Clip to negative box side 1 - np = b2ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2, iv2); - - if (np < 2) - { - return; - } - - // Now clipPoints2 contains the clipped points. - manifold->localNormal = localNormal; - manifold->localPoint = planePoint; - - int32 pointCount = 0; - for (int32 i = 0; i < b2_maxManifoldPoints; ++i) - { - float32 separation = b2Dot(normal, clipPoints2[i].v) - frontOffset; - - if (separation <= totalRadius) - { - b2ManifoldPoint* cp = manifold->points + pointCount; - cp->localPoint = b2MulT(xf2, clipPoints2[i].v); - cp->id = clipPoints2[i].id; - if (flip) - { - // Swap features - b2ContactFeature cf = cp->id.cf; - cp->id.cf.indexA = cf.indexB; - cp->id.cf.indexB = cf.indexA; - cp->id.cf.typeA = cf.typeB; - cp->id.cf.typeB = cf.typeA; - } - ++pointCount; - } - } - - manifold->pointCount = pointCount; -} diff --git a/sources/Box2D/Collision/b2Collision.cpp b/sources/Box2D/Collision/b2Collision.cpp deleted file mode 100755 index bd3e78b8..00000000 --- a/sources/Box2D/Collision/b2Collision.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -void b2WorldManifold::Initialize(const b2Manifold* manifold, - const b2Transform& xfA, float32 radiusA, - const b2Transform& xfB, float32 radiusB) -{ - if (manifold->pointCount == 0) - { - return; - } - - switch (manifold->type) - { - case b2Manifold::e_circles: - { - normal.Set(1.0f, 0.0f); - b2Vec2 pointA = b2Mul(xfA, manifold->localPoint); - b2Vec2 pointB = b2Mul(xfB, manifold->points[0].localPoint); - if (b2DistanceSquared(pointA, pointB) > b2_epsilon * b2_epsilon) - { - normal = pointB - pointA; - normal.Normalize(); - } - - b2Vec2 cA = pointA + radiusA * normal; - b2Vec2 cB = pointB - radiusB * normal; - points[0] = 0.5f * (cA + cB); - separations[0] = b2Dot(cB - cA, normal); - } - break; - - case b2Manifold::e_faceA: - { - normal = b2Mul(xfA.q, manifold->localNormal); - b2Vec2 planePoint = b2Mul(xfA, manifold->localPoint); - - for (int32 i = 0; i < manifold->pointCount; ++i) - { - b2Vec2 clipPoint = b2Mul(xfB, manifold->points[i].localPoint); - b2Vec2 cA = clipPoint + (radiusA - b2Dot(clipPoint - planePoint, normal)) * normal; - b2Vec2 cB = clipPoint - radiusB * normal; - points[i] = 0.5f * (cA + cB); - separations[i] = b2Dot(cB - cA, normal); - } - } - break; - - case b2Manifold::e_faceB: - { - normal = b2Mul(xfB.q, manifold->localNormal); - b2Vec2 planePoint = b2Mul(xfB, manifold->localPoint); - - for (int32 i = 0; i < manifold->pointCount; ++i) - { - b2Vec2 clipPoint = b2Mul(xfA, manifold->points[i].localPoint); - b2Vec2 cB = clipPoint + (radiusB - b2Dot(clipPoint - planePoint, normal)) * normal; - b2Vec2 cA = clipPoint - radiusA * normal; - points[i] = 0.5f * (cA + cB); - separations[i] = b2Dot(cA - cB, normal); - } - - // Ensure normal points from A to B. - normal = -normal; - } - break; - } -} - -void b2GetPointStates(b2PointState state1[b2_maxManifoldPoints], b2PointState state2[b2_maxManifoldPoints], - const b2Manifold* manifold1, const b2Manifold* manifold2) -{ - for (int32 i = 0; i < b2_maxManifoldPoints; ++i) - { - state1[i] = b2_nullState; - state2[i] = b2_nullState; - } - - // Detect persists and removes. - for (int32 i = 0; i < manifold1->pointCount; ++i) - { - b2ContactID id = manifold1->points[i].id; - - state1[i] = b2_removeState; - - for (int32 j = 0; j < manifold2->pointCount; ++j) - { - if (manifold2->points[j].id.key == id.key) - { - state1[i] = b2_persistState; - break; - } - } - } - - // Detect persists and adds. - for (int32 i = 0; i < manifold2->pointCount; ++i) - { - b2ContactID id = manifold2->points[i].id; - - state2[i] = b2_addState; - - for (int32 j = 0; j < manifold1->pointCount; ++j) - { - if (manifold1->points[j].id.key == id.key) - { - state2[i] = b2_persistState; - break; - } - } - } -} - -// From Real-time Collision Detection, p179. -bool b2AABB::RayCast(b2RayCastOutput* output, const b2RayCastInput& input) const -{ - float32 tmin = -b2_maxFloat; - float32 tmax = b2_maxFloat; - - b2Vec2 p = input.p1; - b2Vec2 d = input.p2 - input.p1; - b2Vec2 absD = b2Abs(d); - - b2Vec2 normal; - - for (int32 i = 0; i < 2; ++i) - { - if (absD(i) < b2_epsilon) - { - // Parallel. - if (p(i) < lowerBound(i) || upperBound(i) < p(i)) - { - return false; - } - } - else - { - float32 inv_d = 1.0f / d(i); - float32 t1 = (lowerBound(i) - p(i)) * inv_d; - float32 t2 = (upperBound(i) - p(i)) * inv_d; - - // Sign of the normal vector. - float32 s = -1.0f; - - if (t1 > t2) - { - b2Swap(t1, t2); - s = 1.0f; - } - - // Push the min up - if (t1 > tmin) - { - normal.SetZero(); - normal(i) = s; - tmin = t1; - } - - // Pull the max down - tmax = b2Min(tmax, t2); - - if (tmin > tmax) - { - return false; - } - } - } - - // Does the ray start inside the box? - // Does the ray intersect beyond the max fraction? - if (tmin < 0.0f || input.maxFraction < tmin) - { - return false; - } - - // Intersection. - output->fraction = tmin; - output->normal = normal; - return true; -} - -// Sutherland-Hodgman clipping. -int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2], - const b2Vec2& normal, float32 offset, int32 vertexIndexA) -{ - // Start with no output points - int32 numOut = 0; - - // Calculate the distance of end points to the line - float32 distance0 = b2Dot(normal, vIn[0].v) - offset; - float32 distance1 = b2Dot(normal, vIn[1].v) - offset; - - // If the points are behind the plane - if (distance0 <= 0.0f) vOut[numOut++] = vIn[0]; - if (distance1 <= 0.0f) vOut[numOut++] = vIn[1]; - - // If the points are on different sides of the plane - if (distance0 * distance1 < 0.0f) - { - // Find intersection point of edge and plane - float32 interp = distance0 / (distance0 - distance1); - vOut[numOut].v = vIn[0].v + interp * (vIn[1].v - vIn[0].v); - - // VertexA is hitting edgeB. - vOut[numOut].id.cf.indexA = static_cast(vertexIndexA); - vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB; - vOut[numOut].id.cf.typeA = b2ContactFeature::e_vertex; - vOut[numOut].id.cf.typeB = b2ContactFeature::e_face; - ++numOut; - } - - return numOut; -} - -bool b2TestOverlap( const b2Shape* shapeA, int32 indexA, - const b2Shape* shapeB, int32 indexB, - const b2Transform& xfA, const b2Transform& xfB) -{ - b2DistanceInput input; - input.proxyA.Set(shapeA, indexA); - input.proxyB.Set(shapeB, indexB); - input.transformA = xfA; - input.transformB = xfB; - input.useRadii = true; - - b2SimplexCache cache; - cache.count = 0; - - b2DistanceOutput output; - - b2Distance(&output, &cache, &input); - - return output.distance < 10.0f * b2_epsilon; -} diff --git a/sources/Box2D/Collision/b2Collision.h b/sources/Box2D/Collision/b2Collision.h deleted file mode 100755 index 8b0ed66a..00000000 --- a/sources/Box2D/Collision/b2Collision.h +++ /dev/null @@ -1,277 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_COLLISION_H -#define B2_COLLISION_H - -#include -#include - -/// @file -/// Structures and functions used for computing contact points, distance -/// queries, and TOI queries. - -class b2Shape; -class b2CircleShape; -class b2EdgeShape; -class b2PolygonShape; - -const uint8 b2_nullFeature = UCHAR_MAX; - -/// The features that intersect to form the contact point -/// This must be 4 bytes or less. -struct b2ContactFeature -{ - enum Type - { - e_vertex = 0, - e_face = 1 - }; - - uint8 indexA; ///< Feature index on shapeA - uint8 indexB; ///< Feature index on shapeB - uint8 typeA; ///< The feature type on shapeA - uint8 typeB; ///< The feature type on shapeB -}; - -/// Contact ids to facilitate warm starting. -union b2ContactID -{ - b2ContactFeature cf; - uint32 key; ///< Used to quickly compare contact ids. -}; - -/// A manifold point is a contact point belonging to a contact -/// manifold. It holds details related to the geometry and dynamics -/// of the contact points. -/// The local point usage depends on the manifold type: -/// -e_circles: the local center of circleB -/// -e_faceA: the local center of cirlceB or the clip point of polygonB -/// -e_faceB: the clip point of polygonA -/// This structure is stored across time steps, so we keep it small. -/// Note: the impulses are used for internal caching and may not -/// provide reliable contact forces, especially for high speed collisions. -struct b2ManifoldPoint -{ - b2Vec2 localPoint; ///< usage depends on manifold type - float32 normalImpulse; ///< the non-penetration impulse - float32 tangentImpulse; ///< the friction impulse - b2ContactID id; ///< uniquely identifies a contact point between two shapes -}; - -/// A manifold for two touching convex shapes. -/// Box2D supports multiple types of contact: -/// - clip point versus plane with radius -/// - point versus point with radius (circles) -/// The local point usage depends on the manifold type: -/// -e_circles: the local center of circleA -/// -e_faceA: the center of faceA -/// -e_faceB: the center of faceB -/// Similarly the local normal usage: -/// -e_circles: not used -/// -e_faceA: the normal on polygonA -/// -e_faceB: the normal on polygonB -/// We store contacts in this way so that position correction can -/// account for movement, which is critical for continuous physics. -/// All contact scenarios must be expressed in one of these types. -/// This structure is stored across time steps, so we keep it small. -struct b2Manifold -{ - enum Type - { - e_circles, - e_faceA, - e_faceB - }; - - b2ManifoldPoint points[b2_maxManifoldPoints]; ///< the points of contact - b2Vec2 localNormal; ///< not use for Type::e_points - b2Vec2 localPoint; ///< usage depends on manifold type - Type type; - int32 pointCount; ///< the number of manifold points -}; - -/// This is used to compute the current state of a contact manifold. -struct b2WorldManifold -{ - /// Evaluate the manifold with supplied transforms. This assumes - /// modest motion from the original state. This does not change the - /// point count, impulses, etc. The radii must come from the shapes - /// that generated the manifold. - void Initialize(const b2Manifold* manifold, - const b2Transform& xfA, float32 radiusA, - const b2Transform& xfB, float32 radiusB); - - b2Vec2 normal; ///< world vector pointing from A to B - b2Vec2 points[b2_maxManifoldPoints]; ///< world contact point (point of intersection) - float32 separations[b2_maxManifoldPoints]; ///< a negative value indicates overlap, in meters -}; - -/// This is used for determining the state of contact points. -enum b2PointState -{ - b2_nullState, ///< point does not exist - b2_addState, ///< point was added in the update - b2_persistState, ///< point persisted across the update - b2_removeState ///< point was removed in the update -}; - -/// Compute the point states given two manifolds. The states pertain to the transition from manifold1 -/// to manifold2. So state1 is either persist or remove while state2 is either add or persist. -void b2GetPointStates(b2PointState state1[b2_maxManifoldPoints], b2PointState state2[b2_maxManifoldPoints], - const b2Manifold* manifold1, const b2Manifold* manifold2); - -/// Used for computing contact manifolds. -struct b2ClipVertex -{ - b2Vec2 v; - b2ContactID id; -}; - -/// Ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). -struct b2RayCastInput -{ - b2Vec2 p1, p2; - float32 maxFraction; -}; - -/// Ray-cast output data. The ray hits at p1 + fraction * (p2 - p1), where p1 and p2 -/// come from b2RayCastInput. -struct b2RayCastOutput -{ - b2Vec2 normal; - float32 fraction; -}; - -/// An axis aligned bounding box. -struct b2AABB -{ - /// Verify that the bounds are sorted. - bool IsValid() const; - - /// Get the center of the AABB. - b2Vec2 GetCenter() const - { - return 0.5f * (lowerBound + upperBound); - } - - /// Get the extents of the AABB (half-widths). - b2Vec2 GetExtents() const - { - return 0.5f * (upperBound - lowerBound); - } - - /// Get the perimeter length - float32 GetPerimeter() const - { - float32 wx = upperBound.x - lowerBound.x; - float32 wy = upperBound.y - lowerBound.y; - return 2.0f * (wx + wy); - } - - /// Combine an AABB into this one. - void Combine(const b2AABB& aabb) - { - lowerBound = b2Min(lowerBound, aabb.lowerBound); - upperBound = b2Max(upperBound, aabb.upperBound); - } - - /// Combine two AABBs into this one. - void Combine(const b2AABB& aabb1, const b2AABB& aabb2) - { - lowerBound = b2Min(aabb1.lowerBound, aabb2.lowerBound); - upperBound = b2Max(aabb1.upperBound, aabb2.upperBound); - } - - /// Does this aabb contain the provided AABB. - bool Contains(const b2AABB& aabb) const - { - bool result = true; - result = result && lowerBound.x <= aabb.lowerBound.x; - result = result && lowerBound.y <= aabb.lowerBound.y; - result = result && aabb.upperBound.x <= upperBound.x; - result = result && aabb.upperBound.y <= upperBound.y; - return result; - } - - bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input) const; - - b2Vec2 lowerBound; ///< the lower vertex - b2Vec2 upperBound; ///< the upper vertex -}; - -/// Compute the collision manifold between two circles. -void b2CollideCircles(b2Manifold* manifold, - const b2CircleShape* circleA, const b2Transform& xfA, - const b2CircleShape* circleB, const b2Transform& xfB); - -/// Compute the collision manifold between a polygon and a circle. -void b2CollidePolygonAndCircle(b2Manifold* manifold, - const b2PolygonShape* polygonA, const b2Transform& xfA, - const b2CircleShape* circleB, const b2Transform& xfB); - -/// Compute the collision manifold between two polygons. -void b2CollidePolygons(b2Manifold* manifold, - const b2PolygonShape* polygonA, const b2Transform& xfA, - const b2PolygonShape* polygonB, const b2Transform& xfB); - -/// Compute the collision manifold between an edge and a circle. -void b2CollideEdgeAndCircle(b2Manifold* manifold, - const b2EdgeShape* polygonA, const b2Transform& xfA, - const b2CircleShape* circleB, const b2Transform& xfB); - -/// Compute the collision manifold between an edge and a circle. -void b2CollideEdgeAndPolygon(b2Manifold* manifold, - const b2EdgeShape* edgeA, const b2Transform& xfA, - const b2PolygonShape* circleB, const b2Transform& xfB); - -/// Clipping for contact manifolds. -int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2], - const b2Vec2& normal, float32 offset, int32 vertexIndexA); - -/// Determine if two generic shapes overlap. -bool b2TestOverlap( const b2Shape* shapeA, int32 indexA, - const b2Shape* shapeB, int32 indexB, - const b2Transform& xfA, const b2Transform& xfB); - -// ---------------- Inline Functions ------------------------------------------ - -inline bool b2AABB::IsValid() const -{ - b2Vec2 d = upperBound - lowerBound; - bool valid = d.x >= 0.0f && d.y >= 0.0f; - valid = valid && lowerBound.IsValid() && upperBound.IsValid(); - return valid; -} - -inline bool b2TestOverlap(const b2AABB& a, const b2AABB& b) -{ - b2Vec2 d1, d2; - d1 = b.lowerBound - a.upperBound; - d2 = a.lowerBound - b.upperBound; - - if (d1.x > 0.0f || d1.y > 0.0f) - return false; - - if (d2.x > 0.0f || d2.y > 0.0f) - return false; - - return true; -} - -#endif diff --git a/sources/Box2D/Collision/b2Distance.cpp b/sources/Box2D/Collision/b2Distance.cpp deleted file mode 100755 index faa4c87a..00000000 --- a/sources/Box2D/Collision/b2Distance.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include - -// GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates. -int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters; - -void b2DistanceProxy::Set(const b2Shape* shape, int32 index) -{ - switch (shape->GetType()) - { - case b2Shape::e_circle: - { - const b2CircleShape* circle = static_cast(shape); - m_vertices = &circle->m_p; - m_count = 1; - m_radius = circle->m_radius; - } - break; - - case b2Shape::e_polygon: - { - const b2PolygonShape* polygon = static_cast(shape); - m_vertices = polygon->m_vertices; - m_count = polygon->m_count; - m_radius = polygon->m_radius; - } - break; - - case b2Shape::e_chain: - { - const b2ChainShape* chain = static_cast(shape); - b2Assert(0 <= index && index < chain->m_count); - - m_buffer[0] = chain->m_vertices[index]; - if (index + 1 < chain->m_count) - { - m_buffer[1] = chain->m_vertices[index + 1]; - } - else - { - m_buffer[1] = chain->m_vertices[0]; - } - - m_vertices = m_buffer; - m_count = 2; - m_radius = chain->m_radius; - } - break; - - case b2Shape::e_edge: - { - const b2EdgeShape* edge = static_cast(shape); - m_vertices = &edge->m_vertex1; - m_count = 2; - m_radius = edge->m_radius; - } - break; - - default: - b2Assert(false); - } -} - - -struct b2SimplexVertex -{ - b2Vec2 wA; // support point in proxyA - b2Vec2 wB; // support point in proxyB - b2Vec2 w; // wB - wA - float32 a; // barycentric coordinate for closest point - int32 indexA; // wA index - int32 indexB; // wB index -}; - -struct b2Simplex -{ - void ReadCache( const b2SimplexCache* cache, - const b2DistanceProxy* proxyA, const b2Transform& transformA, - const b2DistanceProxy* proxyB, const b2Transform& transformB) - { - b2Assert(cache->count <= 3); - - // Copy data from cache. - m_count = cache->count; - b2SimplexVertex* vertices = &m_v1; - for (int32 i = 0; i < m_count; ++i) - { - b2SimplexVertex* v = vertices + i; - v->indexA = cache->indexA[i]; - v->indexB = cache->indexB[i]; - b2Vec2 wALocal = proxyA->GetVertex(v->indexA); - b2Vec2 wBLocal = proxyB->GetVertex(v->indexB); - v->wA = b2Mul(transformA, wALocal); - v->wB = b2Mul(transformB, wBLocal); - v->w = v->wB - v->wA; - v->a = 0.0f; - } - - // Compute the new simplex metric, if it is substantially different than - // old metric then flush the simplex. - if (m_count > 1) - { - float32 metric1 = cache->metric; - float32 metric2 = GetMetric(); - if (metric2 < 0.5f * metric1 || 2.0f * metric1 < metric2 || metric2 < b2_epsilon) - { - // Reset the simplex. - m_count = 0; - } - } - - // If the cache is empty or invalid ... - if (m_count == 0) - { - b2SimplexVertex* v = vertices + 0; - v->indexA = 0; - v->indexB = 0; - b2Vec2 wALocal = proxyA->GetVertex(0); - b2Vec2 wBLocal = proxyB->GetVertex(0); - v->wA = b2Mul(transformA, wALocal); - v->wB = b2Mul(transformB, wBLocal); - v->w = v->wB - v->wA; - v->a = 1.0f; - m_count = 1; - } - } - - void WriteCache(b2SimplexCache* cache) const - { - cache->metric = GetMetric(); - cache->count = uint16(m_count); - const b2SimplexVertex* vertices = &m_v1; - for (int32 i = 0; i < m_count; ++i) - { - cache->indexA[i] = uint8(vertices[i].indexA); - cache->indexB[i] = uint8(vertices[i].indexB); - } - } - - b2Vec2 GetSearchDirection() const - { - switch (m_count) - { - case 1: - return -m_v1.w; - - case 2: - { - b2Vec2 e12 = m_v2.w - m_v1.w; - float32 sgn = b2Cross(e12, -m_v1.w); - if (sgn > 0.0f) - { - // Origin is left of e12. - return b2Cross(1.0f, e12); - } - else - { - // Origin is right of e12. - return b2Cross(e12, 1.0f); - } - } - - default: - b2Assert(false); - return b2Vec2_zero; - } - } - - b2Vec2 GetClosestPoint() const - { - switch (m_count) - { - case 0: - b2Assert(false); - return b2Vec2_zero; - - case 1: - return m_v1.w; - - case 2: - return m_v1.a * m_v1.w + m_v2.a * m_v2.w; - - case 3: - return b2Vec2_zero; - - default: - b2Assert(false); - return b2Vec2_zero; - } - } - - void GetWitnessPoints(b2Vec2* pA, b2Vec2* pB) const - { - switch (m_count) - { - case 0: - b2Assert(false); - break; - - case 1: - *pA = m_v1.wA; - *pB = m_v1.wB; - break; - - case 2: - *pA = m_v1.a * m_v1.wA + m_v2.a * m_v2.wA; - *pB = m_v1.a * m_v1.wB + m_v2.a * m_v2.wB; - break; - - case 3: - *pA = m_v1.a * m_v1.wA + m_v2.a * m_v2.wA + m_v3.a * m_v3.wA; - *pB = *pA; - break; - - default: - b2Assert(false); - break; - } - } - - float32 GetMetric() const - { - switch (m_count) - { - case 0: - b2Assert(false); - return 0.0f; - - case 1: - return 0.0f; - - case 2: - return b2Distance(m_v1.w, m_v2.w); - - case 3: - return b2Cross(m_v2.w - m_v1.w, m_v3.w - m_v1.w); - - default: - b2Assert(false); - return 0.0f; - } - } - - void Solve2(); - void Solve3(); - - b2SimplexVertex m_v1, m_v2, m_v3; - int32 m_count; -}; - - -// Solve a line segment using barycentric coordinates. -// -// p = a1 * w1 + a2 * w2 -// a1 + a2 = 1 -// -// The vector from the origin to the closest point on the line is -// perpendicular to the line. -// e12 = w2 - w1 -// dot(p, e) = 0 -// a1 * dot(w1, e) + a2 * dot(w2, e) = 0 -// -// 2-by-2 linear system -// [1 1 ][a1] = [1] -// [w1.e12 w2.e12][a2] = [0] -// -// Define -// d12_1 = dot(w2, e12) -// d12_2 = -dot(w1, e12) -// d12 = d12_1 + d12_2 -// -// Solution -// a1 = d12_1 / d12 -// a2 = d12_2 / d12 -void b2Simplex::Solve2() -{ - b2Vec2 w1 = m_v1.w; - b2Vec2 w2 = m_v2.w; - b2Vec2 e12 = w2 - w1; - - // w1 region - float32 d12_2 = -b2Dot(w1, e12); - if (d12_2 <= 0.0f) - { - // a2 <= 0, so we clamp it to 0 - m_v1.a = 1.0f; - m_count = 1; - return; - } - - // w2 region - float32 d12_1 = b2Dot(w2, e12); - if (d12_1 <= 0.0f) - { - // a1 <= 0, so we clamp it to 0 - m_v2.a = 1.0f; - m_count = 1; - m_v1 = m_v2; - return; - } - - // Must be in e12 region. - float32 inv_d12 = 1.0f / (d12_1 + d12_2); - m_v1.a = d12_1 * inv_d12; - m_v2.a = d12_2 * inv_d12; - m_count = 2; -} - -// Possible regions: -// - points[2] -// - edge points[0]-points[2] -// - edge points[1]-points[2] -// - inside the triangle -void b2Simplex::Solve3() -{ - b2Vec2 w1 = m_v1.w; - b2Vec2 w2 = m_v2.w; - b2Vec2 w3 = m_v3.w; - - // Edge12 - // [1 1 ][a1] = [1] - // [w1.e12 w2.e12][a2] = [0] - // a3 = 0 - b2Vec2 e12 = w2 - w1; - float32 w1e12 = b2Dot(w1, e12); - float32 w2e12 = b2Dot(w2, e12); - float32 d12_1 = w2e12; - float32 d12_2 = -w1e12; - - // Edge13 - // [1 1 ][a1] = [1] - // [w1.e13 w3.e13][a3] = [0] - // a2 = 0 - b2Vec2 e13 = w3 - w1; - float32 w1e13 = b2Dot(w1, e13); - float32 w3e13 = b2Dot(w3, e13); - float32 d13_1 = w3e13; - float32 d13_2 = -w1e13; - - // Edge23 - // [1 1 ][a2] = [1] - // [w2.e23 w3.e23][a3] = [0] - // a1 = 0 - b2Vec2 e23 = w3 - w2; - float32 w2e23 = b2Dot(w2, e23); - float32 w3e23 = b2Dot(w3, e23); - float32 d23_1 = w3e23; - float32 d23_2 = -w2e23; - - // Triangle123 - float32 n123 = b2Cross(e12, e13); - - float32 d123_1 = n123 * b2Cross(w2, w3); - float32 d123_2 = n123 * b2Cross(w3, w1); - float32 d123_3 = n123 * b2Cross(w1, w2); - - // w1 region - if (d12_2 <= 0.0f && d13_2 <= 0.0f) - { - m_v1.a = 1.0f; - m_count = 1; - return; - } - - // e12 - if (d12_1 > 0.0f && d12_2 > 0.0f && d123_3 <= 0.0f) - { - float32 inv_d12 = 1.0f / (d12_1 + d12_2); - m_v1.a = d12_1 * inv_d12; - m_v2.a = d12_2 * inv_d12; - m_count = 2; - return; - } - - // e13 - if (d13_1 > 0.0f && d13_2 > 0.0f && d123_2 <= 0.0f) - { - float32 inv_d13 = 1.0f / (d13_1 + d13_2); - m_v1.a = d13_1 * inv_d13; - m_v3.a = d13_2 * inv_d13; - m_count = 2; - m_v2 = m_v3; - return; - } - - // w2 region - if (d12_1 <= 0.0f && d23_2 <= 0.0f) - { - m_v2.a = 1.0f; - m_count = 1; - m_v1 = m_v2; - return; - } - - // w3 region - if (d13_1 <= 0.0f && d23_1 <= 0.0f) - { - m_v3.a = 1.0f; - m_count = 1; - m_v1 = m_v3; - return; - } - - // e23 - if (d23_1 > 0.0f && d23_2 > 0.0f && d123_1 <= 0.0f) - { - float32 inv_d23 = 1.0f / (d23_1 + d23_2); - m_v2.a = d23_1 * inv_d23; - m_v3.a = d23_2 * inv_d23; - m_count = 2; - m_v1 = m_v3; - return; - } - - // Must be in triangle123 - float32 inv_d123 = 1.0f / (d123_1 + d123_2 + d123_3); - m_v1.a = d123_1 * inv_d123; - m_v2.a = d123_2 * inv_d123; - m_v3.a = d123_3 * inv_d123; - m_count = 3; -} - -void b2Distance(b2DistanceOutput* output, - b2SimplexCache* cache, - const b2DistanceInput* input) -{ - ++b2_gjkCalls; - - const b2DistanceProxy* proxyA = &input->proxyA; - const b2DistanceProxy* proxyB = &input->proxyB; - - b2Transform transformA = input->transformA; - b2Transform transformB = input->transformB; - - // Initialize the simplex. - b2Simplex simplex; - simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB); - - // Get simplex vertices as an array. - b2SimplexVertex* vertices = &simplex.m_v1; - const int32 k_maxIters = 20; - - // These store the vertices of the last simplex so that we - // can check for duplicates and prevent cycling. - int32 saveA[3], saveB[3]; - int32 saveCount = 0; - - float32 distanceSqr1 = b2_maxFloat; - float32 distanceSqr2 = distanceSqr1; - - // Main iteration loop. - int32 iter = 0; - while (iter < k_maxIters) - { - // Copy simplex so we can identify duplicates. - saveCount = simplex.m_count; - for (int32 i = 0; i < saveCount; ++i) - { - saveA[i] = vertices[i].indexA; - saveB[i] = vertices[i].indexB; - } - - switch (simplex.m_count) - { - case 1: - break; - - case 2: - simplex.Solve2(); - break; - - case 3: - simplex.Solve3(); - break; - - default: - b2Assert(false); - } - - // If we have 3 points, then the origin is in the corresponding triangle. - if (simplex.m_count == 3) - { - break; - } - - // Compute closest point. - b2Vec2 p = simplex.GetClosestPoint(); - distanceSqr2 = p.LengthSquared(); - - // Ensure progress - if (distanceSqr2 >= distanceSqr1) - { - //break; - } - distanceSqr1 = distanceSqr2; - - // Get search direction. - b2Vec2 d = simplex.GetSearchDirection(); - - // Ensure the search direction is numerically fit. - if (d.LengthSquared() < b2_epsilon * b2_epsilon) - { - // The origin is probably contained by a line segment - // or triangle. Thus the shapes are overlapped. - - // We can't return zero here even though there may be overlap. - // In case the simplex is a point, segment, or triangle it is difficult - // to determine if the origin is contained in the CSO or very close to it. - break; - } - - // Compute a tentative new simplex vertex using support points. - b2SimplexVertex* vertex = vertices + simplex.m_count; - vertex->indexA = proxyA->GetSupport(b2MulT(transformA.q, -d)); - vertex->wA = b2Mul(transformA, proxyA->GetVertex(vertex->indexA)); - b2Vec2 wBLocal; - vertex->indexB = proxyB->GetSupport(b2MulT(transformB.q, d)); - vertex->wB = b2Mul(transformB, proxyB->GetVertex(vertex->indexB)); - vertex->w = vertex->wB - vertex->wA; - - // Iteration count is equated to the number of support point calls. - ++iter; - ++b2_gjkIters; - - // Check for duplicate support points. This is the main termination criteria. - bool duplicate = false; - for (int32 i = 0; i < saveCount; ++i) - { - if (vertex->indexA == saveA[i] && vertex->indexB == saveB[i]) - { - duplicate = true; - break; - } - } - - // If we found a duplicate support point we must exit to avoid cycling. - if (duplicate) - { - break; - } - - // New vertex is ok and needed. - ++simplex.m_count; - } - - b2_gjkMaxIters = b2Max(b2_gjkMaxIters, iter); - - // Prepare output. - simplex.GetWitnessPoints(&output->pointA, &output->pointB); - output->distance = b2Distance(output->pointA, output->pointB); - output->iterations = iter; - - // Cache the simplex. - simplex.WriteCache(cache); - - // Apply radii if requested. - if (input->useRadii) - { - float32 rA = proxyA->m_radius; - float32 rB = proxyB->m_radius; - - if (output->distance > rA + rB && output->distance > b2_epsilon) - { - // Shapes are still no overlapped. - // Move the witness points to the outer surface. - output->distance -= rA + rB; - b2Vec2 normal = output->pointB - output->pointA; - normal.Normalize(); - output->pointA += rA * normal; - output->pointB -= rB * normal; - } - else - { - // Shapes are overlapped when radii are considered. - // Move the witness points to the middle. - b2Vec2 p = 0.5f * (output->pointA + output->pointB); - output->pointA = p; - output->pointB = p; - output->distance = 0.0f; - } - } -} diff --git a/sources/Box2D/Collision/b2Distance.h b/sources/Box2D/Collision/b2Distance.h deleted file mode 100755 index 54ed1e13..00000000 --- a/sources/Box2D/Collision/b2Distance.h +++ /dev/null @@ -1,141 +0,0 @@ - -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_DISTANCE_H -#define B2_DISTANCE_H - -#include - -class b2Shape; - -/// A distance proxy is used by the GJK algorithm. -/// It encapsulates any shape. -struct b2DistanceProxy -{ - b2DistanceProxy() : m_vertices(NULL), m_count(0), m_radius(0.0f) {} - - /// Initialize the proxy using the given shape. The shape - /// must remain in scope while the proxy is in use. - void Set(const b2Shape* shape, int32 index); - - /// Get the supporting vertex index in the given direction. - int32 GetSupport(const b2Vec2& d) const; - - /// Get the supporting vertex in the given direction. - const b2Vec2& GetSupportVertex(const b2Vec2& d) const; - - /// Get the vertex count. - int32 GetVertexCount() const; - - /// Get a vertex by index. Used by b2Distance. - const b2Vec2& GetVertex(int32 index) const; - - b2Vec2 m_buffer[2]; - const b2Vec2* m_vertices; - int32 m_count; - float32 m_radius; -}; - -/// Used to warm start b2Distance. -/// Set count to zero on first call. -struct b2SimplexCache -{ - float32 metric; ///< length or area - uint16 count; - uint8 indexA[3]; ///< vertices on shape A - uint8 indexB[3]; ///< vertices on shape B -}; - -/// Input for b2Distance. -/// You have to option to use the shape radii -/// in the computation. Even -struct b2DistanceInput -{ - b2DistanceProxy proxyA; - b2DistanceProxy proxyB; - b2Transform transformA; - b2Transform transformB; - bool useRadii; -}; - -/// Output for b2Distance. -struct b2DistanceOutput -{ - b2Vec2 pointA; ///< closest point on shapeA - b2Vec2 pointB; ///< closest point on shapeB - float32 distance; - int32 iterations; ///< number of GJK iterations used -}; - -/// Compute the closest points between two shapes. Supports any combination of: -/// b2CircleShape, b2PolygonShape, b2EdgeShape. The simplex cache is input/output. -/// On the first call set b2SimplexCache.count to zero. -void b2Distance(b2DistanceOutput* output, - b2SimplexCache* cache, - const b2DistanceInput* input); - - -////////////////////////////////////////////////////////////////////////// - -inline int32 b2DistanceProxy::GetVertexCount() const -{ - return m_count; -} - -inline const b2Vec2& b2DistanceProxy::GetVertex(int32 index) const -{ - b2Assert(0 <= index && index < m_count); - return m_vertices[index]; -} - -inline int32 b2DistanceProxy::GetSupport(const b2Vec2& d) const -{ - int32 bestIndex = 0; - float32 bestValue = b2Dot(m_vertices[0], d); - for (int32 i = 1; i < m_count; ++i) - { - float32 value = b2Dot(m_vertices[i], d); - if (value > bestValue) - { - bestIndex = i; - bestValue = value; - } - } - - return bestIndex; -} - -inline const b2Vec2& b2DistanceProxy::GetSupportVertex(const b2Vec2& d) const -{ - int32 bestIndex = 0; - float32 bestValue = b2Dot(m_vertices[0], d); - for (int32 i = 1; i < m_count; ++i) - { - float32 value = b2Dot(m_vertices[i], d); - if (value > bestValue) - { - bestIndex = i; - bestValue = value; - } - } - - return m_vertices[bestIndex]; -} - -#endif diff --git a/sources/Box2D/Collision/b2DynamicTree.cpp b/sources/Box2D/Collision/b2DynamicTree.cpp deleted file mode 100755 index cc41b285..00000000 --- a/sources/Box2D/Collision/b2DynamicTree.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* -* Copyright (c) 2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -b2DynamicTree::b2DynamicTree() -{ - m_root = b2_nullNode; - - m_nodeCapacity = 16; - m_nodeCount = 0; - m_nodes = (b2TreeNode*)b2Alloc(m_nodeCapacity * sizeof(b2TreeNode)); - memset(m_nodes, 0, m_nodeCapacity * sizeof(b2TreeNode)); - - // Build a linked list for the free list. - for (int32 i = 0; i < m_nodeCapacity - 1; ++i) - { - m_nodes[i].next = i + 1; - m_nodes[i].height = -1; - } - m_nodes[m_nodeCapacity-1].next = b2_nullNode; - m_nodes[m_nodeCapacity-1].height = -1; - m_freeList = 0; - - m_path = 0; - - m_insertionCount = 0; -} - -b2DynamicTree::~b2DynamicTree() -{ - // This frees the entire tree in one shot. - b2Free(m_nodes); -} - -// Allocate a node from the pool. Grow the pool if necessary. -int32 b2DynamicTree::AllocateNode() -{ - // Expand the node pool as needed. - if (m_freeList == b2_nullNode) - { - b2Assert(m_nodeCount == m_nodeCapacity); - - // The free list is empty. Rebuild a bigger pool. - b2TreeNode* oldNodes = m_nodes; - m_nodeCapacity *= 2; - m_nodes = (b2TreeNode*)b2Alloc(m_nodeCapacity * sizeof(b2TreeNode)); - memcpy(m_nodes, oldNodes, m_nodeCount * sizeof(b2TreeNode)); - b2Free(oldNodes); - - // Build a linked list for the free list. The parent - // pointer becomes the "next" pointer. - for (int32 i = m_nodeCount; i < m_nodeCapacity - 1; ++i) - { - m_nodes[i].next = i + 1; - m_nodes[i].height = -1; - } - m_nodes[m_nodeCapacity-1].next = b2_nullNode; - m_nodes[m_nodeCapacity-1].height = -1; - m_freeList = m_nodeCount; - } - - // Peel a node off the free list. - int32 nodeId = m_freeList; - m_freeList = m_nodes[nodeId].next; - m_nodes[nodeId].parent = b2_nullNode; - m_nodes[nodeId].child1 = b2_nullNode; - m_nodes[nodeId].child2 = b2_nullNode; - m_nodes[nodeId].height = 0; - m_nodes[nodeId].userData = NULL; - ++m_nodeCount; - return nodeId; -} - -// Return a node to the pool. -void b2DynamicTree::FreeNode(int32 nodeId) -{ - b2Assert(0 <= nodeId && nodeId < m_nodeCapacity); - b2Assert(0 < m_nodeCount); - m_nodes[nodeId].next = m_freeList; - m_nodes[nodeId].height = -1; - m_freeList = nodeId; - --m_nodeCount; -} - -// Create a proxy in the tree as a leaf node. We return the index -// of the node instead of a pointer so that we can grow -// the node pool. -int32 b2DynamicTree::CreateProxy(const b2AABB& aabb, void* userData) -{ - int32 proxyId = AllocateNode(); - - // Fatten the aabb. - b2Vec2 r(b2_aabbExtension, b2_aabbExtension); - m_nodes[proxyId].aabb.lowerBound = aabb.lowerBound - r; - m_nodes[proxyId].aabb.upperBound = aabb.upperBound + r; - m_nodes[proxyId].userData = userData; - m_nodes[proxyId].height = 0; - - InsertLeaf(proxyId); - - return proxyId; -} - -void b2DynamicTree::DestroyProxy(int32 proxyId) -{ - b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); - b2Assert(m_nodes[proxyId].IsLeaf()); - - RemoveLeaf(proxyId); - FreeNode(proxyId); -} - -bool b2DynamicTree::MoveProxy(int32 proxyId, const b2AABB& aabb, const b2Vec2& displacement) -{ - b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); - - b2Assert(m_nodes[proxyId].IsLeaf()); - - if (m_nodes[proxyId].aabb.Contains(aabb)) - { - return false; - } - - RemoveLeaf(proxyId); - - // Extend AABB. - b2AABB b = aabb; - b2Vec2 r(b2_aabbExtension, b2_aabbExtension); - b.lowerBound = b.lowerBound - r; - b.upperBound = b.upperBound + r; - - // Predict AABB displacement. - b2Vec2 d = b2_aabbMultiplier * displacement; - - if (d.x < 0.0f) - { - b.lowerBound.x += d.x; - } - else - { - b.upperBound.x += d.x; - } - - if (d.y < 0.0f) - { - b.lowerBound.y += d.y; - } - else - { - b.upperBound.y += d.y; - } - - m_nodes[proxyId].aabb = b; - - InsertLeaf(proxyId); - return true; -} - -void b2DynamicTree::InsertLeaf(int32 leaf) -{ - ++m_insertionCount; - - if (m_root == b2_nullNode) - { - m_root = leaf; - m_nodes[m_root].parent = b2_nullNode; - return; - } - - // Find the best sibling for this node - b2AABB leafAABB = m_nodes[leaf].aabb; - int32 index = m_root; - while (m_nodes[index].IsLeaf() == false) - { - int32 child1 = m_nodes[index].child1; - int32 child2 = m_nodes[index].child2; - - float32 area = m_nodes[index].aabb.GetPerimeter(); - - b2AABB combinedAABB; - combinedAABB.Combine(m_nodes[index].aabb, leafAABB); - float32 combinedArea = combinedAABB.GetPerimeter(); - - // Cost of creating a new parent for this node and the new leaf - float32 cost = 2.0f * combinedArea; - - // Minimum cost of pushing the leaf further down the tree - float32 inheritanceCost = 2.0f * (combinedArea - area); - - // Cost of descending into child1 - float32 cost1; - if (m_nodes[child1].IsLeaf()) - { - b2AABB aabb; - aabb.Combine(leafAABB, m_nodes[child1].aabb); - cost1 = aabb.GetPerimeter() + inheritanceCost; - } - else - { - b2AABB aabb; - aabb.Combine(leafAABB, m_nodes[child1].aabb); - float32 oldArea = m_nodes[child1].aabb.GetPerimeter(); - float32 newArea = aabb.GetPerimeter(); - cost1 = (newArea - oldArea) + inheritanceCost; - } - - // Cost of descending into child2 - float32 cost2; - if (m_nodes[child2].IsLeaf()) - { - b2AABB aabb; - aabb.Combine(leafAABB, m_nodes[child2].aabb); - cost2 = aabb.GetPerimeter() + inheritanceCost; - } - else - { - b2AABB aabb; - aabb.Combine(leafAABB, m_nodes[child2].aabb); - float32 oldArea = m_nodes[child2].aabb.GetPerimeter(); - float32 newArea = aabb.GetPerimeter(); - cost2 = newArea - oldArea + inheritanceCost; - } - - // Descend according to the minimum cost. - if (cost < cost1 && cost < cost2) - { - break; - } - - // Descend - if (cost1 < cost2) - { - index = child1; - } - else - { - index = child2; - } - } - - int32 sibling = index; - - // Create a new parent. - int32 oldParent = m_nodes[sibling].parent; - int32 newParent = AllocateNode(); - m_nodes[newParent].parent = oldParent; - m_nodes[newParent].userData = NULL; - m_nodes[newParent].aabb.Combine(leafAABB, m_nodes[sibling].aabb); - m_nodes[newParent].height = m_nodes[sibling].height + 1; - - if (oldParent != b2_nullNode) - { - // The sibling was not the root. - if (m_nodes[oldParent].child1 == sibling) - { - m_nodes[oldParent].child1 = newParent; - } - else - { - m_nodes[oldParent].child2 = newParent; - } - - m_nodes[newParent].child1 = sibling; - m_nodes[newParent].child2 = leaf; - m_nodes[sibling].parent = newParent; - m_nodes[leaf].parent = newParent; - } - else - { - // The sibling was the root. - m_nodes[newParent].child1 = sibling; - m_nodes[newParent].child2 = leaf; - m_nodes[sibling].parent = newParent; - m_nodes[leaf].parent = newParent; - m_root = newParent; - } - - // Walk back up the tree fixing heights and AABBs - index = m_nodes[leaf].parent; - while (index != b2_nullNode) - { - index = Balance(index); - - int32 child1 = m_nodes[index].child1; - int32 child2 = m_nodes[index].child2; - - b2Assert(child1 != b2_nullNode); - b2Assert(child2 != b2_nullNode); - - m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height); - m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb); - - index = m_nodes[index].parent; - } - - //Validate(); -} - -void b2DynamicTree::RemoveLeaf(int32 leaf) -{ - if (leaf == m_root) - { - m_root = b2_nullNode; - return; - } - - int32 parent = m_nodes[leaf].parent; - int32 grandParent = m_nodes[parent].parent; - int32 sibling; - if (m_nodes[parent].child1 == leaf) - { - sibling = m_nodes[parent].child2; - } - else - { - sibling = m_nodes[parent].child1; - } - - if (grandParent != b2_nullNode) - { - // Destroy parent and connect sibling to grandParent. - if (m_nodes[grandParent].child1 == parent) - { - m_nodes[grandParent].child1 = sibling; - } - else - { - m_nodes[grandParent].child2 = sibling; - } - m_nodes[sibling].parent = grandParent; - FreeNode(parent); - - // Adjust ancestor bounds. - int32 index = grandParent; - while (index != b2_nullNode) - { - index = Balance(index); - - int32 child1 = m_nodes[index].child1; - int32 child2 = m_nodes[index].child2; - - m_nodes[index].aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb); - m_nodes[index].height = 1 + b2Max(m_nodes[child1].height, m_nodes[child2].height); - - index = m_nodes[index].parent; - } - } - else - { - m_root = sibling; - m_nodes[sibling].parent = b2_nullNode; - FreeNode(parent); - } - - //Validate(); -} - -// Perform a left or right rotation if node A is imbalanced. -// Returns the new root index. -int32 b2DynamicTree::Balance(int32 iA) -{ - b2Assert(iA != b2_nullNode); - - b2TreeNode* A = m_nodes + iA; - if (A->IsLeaf() || A->height < 2) - { - return iA; - } - - int32 iB = A->child1; - int32 iC = A->child2; - b2Assert(0 <= iB && iB < m_nodeCapacity); - b2Assert(0 <= iC && iC < m_nodeCapacity); - - b2TreeNode* B = m_nodes + iB; - b2TreeNode* C = m_nodes + iC; - - int32 balance = C->height - B->height; - - // Rotate C up - if (balance > 1) - { - int32 iF = C->child1; - int32 iG = C->child2; - b2TreeNode* F = m_nodes + iF; - b2TreeNode* G = m_nodes + iG; - b2Assert(0 <= iF && iF < m_nodeCapacity); - b2Assert(0 <= iG && iG < m_nodeCapacity); - - // Swap A and C - C->child1 = iA; - C->parent = A->parent; - A->parent = iC; - - // A's old parent should point to C - if (C->parent != b2_nullNode) - { - if (m_nodes[C->parent].child1 == iA) - { - m_nodes[C->parent].child1 = iC; - } - else - { - b2Assert(m_nodes[C->parent].child2 == iA); - m_nodes[C->parent].child2 = iC; - } - } - else - { - m_root = iC; - } - - // Rotate - if (F->height > G->height) - { - C->child2 = iF; - A->child2 = iG; - G->parent = iA; - A->aabb.Combine(B->aabb, G->aabb); - C->aabb.Combine(A->aabb, F->aabb); - - A->height = 1 + b2Max(B->height, G->height); - C->height = 1 + b2Max(A->height, F->height); - } - else - { - C->child2 = iG; - A->child2 = iF; - F->parent = iA; - A->aabb.Combine(B->aabb, F->aabb); - C->aabb.Combine(A->aabb, G->aabb); - - A->height = 1 + b2Max(B->height, F->height); - C->height = 1 + b2Max(A->height, G->height); - } - - return iC; - } - - // Rotate B up - if (balance < -1) - { - int32 iD = B->child1; - int32 iE = B->child2; - b2TreeNode* D = m_nodes + iD; - b2TreeNode* E = m_nodes + iE; - b2Assert(0 <= iD && iD < m_nodeCapacity); - b2Assert(0 <= iE && iE < m_nodeCapacity); - - // Swap A and B - B->child1 = iA; - B->parent = A->parent; - A->parent = iB; - - // A's old parent should point to B - if (B->parent != b2_nullNode) - { - if (m_nodes[B->parent].child1 == iA) - { - m_nodes[B->parent].child1 = iB; - } - else - { - b2Assert(m_nodes[B->parent].child2 == iA); - m_nodes[B->parent].child2 = iB; - } - } - else - { - m_root = iB; - } - - // Rotate - if (D->height > E->height) - { - B->child2 = iD; - A->child1 = iE; - E->parent = iA; - A->aabb.Combine(C->aabb, E->aabb); - B->aabb.Combine(A->aabb, D->aabb); - - A->height = 1 + b2Max(C->height, E->height); - B->height = 1 + b2Max(A->height, D->height); - } - else - { - B->child2 = iE; - A->child1 = iD; - D->parent = iA; - A->aabb.Combine(C->aabb, D->aabb); - B->aabb.Combine(A->aabb, E->aabb); - - A->height = 1 + b2Max(C->height, D->height); - B->height = 1 + b2Max(A->height, E->height); - } - - return iB; - } - - return iA; -} - -int32 b2DynamicTree::GetHeight() const -{ - if (m_root == b2_nullNode) - { - return 0; - } - - return m_nodes[m_root].height; -} - -// -float32 b2DynamicTree::GetAreaRatio() const -{ - if (m_root == b2_nullNode) - { - return 0.0f; - } - - const b2TreeNode* root = m_nodes + m_root; - float32 rootArea = root->aabb.GetPerimeter(); - - float32 totalArea = 0.0f; - for (int32 i = 0; i < m_nodeCapacity; ++i) - { - const b2TreeNode* node = m_nodes + i; - if (node->height < 0) - { - // Free node in pool - continue; - } - - totalArea += node->aabb.GetPerimeter(); - } - - return totalArea / rootArea; -} - -// Compute the height of a sub-tree. -int32 b2DynamicTree::ComputeHeight(int32 nodeId) const -{ - b2Assert(0 <= nodeId && nodeId < m_nodeCapacity); - b2TreeNode* node = m_nodes + nodeId; - - if (node->IsLeaf()) - { - return 0; - } - - int32 height1 = ComputeHeight(node->child1); - int32 height2 = ComputeHeight(node->child2); - return 1 + b2Max(height1, height2); -} - -int32 b2DynamicTree::ComputeHeight() const -{ - int32 height = ComputeHeight(m_root); - return height; -} - -void b2DynamicTree::ValidateStructure(int32 index) const -{ - if (index == b2_nullNode) - { - return; - } - - if (index == m_root) - { - b2Assert(m_nodes[index].parent == b2_nullNode); - } - - const b2TreeNode* node = m_nodes + index; - - int32 child1 = node->child1; - int32 child2 = node->child2; - - if (node->IsLeaf()) - { - b2Assert(child1 == b2_nullNode); - b2Assert(child2 == b2_nullNode); - b2Assert(node->height == 0); - return; - } - - b2Assert(0 <= child1 && child1 < m_nodeCapacity); - b2Assert(0 <= child2 && child2 < m_nodeCapacity); - - b2Assert(m_nodes[child1].parent == index); - b2Assert(m_nodes[child2].parent == index); - - ValidateStructure(child1); - ValidateStructure(child2); -} - -void b2DynamicTree::ValidateMetrics(int32 index) const -{ - if (index == b2_nullNode) - { - return; - } - - const b2TreeNode* node = m_nodes + index; - - int32 child1 = node->child1; - int32 child2 = node->child2; - - if (node->IsLeaf()) - { - b2Assert(child1 == b2_nullNode); - b2Assert(child2 == b2_nullNode); - b2Assert(node->height == 0); - return; - } - - b2Assert(0 <= child1 && child1 < m_nodeCapacity); - b2Assert(0 <= child2 && child2 < m_nodeCapacity); - - int32 height1 = m_nodes[child1].height; - int32 height2 = m_nodes[child2].height; - int32 height; - height = 1 + b2Max(height1, height2); - b2Assert(node->height == height); - - b2AABB aabb; - aabb.Combine(m_nodes[child1].aabb, m_nodes[child2].aabb); - - b2Assert(aabb.lowerBound == node->aabb.lowerBound); - b2Assert(aabb.upperBound == node->aabb.upperBound); - - ValidateMetrics(child1); - ValidateMetrics(child2); -} - -void b2DynamicTree::Validate() const -{ - ValidateStructure(m_root); - ValidateMetrics(m_root); - - int32 freeCount = 0; - int32 freeIndex = m_freeList; - while (freeIndex != b2_nullNode) - { - b2Assert(0 <= freeIndex && freeIndex < m_nodeCapacity); - freeIndex = m_nodes[freeIndex].next; - ++freeCount; - } - - b2Assert(GetHeight() == ComputeHeight()); - - b2Assert(m_nodeCount + freeCount == m_nodeCapacity); -} - -int32 b2DynamicTree::GetMaxBalance() const -{ - int32 maxBalance = 0; - for (int32 i = 0; i < m_nodeCapacity; ++i) - { - const b2TreeNode* node = m_nodes + i; - if (node->height <= 1) - { - continue; - } - - b2Assert(node->IsLeaf() == false); - - int32 child1 = node->child1; - int32 child2 = node->child2; - int32 balance = b2Abs(m_nodes[child2].height - m_nodes[child1].height); - maxBalance = b2Max(maxBalance, balance); - } - - return maxBalance; -} - -void b2DynamicTree::RebuildBottomUp() -{ - int32* nodes = (int32*)b2Alloc(m_nodeCount * sizeof(int32)); - int32 count = 0; - - // Build array of leaves. Free the rest. - for (int32 i = 0; i < m_nodeCapacity; ++i) - { - if (m_nodes[i].height < 0) - { - // free node in pool - continue; - } - - if (m_nodes[i].IsLeaf()) - { - m_nodes[i].parent = b2_nullNode; - nodes[count] = i; - ++count; - } - else - { - FreeNode(i); - } - } - - while (count > 1) - { - float32 minCost = b2_maxFloat; - int32 iMin = -1, jMin = -1; - for (int32 i = 0; i < count; ++i) - { - b2AABB aabbi = m_nodes[nodes[i]].aabb; - - for (int32 j = i + 1; j < count; ++j) - { - b2AABB aabbj = m_nodes[nodes[j]].aabb; - b2AABB b; - b.Combine(aabbi, aabbj); - float32 cost = b.GetPerimeter(); - if (cost < minCost) - { - iMin = i; - jMin = j; - minCost = cost; - } - } - } - - int32 index1 = nodes[iMin]; - int32 index2 = nodes[jMin]; - b2TreeNode* child1 = m_nodes + index1; - b2TreeNode* child2 = m_nodes + index2; - - int32 parentIndex = AllocateNode(); - b2TreeNode* parent = m_nodes + parentIndex; - parent->child1 = index1; - parent->child2 = index2; - parent->height = 1 + b2Max(child1->height, child2->height); - parent->aabb.Combine(child1->aabb, child2->aabb); - parent->parent = b2_nullNode; - - child1->parent = parentIndex; - child2->parent = parentIndex; - - nodes[jMin] = nodes[count-1]; - nodes[iMin] = parentIndex; - --count; - } - - m_root = nodes[0]; - b2Free(nodes); - - Validate(); -} - -void b2DynamicTree::ShiftOrigin(const b2Vec2& newOrigin) -{ - // Build array of leaves. Free the rest. - for (int32 i = 0; i < m_nodeCapacity; ++i) - { - m_nodes[i].aabb.lowerBound -= newOrigin; - m_nodes[i].aabb.upperBound -= newOrigin; - } -} diff --git a/sources/Box2D/Collision/b2DynamicTree.h b/sources/Box2D/Collision/b2DynamicTree.h deleted file mode 100755 index 97aa461b..00000000 --- a/sources/Box2D/Collision/b2DynamicTree.h +++ /dev/null @@ -1,289 +0,0 @@ -/* -* Copyright (c) 2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_DYNAMIC_TREE_H -#define B2_DYNAMIC_TREE_H - -#include -#include - -#define b2_nullNode (-1) - -/// A node in the dynamic tree. The client does not interact with this directly. -struct b2TreeNode -{ - bool IsLeaf() const - { - return child1 == b2_nullNode; - } - - /// Enlarged AABB - b2AABB aabb; - - void* userData; - - union - { - int32 parent; - int32 next; - }; - - int32 child1; - int32 child2; - - // leaf = 0, free node = -1 - int32 height; -}; - -/// A dynamic AABB tree broad-phase, inspired by Nathanael Presson's btDbvt. -/// A dynamic tree arranges data in a binary tree to accelerate -/// queries such as volume queries and ray casts. Leafs are proxies -/// with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor -/// so that the proxy AABB is bigger than the client object. This allows the client -/// object to move by small amounts without triggering a tree update. -/// -/// Nodes are pooled and relocatable, so we use node indices rather than pointers. -class b2DynamicTree -{ -public: - /// Constructing the tree initializes the node pool. - b2DynamicTree(); - - /// Destroy the tree, freeing the node pool. - ~b2DynamicTree(); - - /// Create a proxy. Provide a tight fitting AABB and a userData pointer. - int32 CreateProxy(const b2AABB& aabb, void* userData); - - /// Destroy a proxy. This asserts if the id is invalid. - void DestroyProxy(int32 proxyId); - - /// Move a proxy with a swepted AABB. If the proxy has moved outside of its fattened AABB, - /// then the proxy is removed from the tree and re-inserted. Otherwise - /// the function returns immediately. - /// @return true if the proxy was re-inserted. - bool MoveProxy(int32 proxyId, const b2AABB& aabb1, const b2Vec2& displacement); - - /// Get proxy user data. - /// @return the proxy user data or 0 if the id is invalid. - void* GetUserData(int32 proxyId) const; - - /// Get the fat AABB for a proxy. - const b2AABB& GetFatAABB(int32 proxyId) const; - - /// Query an AABB for overlapping proxies. The callback class - /// is called for each proxy that overlaps the supplied AABB. - template - void Query(T* callback, const b2AABB& aabb) const; - - /// Ray-cast against the proxies in the tree. This relies on the callback - /// to perform a exact ray-cast in the case were the proxy contains a shape. - /// The callback also performs the any collision filtering. This has performance - /// roughly equal to k * log(n), where k is the number of collisions and n is the - /// number of proxies in the tree. - /// @param input the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). - /// @param callback a callback class that is called for each proxy that is hit by the ray. - template - void RayCast(T* callback, const b2RayCastInput& input) const; - - /// Validate this tree. For testing. - void Validate() const; - - /// Compute the height of the binary tree in O(N) time. Should not be - /// called often. - int32 GetHeight() const; - - /// Get the maximum balance of an node in the tree. The balance is the difference - /// in height of the two children of a node. - int32 GetMaxBalance() const; - - /// Get the ratio of the sum of the node areas to the root area. - float32 GetAreaRatio() const; - - /// Build an optimal tree. Very expensive. For testing. - void RebuildBottomUp(); - - /// Shift the world origin. Useful for large worlds. - /// The shift formula is: position -= newOrigin - /// @param newOrigin the new origin with respect to the old origin - void ShiftOrigin(const b2Vec2& newOrigin); - -private: - - int32 AllocateNode(); - void FreeNode(int32 node); - - void InsertLeaf(int32 node); - void RemoveLeaf(int32 node); - - int32 Balance(int32 index); - - int32 ComputeHeight() const; - int32 ComputeHeight(int32 nodeId) const; - - void ValidateStructure(int32 index) const; - void ValidateMetrics(int32 index) const; - - int32 m_root; - - b2TreeNode* m_nodes; - int32 m_nodeCount; - int32 m_nodeCapacity; - - int32 m_freeList; - - /// This is used to incrementally traverse the tree for re-balancing. - uint32 m_path; - - int32 m_insertionCount; -}; - -inline void* b2DynamicTree::GetUserData(int32 proxyId) const -{ - b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); - return m_nodes[proxyId].userData; -} - -inline const b2AABB& b2DynamicTree::GetFatAABB(int32 proxyId) const -{ - b2Assert(0 <= proxyId && proxyId < m_nodeCapacity); - return m_nodes[proxyId].aabb; -} - -template -inline void b2DynamicTree::Query(T* callback, const b2AABB& aabb) const -{ - b2GrowableStack stack; - stack.Push(m_root); - - while (stack.GetCount() > 0) - { - int32 nodeId = stack.Pop(); - if (nodeId == b2_nullNode) - { - continue; - } - - const b2TreeNode* node = m_nodes + nodeId; - - if (b2TestOverlap(node->aabb, aabb)) - { - if (node->IsLeaf()) - { - bool proceed = callback->QueryCallback(nodeId); - if (proceed == false) - { - return; - } - } - else - { - stack.Push(node->child1); - stack.Push(node->child2); - } - } - } -} - -template -inline void b2DynamicTree::RayCast(T* callback, const b2RayCastInput& input) const -{ - b2Vec2 p1 = input.p1; - b2Vec2 p2 = input.p2; - b2Vec2 r = p2 - p1; - b2Assert(r.LengthSquared() > 0.0f); - r.Normalize(); - - // v is perpendicular to the segment. - b2Vec2 v = b2Cross(1.0f, r); - b2Vec2 abs_v = b2Abs(v); - - // Separating axis for segment (Gino, p80). - // |dot(v, p1 - c)| > dot(|v|, h) - - float32 maxFraction = input.maxFraction; - - // Build a bounding box for the segment. - b2AABB segmentAABB; - { - b2Vec2 t = p1 + maxFraction * (p2 - p1); - segmentAABB.lowerBound = b2Min(p1, t); - segmentAABB.upperBound = b2Max(p1, t); - } - - b2GrowableStack stack; - stack.Push(m_root); - - while (stack.GetCount() > 0) - { - int32 nodeId = stack.Pop(); - if (nodeId == b2_nullNode) - { - continue; - } - - const b2TreeNode* node = m_nodes + nodeId; - - if (b2TestOverlap(node->aabb, segmentAABB) == false) - { - continue; - } - - // Separating axis for segment (Gino, p80). - // |dot(v, p1 - c)| > dot(|v|, h) - b2Vec2 c = node->aabb.GetCenter(); - b2Vec2 h = node->aabb.GetExtents(); - float32 separation = b2Abs(b2Dot(v, p1 - c)) - b2Dot(abs_v, h); - if (separation > 0.0f) - { - continue; - } - - if (node->IsLeaf()) - { - b2RayCastInput subInput; - subInput.p1 = input.p1; - subInput.p2 = input.p2; - subInput.maxFraction = maxFraction; - - float32 value = callback->RayCastCallback(subInput, nodeId); - - if (value == 0.0f) - { - // The client has terminated the ray cast. - return; - } - - if (value > 0.0f) - { - // Update segment bounding box. - maxFraction = value; - b2Vec2 t = p1 + maxFraction * (p2 - p1); - segmentAABB.lowerBound = b2Min(p1, t); - segmentAABB.upperBound = b2Max(p1, t); - } - } - else - { - stack.Push(node->child1); - stack.Push(node->child2); - } - } -} - -#endif diff --git a/sources/Box2D/Collision/b2TimeOfImpact.cpp b/sources/Box2D/Collision/b2TimeOfImpact.cpp deleted file mode 100755 index fa2248c4..00000000 --- a/sources/Box2D/Collision/b2TimeOfImpact.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include - -#include - -float32 b2_toiTime, b2_toiMaxTime; -int32 b2_toiCalls, b2_toiIters, b2_toiMaxIters; -int32 b2_toiRootIters, b2_toiMaxRootIters; - -// -struct b2SeparationFunction -{ - enum Type - { - e_points, - e_faceA, - e_faceB - }; - - // TODO_ERIN might not need to return the separation - - float32 Initialize(const b2SimplexCache* cache, - const b2DistanceProxy* proxyA, const b2Sweep& sweepA, - const b2DistanceProxy* proxyB, const b2Sweep& sweepB, - float32 t1) - { - m_proxyA = proxyA; - m_proxyB = proxyB; - int32 count = cache->count; - b2Assert(0 < count && count < 3); - - m_sweepA = sweepA; - m_sweepB = sweepB; - - b2Transform xfA, xfB; - m_sweepA.GetTransform(&xfA, t1); - m_sweepB.GetTransform(&xfB, t1); - - if (count == 1) - { - m_type = e_points; - b2Vec2 localPointA = m_proxyA->GetVertex(cache->indexA[0]); - b2Vec2 localPointB = m_proxyB->GetVertex(cache->indexB[0]); - b2Vec2 pointA = b2Mul(xfA, localPointA); - b2Vec2 pointB = b2Mul(xfB, localPointB); - m_axis = pointB - pointA; - float32 s = m_axis.Normalize(); - return s; - } - else if (cache->indexA[0] == cache->indexA[1]) - { - // Two points on B and one on A. - m_type = e_faceB; - b2Vec2 localPointB1 = proxyB->GetVertex(cache->indexB[0]); - b2Vec2 localPointB2 = proxyB->GetVertex(cache->indexB[1]); - - m_axis = b2Cross(localPointB2 - localPointB1, 1.0f); - m_axis.Normalize(); - b2Vec2 normal = b2Mul(xfB.q, m_axis); - - m_localPoint = 0.5f * (localPointB1 + localPointB2); - b2Vec2 pointB = b2Mul(xfB, m_localPoint); - - b2Vec2 localPointA = proxyA->GetVertex(cache->indexA[0]); - b2Vec2 pointA = b2Mul(xfA, localPointA); - - float32 s = b2Dot(pointA - pointB, normal); - if (s < 0.0f) - { - m_axis = -m_axis; - s = -s; - } - return s; - } - else - { - // Two points on A and one or two points on B. - m_type = e_faceA; - b2Vec2 localPointA1 = m_proxyA->GetVertex(cache->indexA[0]); - b2Vec2 localPointA2 = m_proxyA->GetVertex(cache->indexA[1]); - - m_axis = b2Cross(localPointA2 - localPointA1, 1.0f); - m_axis.Normalize(); - b2Vec2 normal = b2Mul(xfA.q, m_axis); - - m_localPoint = 0.5f * (localPointA1 + localPointA2); - b2Vec2 pointA = b2Mul(xfA, m_localPoint); - - b2Vec2 localPointB = m_proxyB->GetVertex(cache->indexB[0]); - b2Vec2 pointB = b2Mul(xfB, localPointB); - - float32 s = b2Dot(pointB - pointA, normal); - if (s < 0.0f) - { - m_axis = -m_axis; - s = -s; - } - return s; - } - } - - // - float32 FindMinSeparation(int32* indexA, int32* indexB, float32 t) const - { - b2Transform xfA, xfB; - m_sweepA.GetTransform(&xfA, t); - m_sweepB.GetTransform(&xfB, t); - - switch (m_type) - { - case e_points: - { - b2Vec2 axisA = b2MulT(xfA.q, m_axis); - b2Vec2 axisB = b2MulT(xfB.q, -m_axis); - - *indexA = m_proxyA->GetSupport(axisA); - *indexB = m_proxyB->GetSupport(axisB); - - b2Vec2 localPointA = m_proxyA->GetVertex(*indexA); - b2Vec2 localPointB = m_proxyB->GetVertex(*indexB); - - b2Vec2 pointA = b2Mul(xfA, localPointA); - b2Vec2 pointB = b2Mul(xfB, localPointB); - - float32 separation = b2Dot(pointB - pointA, m_axis); - return separation; - } - - case e_faceA: - { - b2Vec2 normal = b2Mul(xfA.q, m_axis); - b2Vec2 pointA = b2Mul(xfA, m_localPoint); - - b2Vec2 axisB = b2MulT(xfB.q, -normal); - - *indexA = -1; - *indexB = m_proxyB->GetSupport(axisB); - - b2Vec2 localPointB = m_proxyB->GetVertex(*indexB); - b2Vec2 pointB = b2Mul(xfB, localPointB); - - float32 separation = b2Dot(pointB - pointA, normal); - return separation; - } - - case e_faceB: - { - b2Vec2 normal = b2Mul(xfB.q, m_axis); - b2Vec2 pointB = b2Mul(xfB, m_localPoint); - - b2Vec2 axisA = b2MulT(xfA.q, -normal); - - *indexB = -1; - *indexA = m_proxyA->GetSupport(axisA); - - b2Vec2 localPointA = m_proxyA->GetVertex(*indexA); - b2Vec2 pointA = b2Mul(xfA, localPointA); - - float32 separation = b2Dot(pointA - pointB, normal); - return separation; - } - - default: - b2Assert(false); - *indexA = -1; - *indexB = -1; - return 0.0f; - } - } - - // - float32 Evaluate(int32 indexA, int32 indexB, float32 t) const - { - b2Transform xfA, xfB; - m_sweepA.GetTransform(&xfA, t); - m_sweepB.GetTransform(&xfB, t); - - switch (m_type) - { - case e_points: - { - b2Vec2 localPointA = m_proxyA->GetVertex(indexA); - b2Vec2 localPointB = m_proxyB->GetVertex(indexB); - - b2Vec2 pointA = b2Mul(xfA, localPointA); - b2Vec2 pointB = b2Mul(xfB, localPointB); - float32 separation = b2Dot(pointB - pointA, m_axis); - - return separation; - } - - case e_faceA: - { - b2Vec2 normal = b2Mul(xfA.q, m_axis); - b2Vec2 pointA = b2Mul(xfA, m_localPoint); - - b2Vec2 localPointB = m_proxyB->GetVertex(indexB); - b2Vec2 pointB = b2Mul(xfB, localPointB); - - float32 separation = b2Dot(pointB - pointA, normal); - return separation; - } - - case e_faceB: - { - b2Vec2 normal = b2Mul(xfB.q, m_axis); - b2Vec2 pointB = b2Mul(xfB, m_localPoint); - - b2Vec2 localPointA = m_proxyA->GetVertex(indexA); - b2Vec2 pointA = b2Mul(xfA, localPointA); - - float32 separation = b2Dot(pointA - pointB, normal); - return separation; - } - - default: - b2Assert(false); - return 0.0f; - } - } - - const b2DistanceProxy* m_proxyA; - const b2DistanceProxy* m_proxyB; - b2Sweep m_sweepA, m_sweepB; - Type m_type; - b2Vec2 m_localPoint; - b2Vec2 m_axis; -}; - -// CCD via the local separating axis method. This seeks progression -// by computing the largest time at which separation is maintained. -void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input) -{ - b2Timer timer; - - ++b2_toiCalls; - - output->state = b2TOIOutput::e_unknown; - output->t = input->tMax; - - const b2DistanceProxy* proxyA = &input->proxyA; - const b2DistanceProxy* proxyB = &input->proxyB; - - b2Sweep sweepA = input->sweepA; - b2Sweep sweepB = input->sweepB; - - // Large rotations can make the root finder fail, so we normalize the - // sweep angles. - sweepA.Normalize(); - sweepB.Normalize(); - - float32 tMax = input->tMax; - - float32 totalRadius = proxyA->m_radius + proxyB->m_radius; - float32 target = b2Max(b2_linearSlop, totalRadius - 3.0f * b2_linearSlop); - float32 tolerance = 0.25f * b2_linearSlop; - b2Assert(target > tolerance); - - float32 t1 = 0.0f; - const int32 k_maxIterations = 20; // TODO_ERIN b2Settings - int32 iter = 0; - - // Prepare input for distance query. - b2SimplexCache cache; - cache.count = 0; - b2DistanceInput distanceInput; - distanceInput.proxyA = input->proxyA; - distanceInput.proxyB = input->proxyB; - distanceInput.useRadii = false; - - // The outer loop progressively attempts to compute new separating axes. - // This loop terminates when an axis is repeated (no progress is made). - for(;;) - { - b2Transform xfA, xfB; - sweepA.GetTransform(&xfA, t1); - sweepB.GetTransform(&xfB, t1); - - // Get the distance between shapes. We can also use the results - // to get a separating axis. - distanceInput.transformA = xfA; - distanceInput.transformB = xfB; - b2DistanceOutput distanceOutput; - b2Distance(&distanceOutput, &cache, &distanceInput); - - // If the shapes are overlapped, we give up on continuous collision. - if (distanceOutput.distance <= 0.0f) - { - // Failure! - output->state = b2TOIOutput::e_overlapped; - output->t = 0.0f; - break; - } - - if (distanceOutput.distance < target + tolerance) - { - // Victory! - output->state = b2TOIOutput::e_touching; - output->t = t1; - break; - } - - // Initialize the separating axis. - b2SeparationFunction fcn; - fcn.Initialize(&cache, proxyA, sweepA, proxyB, sweepB, t1); -#if 0 - // Dump the curve seen by the root finder - { - const int32 N = 100; - float32 dx = 1.0f / N; - float32 xs[N+1]; - float32 fs[N+1]; - - float32 x = 0.0f; - - for (int32 i = 0; i <= N; ++i) - { - sweepA.GetTransform(&xfA, x); - sweepB.GetTransform(&xfB, x); - float32 f = fcn.Evaluate(xfA, xfB) - target; - - printf("%g %g\n", x, f); - - xs[i] = x; - fs[i] = f; - - x += dx; - } - } -#endif - - // Compute the TOI on the separating axis. We do this by successively - // resolving the deepest point. This loop is bounded by the number of vertices. - bool done = false; - float32 t2 = tMax; - int32 pushBackIter = 0; - for (;;) - { - // Find the deepest point at t2. Store the witness point indices. - int32 indexA, indexB; - float32 s2 = fcn.FindMinSeparation(&indexA, &indexB, t2); - - // Is the final configuration separated? - if (s2 > target + tolerance) - { - // Victory! - output->state = b2TOIOutput::e_separated; - output->t = tMax; - done = true; - break; - } - - // Has the separation reached tolerance? - if (s2 > target - tolerance) - { - // Advance the sweeps - t1 = t2; - break; - } - - // Compute the initial separation of the witness points. - float32 s1 = fcn.Evaluate(indexA, indexB, t1); - - // Check for initial overlap. This might happen if the root finder - // runs out of iterations. - if (s1 < target - tolerance) - { - output->state = b2TOIOutput::e_failed; - output->t = t1; - done = true; - break; - } - - // Check for touching - if (s1 <= target + tolerance) - { - // Victory! t1 should hold the TOI (could be 0.0). - output->state = b2TOIOutput::e_touching; - output->t = t1; - done = true; - break; - } - - // Compute 1D root of: f(x) - target = 0 - int32 rootIterCount = 0; - float32 a1 = t1, a2 = t2; - for (;;) - { - // Use a mix of the secant rule and bisection. - float32 t; - if (rootIterCount & 1) - { - // Secant rule to improve convergence. - t = a1 + (target - s1) * (a2 - a1) / (s2 - s1); - } - else - { - // Bisection to guarantee progress. - t = 0.5f * (a1 + a2); - } - - ++rootIterCount; - ++b2_toiRootIters; - - float32 s = fcn.Evaluate(indexA, indexB, t); - - if (b2Abs(s - target) < tolerance) - { - // t2 holds a tentative value for t1 - t2 = t; - break; - } - - // Ensure we continue to bracket the root. - if (s > target) - { - a1 = t; - s1 = s; - } - else - { - a2 = t; - s2 = s; - } - - if (rootIterCount == 50) - { - break; - } - } - - b2_toiMaxRootIters = b2Max(b2_toiMaxRootIters, rootIterCount); - - ++pushBackIter; - - if (pushBackIter == b2_maxPolygonVertices) - { - break; - } - } - - ++iter; - ++b2_toiIters; - - if (done) - { - break; - } - - if (iter == k_maxIterations) - { - // Root finder got stuck. Semi-victory. - output->state = b2TOIOutput::e_failed; - output->t = t1; - break; - } - } - - b2_toiMaxIters = b2Max(b2_toiMaxIters, iter); - - float32 time = timer.GetMilliseconds(); - b2_toiMaxTime = b2Max(b2_toiMaxTime, time); - b2_toiTime += time; -} diff --git a/sources/Box2D/Collision/b2TimeOfImpact.h b/sources/Box2D/Collision/b2TimeOfImpact.h deleted file mode 100755 index 179a1700..00000000 --- a/sources/Box2D/Collision/b2TimeOfImpact.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_TIME_OF_IMPACT_H -#define B2_TIME_OF_IMPACT_H - -#include -#include - -/// Input parameters for b2TimeOfImpact -struct b2TOIInput -{ - b2DistanceProxy proxyA; - b2DistanceProxy proxyB; - b2Sweep sweepA; - b2Sweep sweepB; - float32 tMax; // defines sweep interval [0, tMax] -}; - -// Output parameters for b2TimeOfImpact. -struct b2TOIOutput -{ - enum State - { - e_unknown, - e_failed, - e_overlapped, - e_touching, - e_separated - }; - - State state; - float32 t; -}; - -/// Compute the upper bound on time before two shapes penetrate. Time is represented as -/// a fraction between [0,tMax]. This uses a swept separating axis and may miss some intermediate, -/// non-tunneling collision. If you change the time interval, you should call this function -/// again. -/// Note: use b2Distance to compute the contact point and normal at the time of impact. -void b2TimeOfImpact(b2TOIOutput* output, const b2TOIInput* input); - -#endif diff --git a/sources/Box2D/Common/b2BlockAllocator.cpp b/sources/Box2D/Common/b2BlockAllocator.cpp deleted file mode 100755 index c9fcbfbb..00000000 --- a/sources/Box2D/Common/b2BlockAllocator.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include - -int32 b2BlockAllocator::s_blockSizes[b2_blockSizes] = -{ - 16, // 0 - 32, // 1 - 64, // 2 - 96, // 3 - 128, // 4 - 160, // 5 - 192, // 6 - 224, // 7 - 256, // 8 - 320, // 9 - 384, // 10 - 448, // 11 - 512, // 12 - 640, // 13 -}; -uint8 b2BlockAllocator::s_blockSizeLookup[b2_maxBlockSize + 1]; -bool b2BlockAllocator::s_blockSizeLookupInitialized; - -struct b2Chunk -{ - int32 blockSize; - b2Block* blocks; -}; - -struct b2Block -{ - b2Block* next; -}; - -b2BlockAllocator::b2BlockAllocator() -{ - b2Assert(b2_blockSizes < UCHAR_MAX); - - m_chunkSpace = b2_chunkArrayIncrement; - m_chunkCount = 0; - m_chunks = (b2Chunk*)b2Alloc(m_chunkSpace * sizeof(b2Chunk)); - - memset(m_chunks, 0, m_chunkSpace * sizeof(b2Chunk)); - memset(m_freeLists, 0, sizeof(m_freeLists)); - - if (s_blockSizeLookupInitialized == false) - { - int32 j = 0; - for (int32 i = 1; i <= b2_maxBlockSize; ++i) - { - b2Assert(j < b2_blockSizes); - if (i <= s_blockSizes[j]) - { - s_blockSizeLookup[i] = (uint8)j; - } - else - { - ++j; - s_blockSizeLookup[i] = (uint8)j; - } - } - - s_blockSizeLookupInitialized = true; - } -} - -b2BlockAllocator::~b2BlockAllocator() -{ - for (int32 i = 0; i < m_chunkCount; ++i) - { - b2Free(m_chunks[i].blocks); - } - - b2Free(m_chunks); -} - -void* b2BlockAllocator::Allocate(int32 size) -{ - if (size == 0) - return NULL; - - b2Assert(0 < size); - - if (size > b2_maxBlockSize) - { - return b2Alloc(size); - } - - int32 index = s_blockSizeLookup[size]; - b2Assert(0 <= index && index < b2_blockSizes); - - if (m_freeLists[index]) - { - b2Block* block = m_freeLists[index]; - m_freeLists[index] = block->next; - return block; - } - else - { - if (m_chunkCount == m_chunkSpace) - { - b2Chunk* oldChunks = m_chunks; - m_chunkSpace += b2_chunkArrayIncrement; - m_chunks = (b2Chunk*)b2Alloc(m_chunkSpace * sizeof(b2Chunk)); - memcpy(m_chunks, oldChunks, m_chunkCount * sizeof(b2Chunk)); - memset(m_chunks + m_chunkCount, 0, b2_chunkArrayIncrement * sizeof(b2Chunk)); - b2Free(oldChunks); - } - - b2Chunk* chunk = m_chunks + m_chunkCount; - chunk->blocks = (b2Block*)b2Alloc(b2_chunkSize); -#if defined(_DEBUG) - memset(chunk->blocks, 0xcd, b2_chunkSize); -#endif - int32 blockSize = s_blockSizes[index]; - chunk->blockSize = blockSize; - int32 blockCount = b2_chunkSize / blockSize; - b2Assert(blockCount * blockSize <= b2_chunkSize); - for (int32 i = 0; i < blockCount - 1; ++i) - { - b2Block* block = (b2Block*)((int8*)chunk->blocks + blockSize * i); - b2Block* next = (b2Block*)((int8*)chunk->blocks + blockSize * (i + 1)); - block->next = next; - } - b2Block* last = (b2Block*)((int8*)chunk->blocks + blockSize * (blockCount - 1)); - last->next = NULL; - - m_freeLists[index] = chunk->blocks->next; - ++m_chunkCount; - - return chunk->blocks; - } -} - -void b2BlockAllocator::Free(void* p, int32 size) -{ - if (size == 0) - { - return; - } - - b2Assert(0 < size); - - if (size > b2_maxBlockSize) - { - b2Free(p); - return; - } - - int32 index = s_blockSizeLookup[size]; - b2Assert(0 <= index && index < b2_blockSizes); - -#ifdef _DEBUG - // Verify the memory address and size is valid. - int32 blockSize = s_blockSizes[index]; - bool found = false; - for (int32 i = 0; i < m_chunkCount; ++i) - { - b2Chunk* chunk = m_chunks + i; - if (chunk->blockSize != blockSize) - { - b2Assert( (int8*)p + blockSize <= (int8*)chunk->blocks || - (int8*)chunk->blocks + b2_chunkSize <= (int8*)p); - } - else - { - if ((int8*)chunk->blocks <= (int8*)p && (int8*)p + blockSize <= (int8*)chunk->blocks + b2_chunkSize) - { - found = true; - } - } - } - - b2Assert(found); - - memset(p, 0xfd, blockSize); -#endif - - b2Block* block = (b2Block*)p; - block->next = m_freeLists[index]; - m_freeLists[index] = block; -} - -void b2BlockAllocator::Clear() -{ - for (int32 i = 0; i < m_chunkCount; ++i) - { - b2Free(m_chunks[i].blocks); - } - - m_chunkCount = 0; - memset(m_chunks, 0, m_chunkSpace * sizeof(b2Chunk)); - - memset(m_freeLists, 0, sizeof(m_freeLists)); -} diff --git a/sources/Box2D/Common/b2BlockAllocator.h b/sources/Box2D/Common/b2BlockAllocator.h deleted file mode 100755 index 8ba29a5e..00000000 --- a/sources/Box2D/Common/b2BlockAllocator.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_BLOCK_ALLOCATOR_H -#define B2_BLOCK_ALLOCATOR_H - -#include - -const int32 b2_chunkSize = 16 * 1024; -const int32 b2_maxBlockSize = 640; -const int32 b2_blockSizes = 14; -const int32 b2_chunkArrayIncrement = 128; - -struct b2Block; -struct b2Chunk; - -/// This is a small object allocator used for allocating small -/// objects that persist for more than one time step. -/// See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp -class b2BlockAllocator -{ -public: - b2BlockAllocator(); - ~b2BlockAllocator(); - - /// Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize. - void* Allocate(int32 size); - - /// Free memory. This will use b2Free if the size is larger than b2_maxBlockSize. - void Free(void* p, int32 size); - - void Clear(); - -private: - - b2Chunk* m_chunks; - int32 m_chunkCount; - int32 m_chunkSpace; - - b2Block* m_freeLists[b2_blockSizes]; - - static int32 s_blockSizes[b2_blockSizes]; - static uint8 s_blockSizeLookup[b2_maxBlockSize + 1]; - static bool s_blockSizeLookupInitialized; -}; - -#endif diff --git a/sources/Box2D/Common/b2Draw.cpp b/sources/Box2D/Common/b2Draw.cpp deleted file mode 100755 index 327b5807..00000000 --- a/sources/Box2D/Common/b2Draw.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 - -b2Draw::b2Draw() -{ - m_drawFlags = 0; -} - -void b2Draw::SetFlags(uint32 flags) -{ - m_drawFlags = flags; -} - -uint32 b2Draw::GetFlags() const -{ - return m_drawFlags; -} - -void b2Draw::AppendFlags(uint32 flags) -{ - m_drawFlags |= flags; -} - -void b2Draw::ClearFlags(uint32 flags) -{ - m_drawFlags &= ~flags; -} diff --git a/sources/Box2D/Common/b2Draw.h b/sources/Box2D/Common/b2Draw.h deleted file mode 100755 index 7dbcdef4..00000000 --- a/sources/Box2D/Common/b2Draw.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_DRAW_H -#define B2_DRAW_H - -#include - -/// Color for debug drawing. Each value has the range [0,1]. -struct b2Color -{ - b2Color() {} - b2Color(float32 r, float32 g, float32 b, float32 a = 1.0f) : r(r), g(g), b(b), a(a) {} - void Set(float32 ri, float32 gi, float32 bi, float32 ai = 1.0f) { r = ri; g = gi; b = bi; a = ai; } - float32 r, g, b, a; -}; - -/// Implement and register this class with a b2World to provide debug drawing of physics -/// entities in your game. -class b2Draw -{ -public: - b2Draw(); - - virtual ~b2Draw() {} - - enum - { - e_shapeBit = 0x0001, ///< draw shapes - e_jointBit = 0x0002, ///< draw joint connections - e_aabbBit = 0x0004, ///< draw axis aligned bounding boxes - e_pairBit = 0x0008, ///< draw broad-phase pairs - e_centerOfMassBit = 0x0010 ///< draw center of mass frame - }; - - /// Set the drawing flags. - void SetFlags(uint32 flags); - - /// Get the drawing flags. - uint32 GetFlags() const; - - /// Append flags to the current flags. - void AppendFlags(uint32 flags); - - /// Clear flags from the current flags. - void ClearFlags(uint32 flags); - - /// Draw a closed polygon provided in CCW order. - virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0; - - /// Draw a solid closed polygon provided in CCW order. - virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0; - - /// Draw a circle. - virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) = 0; - - /// Draw a solid circle. - virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) = 0; - - /// Draw a line segment. - virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) = 0; - - /// Draw a transform. Choose your own length scale. - /// @param xf a transform. - virtual void DrawTransform(const b2Transform& xf) = 0; - - /// Clear draw commands - virtual void ClearDraw() = 0; -protected: - uint32 m_drawFlags; -}; - -#endif diff --git a/sources/Box2D/Common/b2GrowableStack.h b/sources/Box2D/Common/b2GrowableStack.h deleted file mode 100755 index cd5a981f..00000000 --- a/sources/Box2D/Common/b2GrowableStack.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_GROWABLE_STACK_H -#define B2_GROWABLE_STACK_H -#include -#include - -/// This is a growable LIFO stack with an initial capacity of N. -/// If the stack size exceeds the initial capacity, the heap is used -/// to increase the size of the stack. -template -class b2GrowableStack -{ -public: - b2GrowableStack() - { - m_stack = m_array; - m_count = 0; - m_capacity = N; - } - - ~b2GrowableStack() - { - if (m_stack != m_array) - { - b2Free(m_stack); - m_stack = NULL; - } - } - - void Push(const T& element) - { - if (m_count == m_capacity) - { - T* old = m_stack; - m_capacity *= 2; - m_stack = (T*)b2Alloc(m_capacity * sizeof(T)); - memcpy(m_stack, old, m_count * sizeof(T)); - if (old != m_array) - { - b2Free(old); - } - } - - m_stack[m_count] = element; - ++m_count; - } - - T Pop() - { - b2Assert(m_count > 0); - --m_count; - return m_stack[m_count]; - } - - int32 GetCount() - { - return m_count; - } - -private: - T* m_stack; - T m_array[N]; - int32 m_count; - int32 m_capacity; -}; - - -#endif diff --git a/sources/Box2D/Common/b2Math.cpp b/sources/Box2D/Common/b2Math.cpp deleted file mode 100755 index 4974fe18..00000000 --- a/sources/Box2D/Common/b2Math.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -* Copyright (c) 2007-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 - -const b2Vec2 b2Vec2_zero(0.0f, 0.0f); - -/// Solve A * x = b, where b is a column vector. This is more efficient -/// than computing the inverse in one-shot cases. -b2Vec3 b2Mat33::Solve33(const b2Vec3& b) const -{ - float32 det = b2Dot(ex, b2Cross(ey, ez)); - if (det != 0.0f) - { - det = 1.0f / det; - } - b2Vec3 x; - x.x = det * b2Dot(b, b2Cross(ey, ez)); - x.y = det * b2Dot(ex, b2Cross(b, ez)); - x.z = det * b2Dot(ex, b2Cross(ey, b)); - return x; -} - -/// Solve A * x = b, where b is a column vector. This is more efficient -/// than computing the inverse in one-shot cases. -b2Vec2 b2Mat33::Solve22(const b2Vec2& b) const -{ - float32 a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y; - float32 det = a11 * a22 - a12 * a21; - if (det != 0.0f) - { - det = 1.0f / det; - } - b2Vec2 x; - x.x = det * (a22 * b.x - a12 * b.y); - x.y = det * (a11 * b.y - a21 * b.x); - return x; -} - -/// -void b2Mat33::GetInverse22(b2Mat33* M) const -{ - float32 a = ex.x, b = ey.x, c = ex.y, d = ey.y; - float32 det = a * d - b * c; - if (det != 0.0f) - { - det = 1.0f / det; - } - - M->ex.x = det * d; M->ey.x = -det * b; M->ex.z = 0.0f; - M->ex.y = -det * c; M->ey.y = det * a; M->ey.z = 0.0f; - M->ez.x = 0.0f; M->ez.y = 0.0f; M->ez.z = 0.0f; -} - -/// Returns the zero matrix if singular. -void b2Mat33::GetSymInverse33(b2Mat33* M) const -{ - float32 det = b2Dot(ex, b2Cross(ey, ez)); - if (det != 0.0f) - { - det = 1.0f / det; - } - - float32 a11 = ex.x, a12 = ey.x, a13 = ez.x; - float32 a22 = ey.y, a23 = ez.y; - float32 a33 = ez.z; - - M->ex.x = det * (a22 * a33 - a23 * a23); - M->ex.y = det * (a13 * a23 - a12 * a33); - M->ex.z = det * (a12 * a23 - a13 * a22); - - M->ey.x = M->ex.y; - M->ey.y = det * (a11 * a33 - a13 * a13); - M->ey.z = det * (a13 * a12 - a11 * a23); - - M->ez.x = M->ex.z; - M->ez.y = M->ey.z; - M->ez.z = det * (a11 * a22 - a12 * a12); -} diff --git a/sources/Box2D/Common/b2Math.h b/sources/Box2D/Common/b2Math.h deleted file mode 100755 index a9b0813e..00000000 --- a/sources/Box2D/Common/b2Math.h +++ /dev/null @@ -1,720 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_MATH_H -#define B2_MATH_H - -#include -#include - -/// This function is used to ensure that a floating point number is not a NaN or infinity. -inline bool b2IsValid(float32 x) -{ - int32 ix = *reinterpret_cast(&x); - return (ix & 0x7f800000) != 0x7f800000; -} - -/// This is a approximate yet fast inverse square-root. -inline float32 b2InvSqrt(float32 x) -{ - union - { - float32 x; - int32 i; - } convert; - - convert.x = x; - float32 xhalf = 0.5f * x; - convert.i = 0x5f3759df - (convert.i >> 1); - x = convert.x; - x = x * (1.5f - xhalf * x * x); - return x; -} - -#define b2Sqrt(x) sqrtf(x) -#define b2Atan2(y, x) atan2f(y, x) - -/// A 2D column vector. -struct b2Vec2 -{ - /// Default constructor does nothing (for performance). - b2Vec2() {} - - /// Construct using coordinates. - b2Vec2(float32 x, float32 y) : x(x), y(y) {} - - /// Set this vector to all zeros. - void SetZero() { x = 0.0f; y = 0.0f; } - - /// Set this vector to some specified coordinates. - void Set(float32 x_, float32 y_) { x = x_; y = y_; } - - /// Negate this vector. - b2Vec2 operator -() const { b2Vec2 v; v.Set(-x, -y); return v; } - - /// Read from and indexed element. - float32 operator () (int32 i) const - { - return (&x)[i]; - } - - /// Write to an indexed element. - float32& operator () (int32 i) - { - return (&x)[i]; - } - - /// Add a vector to this vector. - void operator += (const b2Vec2& v) - { - x += v.x; y += v.y; - } - - /// Subtract a vector from this vector. - void operator -= (const b2Vec2& v) - { - x -= v.x; y -= v.y; - } - - /// Multiply this vector by a scalar. - void operator *= (float32 a) - { - x *= a; y *= a; - } - - /// Get the length of this vector (the norm). - float32 Length() const - { - return b2Sqrt(x * x + y * y); - } - - /// Get the length squared. For performance, use this instead of - /// b2Vec2::Length (if possible). - float32 LengthSquared() const - { - return x * x + y * y; - } - - /// Convert this vector into a unit vector. Returns the length. - float32 Normalize() - { - float32 length = Length(); - if (length < b2_epsilon) - { - return 0.0f; - } - float32 invLength = 1.0f / length; - x *= invLength; - y *= invLength; - - return length; - } - - /// Does this vector contain finite coordinates? - bool IsValid() const - { - return b2IsValid(x) && b2IsValid(y); - } - - /// Get the skew vector such that dot(skew_vec, other) == cross(vec, other) - b2Vec2 Skew() const - { - return b2Vec2(-y, x); - } - - float32 x, y; -}; - -/// A 2D column vector with 3 elements. -struct b2Vec3 -{ - /// Default constructor does nothing (for performance). - b2Vec3() {} - - /// Construct using coordinates. - b2Vec3(float32 x, float32 y, float32 z) : x(x), y(y), z(z) {} - - /// Set this vector to all zeros. - void SetZero() { x = 0.0f; y = 0.0f; z = 0.0f; } - - /// Set this vector to some specified coordinates. - void Set(float32 x_, float32 y_, float32 z_) { x = x_; y = y_; z = z_; } - - /// Negate this vector. - b2Vec3 operator -() const { b2Vec3 v; v.Set(-x, -y, -z); return v; } - - /// Add a vector to this vector. - void operator += (const b2Vec3& v) - { - x += v.x; y += v.y; z += v.z; - } - - /// Subtract a vector from this vector. - void operator -= (const b2Vec3& v) - { - x -= v.x; y -= v.y; z -= v.z; - } - - /// Multiply this vector by a scalar. - void operator *= (float32 s) - { - x *= s; y *= s; z *= s; - } - - float32 x, y, z; -}; - -/// A 2-by-2 matrix. Stored in column-major order. -struct b2Mat22 -{ - /// The default constructor does nothing (for performance). - b2Mat22() {} - - /// Construct this matrix using columns. - b2Mat22(const b2Vec2& c1, const b2Vec2& c2) - { - ex = c1; - ey = c2; - } - - /// Construct this matrix using scalars. - b2Mat22(float32 a11, float32 a12, float32 a21, float32 a22) - { - ex.x = a11; ex.y = a21; - ey.x = a12; ey.y = a22; - } - - /// Initialize this matrix using columns. - void Set(const b2Vec2& c1, const b2Vec2& c2) - { - ex = c1; - ey = c2; - } - - /// Set this to the identity matrix. - void SetIdentity() - { - ex.x = 1.0f; ey.x = 0.0f; - ex.y = 0.0f; ey.y = 1.0f; - } - - /// Set this matrix to all zeros. - void SetZero() - { - ex.x = 0.0f; ey.x = 0.0f; - ex.y = 0.0f; ey.y = 0.0f; - } - - b2Mat22 GetInverse() const - { - float32 a = ex.x, b = ey.x, c = ex.y, d = ey.y; - b2Mat22 B; - float32 det = a * d - b * c; - if (det != 0.0f) - { - det = 1.0f / det; - } - B.ex.x = det * d; B.ey.x = -det * b; - B.ex.y = -det * c; B.ey.y = det * a; - return B; - } - - /// Solve A * x = b, where b is a column vector. This is more efficient - /// than computing the inverse in one-shot cases. - b2Vec2 Solve(const b2Vec2& b) const - { - float32 a11 = ex.x, a12 = ey.x, a21 = ex.y, a22 = ey.y; - float32 det = a11 * a22 - a12 * a21; - if (det != 0.0f) - { - det = 1.0f / det; - } - b2Vec2 x; - x.x = det * (a22 * b.x - a12 * b.y); - x.y = det * (a11 * b.y - a21 * b.x); - return x; - } - - b2Vec2 ex, ey; -}; - -/// A 3-by-3 matrix. Stored in column-major order. -struct b2Mat33 -{ - /// The default constructor does nothing (for performance). - b2Mat33() {} - - /// Construct this matrix using columns. - b2Mat33(const b2Vec3& c1, const b2Vec3& c2, const b2Vec3& c3) - { - ex = c1; - ey = c2; - ez = c3; - } - - /// Set this matrix to all zeros. - void SetZero() - { - ex.SetZero(); - ey.SetZero(); - ez.SetZero(); - } - - /// Solve A * x = b, where b is a column vector. This is more efficient - /// than computing the inverse in one-shot cases. - b2Vec3 Solve33(const b2Vec3& b) const; - - /// Solve A * x = b, where b is a column vector. This is more efficient - /// than computing the inverse in one-shot cases. Solve only the upper - /// 2-by-2 matrix equation. - b2Vec2 Solve22(const b2Vec2& b) const; - - /// Get the inverse of this matrix as a 2-by-2. - /// Returns the zero matrix if singular. - void GetInverse22(b2Mat33* M) const; - - /// Get the symmetric inverse of this matrix as a 3-by-3. - /// Returns the zero matrix if singular. - void GetSymInverse33(b2Mat33* M) const; - - b2Vec3 ex, ey, ez; -}; - -/// Rotation -struct b2Rot -{ - b2Rot() {} - - /// Initialize from an angle in radians - explicit b2Rot(float32 angle) - { - /// TODO_ERIN optimize - s = sinf(angle); - c = cosf(angle); - } - - /// Set using an angle in radians. - void Set(float32 angle) - { - /// TODO_ERIN optimize - s = sinf(angle); - c = cosf(angle); - } - - /// Set to the identity rotation - void SetIdentity() - { - s = 0.0f; - c = 1.0f; - } - - /// Get the angle in radians - float32 GetAngle() const - { - return b2Atan2(s, c); - } - - /// Get the x-axis - b2Vec2 GetXAxis() const - { - return b2Vec2(c, s); - } - - /// Get the u-axis - b2Vec2 GetYAxis() const - { - return b2Vec2(-s, c); - } - - /// Sine and cosine - float32 s, c; -}; - -/// A transform contains translation and rotation. It is used to represent -/// the position and orientation of rigid frames. -struct b2Transform -{ - /// The default constructor does nothing. - b2Transform() {} - - /// Initialize using a position vector and a rotation. - b2Transform(const b2Vec2& position, const b2Rot& rotation) : p(position), q(rotation) {} - - /// Set this to the identity transform. - void SetIdentity() - { - p.SetZero(); - q.SetIdentity(); - } - - /// Set this based on the position and angle. - void Set(const b2Vec2& position, float32 angle) - { - p = position; - q.Set(angle); - } - - b2Vec2 p; - b2Rot q; -}; - -/// This describes the motion of a body/shape for TOI computation. -/// Shapes are defined with respect to the body origin, which may -/// no coincide with the center of mass. However, to support dynamics -/// we must interpolate the center of mass position. -struct b2Sweep -{ - /// Get the interpolated transform at a specific time. - /// @param beta is a factor in [0,1], where 0 indicates alpha0. - void GetTransform(b2Transform* xfb, float32 beta) const; - - /// Advance the sweep forward, yielding a new initial state. - /// @param alpha the new initial time. - void Advance(float32 alpha); - - /// Normalize the angles. - void Normalize(); - - b2Vec2 localCenter; ///< local center of mass position - b2Vec2 c0, c; ///< center world positions - float32 a0, a; ///< world angles - - /// Fraction of the current time step in the range [0,1] - /// c0 and a0 are the positions at alpha0. - float32 alpha0; -}; - -/// Useful constant -extern const b2Vec2 b2Vec2_zero; - -/// Perform the dot product on two vectors. -inline float32 b2Dot(const b2Vec2& a, const b2Vec2& b) -{ - return a.x * b.x + a.y * b.y; -} - -/// Perform the cross product on two vectors. In 2D this produces a scalar. -inline float32 b2Cross(const b2Vec2& a, const b2Vec2& b) -{ - return a.x * b.y - a.y * b.x; -} - -/// Perform the cross product on a vector and a scalar. In 2D this produces -/// a vector. -inline b2Vec2 b2Cross(const b2Vec2& a, float32 s) -{ - return b2Vec2(s * a.y, -s * a.x); -} - -/// Perform the cross product on a scalar and a vector. In 2D this produces -/// a vector. -inline b2Vec2 b2Cross(float32 s, const b2Vec2& a) -{ - return b2Vec2(-s * a.y, s * a.x); -} - -/// Multiply a matrix times a vector. If a rotation matrix is provided, -/// then this transforms the vector from one frame to another. -inline b2Vec2 b2Mul(const b2Mat22& A, const b2Vec2& v) -{ - return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y); -} - -/// Multiply a matrix transpose times a vector. If a rotation matrix is provided, -/// then this transforms the vector from one frame to another (inverse transform). -inline b2Vec2 b2MulT(const b2Mat22& A, const b2Vec2& v) -{ - return b2Vec2(b2Dot(v, A.ex), b2Dot(v, A.ey)); -} - -/// Add two vectors component-wise. -inline b2Vec2 operator + (const b2Vec2& a, const b2Vec2& b) -{ - return b2Vec2(a.x + b.x, a.y + b.y); -} - -/// Subtract two vectors component-wise. -inline b2Vec2 operator - (const b2Vec2& a, const b2Vec2& b) -{ - return b2Vec2(a.x - b.x, a.y - b.y); -} - -inline b2Vec2 operator * (float32 s, const b2Vec2& a) -{ - return b2Vec2(s * a.x, s * a.y); -} - -inline bool operator == (const b2Vec2& a, const b2Vec2& b) -{ - return a.x == b.x && a.y == b.y; -} - -inline float32 b2Distance(const b2Vec2& a, const b2Vec2& b) -{ - b2Vec2 c = a - b; - return c.Length(); -} - -inline float32 b2DistanceSquared(const b2Vec2& a, const b2Vec2& b) -{ - b2Vec2 c = a - b; - return b2Dot(c, c); -} - -inline b2Vec3 operator * (float32 s, const b2Vec3& a) -{ - return b2Vec3(s * a.x, s * a.y, s * a.z); -} - -/// Add two vectors component-wise. -inline b2Vec3 operator + (const b2Vec3& a, const b2Vec3& b) -{ - return b2Vec3(a.x + b.x, a.y + b.y, a.z + b.z); -} - -/// Subtract two vectors component-wise. -inline b2Vec3 operator - (const b2Vec3& a, const b2Vec3& b) -{ - return b2Vec3(a.x - b.x, a.y - b.y, a.z - b.z); -} - -/// Perform the dot product on two vectors. -inline float32 b2Dot(const b2Vec3& a, const b2Vec3& b) -{ - return a.x * b.x + a.y * b.y + a.z * b.z; -} - -/// Perform the cross product on two vectors. -inline b2Vec3 b2Cross(const b2Vec3& a, const b2Vec3& b) -{ - return b2Vec3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); -} - -inline b2Mat22 operator + (const b2Mat22& A, const b2Mat22& B) -{ - return b2Mat22(A.ex + B.ex, A.ey + B.ey); -} - -// A * B -inline b2Mat22 b2Mul(const b2Mat22& A, const b2Mat22& B) -{ - return b2Mat22(b2Mul(A, B.ex), b2Mul(A, B.ey)); -} - -// A^T * B -inline b2Mat22 b2MulT(const b2Mat22& A, const b2Mat22& B) -{ - b2Vec2 c1(b2Dot(A.ex, B.ex), b2Dot(A.ey, B.ex)); - b2Vec2 c2(b2Dot(A.ex, B.ey), b2Dot(A.ey, B.ey)); - return b2Mat22(c1, c2); -} - -/// Multiply a matrix times a vector. -inline b2Vec3 b2Mul(const b2Mat33& A, const b2Vec3& v) -{ - return v.x * A.ex + v.y * A.ey + v.z * A.ez; -} - -/// Multiply a matrix times a vector. -inline b2Vec2 b2Mul22(const b2Mat33& A, const b2Vec2& v) -{ - return b2Vec2(A.ex.x * v.x + A.ey.x * v.y, A.ex.y * v.x + A.ey.y * v.y); -} - -/// Multiply two rotations: q * r -inline b2Rot b2Mul(const b2Rot& q, const b2Rot& r) -{ - // [qc -qs] * [rc -rs] = [qc*rc-qs*rs -qc*rs-qs*rc] - // [qs qc] [rs rc] [qs*rc+qc*rs -qs*rs+qc*rc] - // s = qs * rc + qc * rs - // c = qc * rc - qs * rs - b2Rot qr; - qr.s = q.s * r.c + q.c * r.s; - qr.c = q.c * r.c - q.s * r.s; - return qr; -} - -/// Transpose multiply two rotations: qT * r -inline b2Rot b2MulT(const b2Rot& q, const b2Rot& r) -{ - // [ qc qs] * [rc -rs] = [qc*rc+qs*rs -qc*rs+qs*rc] - // [-qs qc] [rs rc] [-qs*rc+qc*rs qs*rs+qc*rc] - // s = qc * rs - qs * rc - // c = qc * rc + qs * rs - b2Rot qr; - qr.s = q.c * r.s - q.s * r.c; - qr.c = q.c * r.c + q.s * r.s; - return qr; -} - -/// Rotate a vector -inline b2Vec2 b2Mul(const b2Rot& q, const b2Vec2& v) -{ - return b2Vec2(q.c * v.x - q.s * v.y, q.s * v.x + q.c * v.y); -} - -/// Inverse rotate a vector -inline b2Vec2 b2MulT(const b2Rot& q, const b2Vec2& v) -{ - return b2Vec2(q.c * v.x + q.s * v.y, -q.s * v.x + q.c * v.y); -} - -inline b2Vec2 b2Mul(const b2Transform& T, const b2Vec2& v) -{ - float32 x = (T.q.c * v.x - T.q.s * v.y) + T.p.x; - float32 y = (T.q.s * v.x + T.q.c * v.y) + T.p.y; - - return b2Vec2(x, y); -} - -inline b2Vec2 b2MulT(const b2Transform& T, const b2Vec2& v) -{ - float32 px = v.x - T.p.x; - float32 py = v.y - T.p.y; - float32 x = (T.q.c * px + T.q.s * py); - float32 y = (-T.q.s * px + T.q.c * py); - - return b2Vec2(x, y); -} - -// v2 = A.q.Rot(B.q.Rot(v1) + B.p) + A.p -// = (A.q * B.q).Rot(v1) + A.q.Rot(B.p) + A.p -inline b2Transform b2Mul(const b2Transform& A, const b2Transform& B) -{ - b2Transform C; - C.q = b2Mul(A.q, B.q); - C.p = b2Mul(A.q, B.p) + A.p; - return C; -} - -// v2 = A.q' * (B.q * v1 + B.p - A.p) -// = A.q' * B.q * v1 + A.q' * (B.p - A.p) -inline b2Transform b2MulT(const b2Transform& A, const b2Transform& B) -{ - b2Transform C; - C.q = b2MulT(A.q, B.q); - C.p = b2MulT(A.q, B.p - A.p); - return C; -} - -template -inline T b2Abs(T a) -{ - return a > T(0) ? a : -a; -} - -inline b2Vec2 b2Abs(const b2Vec2& a) -{ - return b2Vec2(b2Abs(a.x), b2Abs(a.y)); -} - -inline b2Mat22 b2Abs(const b2Mat22& A) -{ - return b2Mat22(b2Abs(A.ex), b2Abs(A.ey)); -} - -template -inline T b2Min(T a, T b) -{ - return a < b ? a : b; -} - -inline b2Vec2 b2Min(const b2Vec2& a, const b2Vec2& b) -{ - return b2Vec2(b2Min(a.x, b.x), b2Min(a.y, b.y)); -} - -template -inline T b2Max(T a, T b) -{ - return a > b ? a : b; -} - -inline b2Vec2 b2Max(const b2Vec2& a, const b2Vec2& b) -{ - return b2Vec2(b2Max(a.x, b.x), b2Max(a.y, b.y)); -} - -template -inline T b2Clamp(T a, T low, T high) -{ - return b2Max(low, b2Min(a, high)); -} - -inline b2Vec2 b2Clamp(const b2Vec2& a, const b2Vec2& low, const b2Vec2& high) -{ - return b2Max(low, b2Min(a, high)); -} - -template inline void b2Swap(T& a, T& b) -{ - T tmp = a; - a = b; - b = tmp; -} - -/// "Next Largest Power of 2 -/// Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm -/// that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with -/// the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next -/// largest power of 2. For a 32-bit value:" -inline uint32 b2NextPowerOfTwo(uint32 x) -{ - x |= (x >> 1); - x |= (x >> 2); - x |= (x >> 4); - x |= (x >> 8); - x |= (x >> 16); - return x + 1; -} - -inline bool b2IsPowerOfTwo(uint32 x) -{ - bool result = x > 0 && (x & (x - 1)) == 0; - return result; -} - -inline void b2Sweep::GetTransform(b2Transform* xf, float32 beta) const -{ - xf->p = (1.0f - beta) * c0 + beta * c; - float32 angle = (1.0f - beta) * a0 + beta * a; - xf->q.Set(angle); - - // Shift to origin - xf->p -= b2Mul(xf->q, localCenter); -} - -inline void b2Sweep::Advance(float32 alpha) -{ - b2Assert(alpha0 < 1.0f); - float32 beta = (alpha - alpha0) / (1.0f - alpha0); - c0 += beta * (c - c0); - a0 += beta * (a - a0); - alpha0 = alpha; -} - -/// Normalize an angle in radians to be between -pi and pi -inline void b2Sweep::Normalize() -{ - float32 twoPi = 2.0f * b2_pi; - float32 d = twoPi * floorf(a0 / twoPi); - a0 -= d; - a -= d; -} - -#endif diff --git a/sources/Box2D/Common/b2Settings.cpp b/sources/Box2D/Common/b2Settings.cpp deleted file mode 100755 index 25ce9491..00000000 --- a/sources/Box2D/Common/b2Settings.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include - -b2Version b2_version = {2, 3, 1}; - -// Memory allocators. Modify these to use your own allocator. -void* b2Alloc(int32 size) -{ - return malloc(size); -} - -void b2Free(void* mem) -{ - free(mem); -} - -// You can modify this to use your logging facility. -void b2Log(const char* string, ...) -{ - va_list args; - va_start(args, string); - vprintf(string, args); - va_end(args); -} diff --git a/sources/Box2D/Common/b2Settings.h b/sources/Box2D/Common/b2Settings.h deleted file mode 100755 index 617fdc88..00000000 --- a/sources/Box2D/Common/b2Settings.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_SETTINGS_H -#define B2_SETTINGS_H - -#include -#include -#include - -#define B2_NOT_USED(x) ((void)(x)) -#define b2Assert(A) assert(A) - -typedef signed char int8; -typedef signed short int16; -typedef signed int int32; -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; -typedef float float32; -typedef double float64; - -#define b2_maxFloat FLT_MAX -#define b2_epsilon FLT_EPSILON -#define b2_pi 3.14159265359f - -/// @file -/// Global tuning constants based on meters-kilograms-seconds (MKS) units. -/// - -// Collision - -/// The maximum number of contact points between two convex shapes. Do -/// not change this value. -#define b2_maxManifoldPoints 2 - -/// The maximum number of vertices on a convex polygon. You cannot increase -/// this too much because b2BlockAllocator has a maximum object size. -#define b2_maxPolygonVertices 8 - -/// This is used to fatten AABBs in the dynamic tree. This allows proxies -/// to move by a small amount without triggering a tree adjustment. -/// This is in meters. -#define b2_aabbExtension 0.1f - -/// This is used to fatten AABBs in the dynamic tree. This is used to predict -/// the future position based on the current displacement. -/// This is a dimensionless multiplier. -#define b2_aabbMultiplier 2.0f - -/// A small length used as a collision and constraint tolerance. Usually it is -/// chosen to be numerically significant, but visually insignificant. -#define b2_linearSlop 0.005f - -/// A small angle used as a collision and constraint tolerance. Usually it is -/// chosen to be numerically significant, but visually insignificant. -#define b2_angularSlop (2.0f / 180.0f * b2_pi) - -/// The radius of the polygon/edge shape skin. This should not be modified. Making -/// this smaller means polygons will have an insufficient buffer for continuous collision. -/// Making it larger may create artifacts for vertex collision. -#define b2_polygonRadius (2.0f * b2_linearSlop) - -/// Maximum number of sub-steps per contact in continuous physics simulation. -#define b2_maxSubSteps 8 - - -// Dynamics - -/// Maximum number of contacts to be handled to solve a TOI impact. -#define b2_maxTOIContacts 32 - -/// A velocity threshold for elastic collisions. Any collision with a relative linear -/// velocity below this threshold will be treated as inelastic. -#define b2_velocityThreshold 1.0f - -/// The maximum linear position correction used when solving constraints. This helps to -/// prevent overshoot. -#define b2_maxLinearCorrection 0.2f - -/// The maximum angular position correction used when solving constraints. This helps to -/// prevent overshoot. -#define b2_maxAngularCorrection (8.0f / 180.0f * b2_pi) - -/// The maximum linear velocity of a body. This limit is very large and is used -/// to prevent numerical problems. You shouldn't need to adjust this. -#define b2_maxTranslation 2.0f -#define b2_maxTranslationSquared (b2_maxTranslation * b2_maxTranslation) - -/// The maximum angular velocity of a body. This limit is very large and is used -/// to prevent numerical problems. You shouldn't need to adjust this. -#define b2_maxRotation (0.5f * b2_pi) -#define b2_maxRotationSquared (b2_maxRotation * b2_maxRotation) - -/// This scale factor controls how fast overlap is resolved. Ideally this would be 1 so -/// that overlap is removed in one time step. However using values close to 1 often lead -/// to overshoot. -#define b2_baumgarte 0.2f -#define b2_toiBaugarte 0.75f - - -// Sleep - -/// The time that a body must be still before it will go to sleep. -#define b2_timeToSleep 0.5f - -/// A body cannot sleep if its linear velocity is above this tolerance. -#define b2_linearSleepTolerance 0.01f - -/// A body cannot sleep if its angular velocity is above this tolerance. -#define b2_angularSleepTolerance (2.0f / 180.0f * b2_pi) - -// Memory Allocation - -/// Implement this function to use your own memory allocator. -void* b2Alloc(int32 size); - -/// If you implement b2Alloc, you should also implement this function. -void b2Free(void* mem); - -/// Logging function. -void b2Log(const char* string, ...); - -/// Version numbering scheme. -/// See http://en.wikipedia.org/wiki/Software_versioning -struct b2Version -{ - int32 major; ///< significant changes - int32 minor; ///< incremental changes - int32 revision; ///< bug fixes -}; - -/// Current version. -extern b2Version b2_version; - -#endif diff --git a/sources/Box2D/Common/b2StackAllocator.cpp b/sources/Box2D/Common/b2StackAllocator.cpp deleted file mode 100755 index 4a862835..00000000 --- a/sources/Box2D/Common/b2StackAllocator.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -b2StackAllocator::b2StackAllocator() -{ - m_index = 0; - m_allocation = 0; - m_maxAllocation = 0; - m_entryCount = 0; -} - -b2StackAllocator::~b2StackAllocator() -{ - b2Assert(m_index == 0); - b2Assert(m_entryCount == 0); -} - -void* b2StackAllocator::Allocate(int32 size) -{ - b2Assert(m_entryCount < b2_maxStackEntries); - - b2StackEntry* entry = m_entries + m_entryCount; - entry->size = size; - if (m_index + size > b2_stackSize) - { - entry->data = (char*)b2Alloc(size); - entry->usedMalloc = true; - } - else - { - entry->data = m_data + m_index; - entry->usedMalloc = false; - m_index += size; - } - - m_allocation += size; - m_maxAllocation = b2Max(m_maxAllocation, m_allocation); - ++m_entryCount; - - return entry->data; -} - -void b2StackAllocator::Free(void* p) -{ - b2Assert(m_entryCount > 0); - b2StackEntry* entry = m_entries + m_entryCount - 1; - b2Assert(p == entry->data); - if (entry->usedMalloc) - { - b2Free(p); - } - else - { - m_index -= entry->size; - } - m_allocation -= entry->size; - --m_entryCount; - - p = NULL; -} - -int32 b2StackAllocator::GetMaxAllocation() const -{ - return m_maxAllocation; -} diff --git a/sources/Box2D/Common/b2StackAllocator.h b/sources/Box2D/Common/b2StackAllocator.h deleted file mode 100755 index 796c51df..00000000 --- a/sources/Box2D/Common/b2StackAllocator.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_STACK_ALLOCATOR_H -#define B2_STACK_ALLOCATOR_H - -#include - -const int32 b2_stackSize = 100 * 1024; // 100k -const int32 b2_maxStackEntries = 32; - -struct b2StackEntry -{ - char* data; - int32 size; - bool usedMalloc; -}; - -// This is a stack allocator used for fast per step allocations. -// You must nest allocate/free pairs. The code will assert -// if you try to interleave multiple allocate/free pairs. -class b2StackAllocator -{ -public: - b2StackAllocator(); - ~b2StackAllocator(); - - void* Allocate(int32 size); - void Free(void* p); - - int32 GetMaxAllocation() const; - -private: - - char m_data[b2_stackSize]; - int32 m_index; - - int32 m_allocation; - int32 m_maxAllocation; - - b2StackEntry m_entries[b2_maxStackEntries]; - int32 m_entryCount; -}; - -#endif diff --git a/sources/Box2D/Common/b2Timer.cpp b/sources/Box2D/Common/b2Timer.cpp deleted file mode 100755 index 44dc5cea..00000000 --- a/sources/Box2D/Common/b2Timer.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 - -#if defined(_WIN32) - -float64 b2Timer::s_invFrequency = 0.0f; - -#define WIN32_LEAN_AND_MEAN -#include - -b2Timer::b2Timer() -{ - LARGE_INTEGER largeInteger; - - if (s_invFrequency == 0.0f) - { - QueryPerformanceFrequency(&largeInteger); - s_invFrequency = float64(largeInteger.QuadPart); - if (s_invFrequency > 0.0f) - { - s_invFrequency = 1000.0f / s_invFrequency; - } - } - - QueryPerformanceCounter(&largeInteger); - m_start = float64(largeInteger.QuadPart); -} - -void b2Timer::Reset() -{ - LARGE_INTEGER largeInteger; - QueryPerformanceCounter(&largeInteger); - m_start = float64(largeInteger.QuadPart); -} - -float32 b2Timer::GetMilliseconds() const -{ - LARGE_INTEGER largeInteger; - QueryPerformanceCounter(&largeInteger); - float64 count = float64(largeInteger.QuadPart); - float32 ms = float32(s_invFrequency * (count - m_start)); - return ms; -} - -#elif defined(__linux__) || defined (__APPLE__) - -#include - -b2Timer::b2Timer() -{ - Reset(); -} - -void b2Timer::Reset() -{ - timeval t; - gettimeofday(&t, 0); - m_start_sec = t.tv_sec; - m_start_usec = t.tv_usec; -} - -float32 b2Timer::GetMilliseconds() const -{ - timeval t; - gettimeofday(&t, 0); - return 1000.0f * (t.tv_sec - m_start_sec) + 0.001f * (t.tv_usec - m_start_usec); -} - -#else - -b2Timer::b2Timer() -{ -} - -void b2Timer::Reset() -{ -} - -float32 b2Timer::GetMilliseconds() const -{ - return 0.0f; -} - -#endif diff --git a/sources/Box2D/Common/b2Timer.h b/sources/Box2D/Common/b2Timer.h deleted file mode 100755 index 823404fe..00000000 --- a/sources/Box2D/Common/b2Timer.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_TIMER_H -#define B2_TIMER_H - -#include - -/// Timer for profiling. This has platform specific code and may -/// not work on every platform. -class b2Timer -{ -public: - - /// Constructor - b2Timer(); - - /// Reset the timer. - void Reset(); - - /// Get the time since construction or the last reset. - float32 GetMilliseconds() const; - -private: - -#if defined(_WIN32) - float64 m_start; - static float64 s_invFrequency; -#elif defined(__linux__) || defined (__APPLE__) - unsigned long m_start_sec; - unsigned long m_start_usec; -#endif -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp b/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp deleted file mode 100755 index 5e2f0f05..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include - -#include - -b2Contact* b2ChainAndCircleContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2ChainAndCircleContact)); - return new (mem) b2ChainAndCircleContact(fixtureA, indexA, fixtureB, indexB); -} - -void b2ChainAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2ChainAndCircleContact*)contact)->~b2ChainAndCircleContact(); - allocator->Free(contact, sizeof(b2ChainAndCircleContact)); -} - -b2ChainAndCircleContact::b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB) -: b2Contact(fixtureA, indexA, fixtureB, indexB) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_chain); - b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); -} - -void b2ChainAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape(); - b2EdgeShape edge; - chain->GetChildEdge(&edge, m_indexA); - b2CollideEdgeAndCircle( manifold, &edge, xfA, - (b2CircleShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h b/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h deleted file mode 100755 index 2dad0b64..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CHAIN_AND_CIRCLE_CONTACT_H -#define B2_CHAIN_AND_CIRCLE_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2ChainAndCircleContact : public b2Contact -{ -public: - static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2ChainAndCircleContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); - ~b2ChainAndCircleContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp b/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp deleted file mode 100755 index a4a99b8c..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include - -#include - -b2Contact* b2ChainAndPolygonContact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2ChainAndPolygonContact)); - return new (mem) b2ChainAndPolygonContact(fixtureA, indexA, fixtureB, indexB); -} - -void b2ChainAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2ChainAndPolygonContact*)contact)->~b2ChainAndPolygonContact(); - allocator->Free(contact, sizeof(b2ChainAndPolygonContact)); -} - -b2ChainAndPolygonContact::b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB) -: b2Contact(fixtureA, indexA, fixtureB, indexB) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_chain); - b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); -} - -void b2ChainAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2ChainShape* chain = (b2ChainShape*)m_fixtureA->GetShape(); - b2EdgeShape edge; - chain->GetChildEdge(&edge, m_indexA); - b2CollideEdgeAndPolygon( manifold, &edge, xfA, - (b2PolygonShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h b/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h deleted file mode 100755 index 8f30ee86..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CHAIN_AND_POLYGON_CONTACT_H -#define B2_CHAIN_AND_POLYGON_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2ChainAndPolygonContact : public b2Contact -{ -public: - static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2ChainAndPolygonContact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); - ~b2ChainAndPolygonContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2CircleContact.cpp b/sources/Box2D/Dynamics/Contacts/b2CircleContact.cpp deleted file mode 100755 index 23b98a9f..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2CircleContact.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include - -#include - -b2Contact* b2CircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2CircleContact)); - return new (mem) b2CircleContact(fixtureA, fixtureB); -} - -void b2CircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2CircleContact*)contact)->~b2CircleContact(); - allocator->Free(contact, sizeof(b2CircleContact)); -} - -b2CircleContact::b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) - : b2Contact(fixtureA, 0, fixtureB, 0) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_circle); - b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); -} - -void b2CircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2CollideCircles(manifold, - (b2CircleShape*)m_fixtureA->GetShape(), xfA, - (b2CircleShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2CircleContact.h b/sources/Box2D/Dynamics/Contacts/b2CircleContact.h deleted file mode 100755 index aac1f0bd..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2CircleContact.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CIRCLE_CONTACT_H -#define B2_CIRCLE_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2CircleContact : public b2Contact -{ -public: - static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2CircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); - ~b2CircleContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2Contact.cpp b/sources/Box2D/Dynamics/Contacts/b2Contact.cpp deleted file mode 100755 index 93ed4d5b..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2Contact.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -b2ContactRegister b2Contact::s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount]; -bool b2Contact::s_initialized = false; - -void b2Contact::InitializeRegisters() -{ - AddType(b2CircleContact::Create, b2CircleContact::Destroy, b2Shape::e_circle, b2Shape::e_circle); - AddType(b2PolygonAndCircleContact::Create, b2PolygonAndCircleContact::Destroy, b2Shape::e_polygon, b2Shape::e_circle); - AddType(b2PolygonContact::Create, b2PolygonContact::Destroy, b2Shape::e_polygon, b2Shape::e_polygon); - AddType(b2EdgeAndCircleContact::Create, b2EdgeAndCircleContact::Destroy, b2Shape::e_edge, b2Shape::e_circle); - AddType(b2EdgeAndPolygonContact::Create, b2EdgeAndPolygonContact::Destroy, b2Shape::e_edge, b2Shape::e_polygon); - AddType(b2ChainAndCircleContact::Create, b2ChainAndCircleContact::Destroy, b2Shape::e_chain, b2Shape::e_circle); - AddType(b2ChainAndPolygonContact::Create, b2ChainAndPolygonContact::Destroy, b2Shape::e_chain, b2Shape::e_polygon); -} - -void b2Contact::AddType(b2ContactCreateFcn* createFcn, b2ContactDestroyFcn* destoryFcn, - b2Shape::Type type1, b2Shape::Type type2) -{ - b2Assert(0 <= type1 && type1 < b2Shape::e_typeCount); - b2Assert(0 <= type2 && type2 < b2Shape::e_typeCount); - - s_registers[type1][type2].createFcn = createFcn; - s_registers[type1][type2].destroyFcn = destoryFcn; - s_registers[type1][type2].primary = true; - - if (type1 != type2) - { - s_registers[type2][type1].createFcn = createFcn; - s_registers[type2][type1].destroyFcn = destoryFcn; - s_registers[type2][type1].primary = false; - } -} - -b2Contact* b2Contact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) -{ - if (s_initialized == false) - { - InitializeRegisters(); - s_initialized = true; - } - - b2Shape::Type type1 = fixtureA->GetType(); - b2Shape::Type type2 = fixtureB->GetType(); - - b2Assert(0 <= type1 && type1 < b2Shape::e_typeCount); - b2Assert(0 <= type2 && type2 < b2Shape::e_typeCount); - - b2ContactCreateFcn* createFcn = s_registers[type1][type2].createFcn; - if (createFcn) - { - if (s_registers[type1][type2].primary) - { - return createFcn(fixtureA, indexA, fixtureB, indexB, allocator); - } - else - { - return createFcn(fixtureB, indexB, fixtureA, indexA, allocator); - } - } - else - { - return NULL; - } -} - -void b2Contact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - b2Assert(s_initialized == true); - - b2Fixture* fixtureA = contact->m_fixtureA; - b2Fixture* fixtureB = contact->m_fixtureB; - - if (contact->m_manifold.pointCount > 0 && - fixtureA->IsSensor() == false && - fixtureB->IsSensor() == false) - { - fixtureA->GetBody()->SetAwake(true); - fixtureB->GetBody()->SetAwake(true); - } - - b2Shape::Type typeA = fixtureA->GetType(); - b2Shape::Type typeB = fixtureB->GetType(); - - b2Assert(0 <= typeA && typeB < b2Shape::e_typeCount); - b2Assert(0 <= typeA && typeB < b2Shape::e_typeCount); - - b2NotifyObjectDestroyed(contact, b2ObjectType::CONTACT, typeid(*contact).name()); - b2ContactDestroyFcn* destroyFcn = s_registers[typeA][typeB].destroyFcn; - destroyFcn(contact, allocator); -} - -b2Contact::b2Contact(b2Fixture* fA, int32 indexA, b2Fixture* fB, int32 indexB) -{ - m_flags = e_enabledFlag; - - m_fixtureA = fA; - m_fixtureB = fB; - - m_indexA = indexA; - m_indexB = indexB; - - m_manifold.pointCount = 0; - - m_prev = NULL; - m_next = NULL; - - m_nodeA.contact = NULL; - m_nodeA.prev = NULL; - m_nodeA.next = NULL; - m_nodeA.other = NULL; - - m_nodeB.contact = NULL; - m_nodeB.prev = NULL; - m_nodeB.next = NULL; - m_nodeB.other = NULL; - - m_toiCount = 0; - - m_friction = b2MixFriction(m_fixtureA->m_friction, m_fixtureB->m_friction); - m_restitution = b2MixRestitution(m_fixtureA->m_restitution, m_fixtureB->m_restitution); - - m_tangentSpeed = 0.0f; -} - -// Update the contact manifold and touching status. -// Note: do not assume the fixture AABBs are overlapping or are valid. -void b2Contact::Update(b2ContactListener* listener) -{ - b2Manifold oldManifold = m_manifold; - - // Re-enable this contact. - m_flags |= e_enabledFlag; - - bool touching = false; - bool wasTouching = (m_flags & e_touchingFlag) == e_touchingFlag; - - bool sensorA = m_fixtureA->IsSensor(); - bool sensorB = m_fixtureB->IsSensor(); - bool sensor = sensorA || sensorB; - - b2Body* bodyA = m_fixtureA->GetBody(); - b2Body* bodyB = m_fixtureB->GetBody(); - const b2Transform& xfA = bodyA->GetTransform(); - const b2Transform& xfB = bodyB->GetTransform(); - - // Is this contact a sensor? - if (sensor) - { - const b2Shape* shapeA = m_fixtureA->GetShape(); - const b2Shape* shapeB = m_fixtureB->GetShape(); - touching = b2TestOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB); - - // Sensors don't generate manifolds. - m_manifold.pointCount = 0; - } - else - { - Evaluate(&m_manifold, xfA, xfB); - touching = m_manifold.pointCount > 0; - - // Match old contact ids to new contact ids and copy the - // stored impulses to warm start the solver. - for (int32 i = 0; i < m_manifold.pointCount; ++i) - { - b2ManifoldPoint* mp2 = m_manifold.points + i; - mp2->normalImpulse = 0.0f; - mp2->tangentImpulse = 0.0f; - b2ContactID id2 = mp2->id; - - for (int32 j = 0; j < oldManifold.pointCount; ++j) - { - b2ManifoldPoint* mp1 = oldManifold.points + j; - - if (mp1->id.key == id2.key) - { - mp2->normalImpulse = mp1->normalImpulse; - mp2->tangentImpulse = mp1->tangentImpulse; - break; - } - } - } - - if (touching != wasTouching) - { - bodyA->SetAwake(true); - bodyB->SetAwake(true); - } - } - - if (touching) - { - m_flags |= e_touchingFlag; - } - else - { - m_flags &= ~e_touchingFlag; - } - - if (wasTouching == false && touching == true && listener) - { - listener->BeginContact(this); - } - - if (wasTouching == true && touching == false && listener) - { - listener->EndContact(this); - } - - if (sensor == false && touching && listener) - { - listener->PreSolve(this, &oldManifold); - } -} diff --git a/sources/Box2D/Dynamics/Contacts/b2Contact.h b/sources/Box2D/Dynamics/Contacts/b2Contact.h deleted file mode 100755 index 347da31e..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2Contact.h +++ /dev/null @@ -1,349 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CONTACT_H -#define B2_CONTACT_H - -#include -#include -#include -#include - -class b2Body; -class b2Contact; -class b2Fixture; -class b2World; -class b2BlockAllocator; -class b2StackAllocator; -class b2ContactListener; - -/// Friction mixing law. The idea is to allow either fixture to drive the restitution to zero. -/// For example, anything slides on ice. -inline float32 b2MixFriction(float32 friction1, float32 friction2) -{ - return b2Sqrt(friction1 * friction2); -} - -/// Restitution mixing law. The idea is allow for anything to bounce off an inelastic surface. -/// For example, a superball bounces on anything. -inline float32 b2MixRestitution(float32 restitution1, float32 restitution2) -{ - return restitution1 > restitution2 ? restitution1 : restitution2; -} - -typedef b2Contact* b2ContactCreateFcn( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, - b2BlockAllocator* allocator); -typedef void b2ContactDestroyFcn(b2Contact* contact, b2BlockAllocator* allocator); - -struct b2ContactRegister -{ - b2ContactCreateFcn* createFcn; - b2ContactDestroyFcn* destroyFcn; - bool primary; -}; - -/// A contact edge is used to connect bodies and contacts together -/// in a contact graph where each body is a node and each contact -/// is an edge. A contact edge belongs to a doubly linked list -/// maintained in each attached body. Each contact has two contact -/// nodes, one for each attached body. -struct b2ContactEdge -{ - b2Body* other; ///< provides quick access to the other body attached. - b2Contact* contact; ///< the contact - b2ContactEdge* prev; ///< the previous contact edge in the body's contact list - b2ContactEdge* next; ///< the next contact edge in the body's contact list -}; - -/// The class manages contact between two shapes. A contact exists for each overlapping -/// AABB in the broad-phase (except if filtered). Therefore a contact object may exist -/// that has no contact points. -class b2Contact -{ -public: - - /// Get the contact manifold. Do not modify the manifold unless you understand the - /// internals of Box2D. - b2Manifold* GetManifold(); - const b2Manifold* GetManifold() const; - - /// Get the world manifold. - void GetWorldManifold(b2WorldManifold* worldManifold) const; - - /// Is this contact touching? - bool IsTouching() const; - - /// Enable/disable this contact. This can be used inside the pre-solve - /// contact listener. The contact is only disabled for the current - /// time step (or sub-step in continuous collisions). - void SetEnabled(bool flag); - - /// Has this contact been disabled? - bool IsEnabled() const; - - /// Get the next contact in the world's contact list. - b2Contact* GetNext(); - const b2Contact* GetNext() const; - - /// Get fixture A in this contact. - b2Fixture* GetFixtureA(); - const b2Fixture* GetFixtureA() const; - - /// Get the child primitive index for fixture A. - int32 GetChildIndexA() const; - - /// Get fixture B in this contact. - b2Fixture* GetFixtureB(); - const b2Fixture* GetFixtureB() const; - - /// Get the child primitive index for fixture B. - int32 GetChildIndexB() const; - - /// Override the default friction mixture. You can call this in b2ContactListener::PreSolve. - /// This value persists until set or reset. - void SetFriction(float32 friction); - - /// Get the friction. - float32 GetFriction() const; - - /// Reset the friction mixture to the default value. - void ResetFriction(); - - /// Override the default restitution mixture. You can call this in b2ContactListener::PreSolve. - /// The value persists until you set or reset. - void SetRestitution(float32 restitution); - - /// Get the restitution. - float32 GetRestitution() const; - - /// Reset the restitution to the default value. - void ResetRestitution(); - - /// Set the desired tangent speed for a conveyor belt behavior. In meters per second. - void SetTangentSpeed(float32 speed); - - /// Get the desired tangent speed. In meters per second. - float32 GetTangentSpeed() const; - - /// Evaluate this contact with your own manifold and transforms. - virtual void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) = 0; - -protected: - friend class b2ContactManager; - friend class b2World; - friend class b2ContactSolver; - friend class b2Body; - friend class b2Fixture; - - // Flags stored in m_flags - enum - { - // Used when crawling contact graph when forming islands. - e_islandFlag = 0x0001, - - // Set when the shapes are touching. - e_touchingFlag = 0x0002, - - // This contact can be disabled (by user) - e_enabledFlag = 0x0004, - - // This contact needs filtering because a fixture filter was changed. - e_filterFlag = 0x0008, - - // This bullet contact had a TOI event - e_bulletHitFlag = 0x0010, - - // This contact has a valid TOI in m_toi - e_toiFlag = 0x0020 - }; - - /// Flag this contact for filtering. Filtering will occur the next time step. - void FlagForFiltering(); - - static void AddType(b2ContactCreateFcn* createFcn, b2ContactDestroyFcn* destroyFcn, - b2Shape::Type typeA, b2Shape::Type typeB); - static void InitializeRegisters(); - static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2Shape::Type typeA, b2Shape::Type typeB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2Contact() : m_fixtureA(NULL), m_fixtureB(NULL) {} - b2Contact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB); - virtual ~b2Contact() {} - - void Update(b2ContactListener* listener); - - static b2ContactRegister s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount]; - static bool s_initialized; - - uint32 m_flags; - - // World pool and list pointers. - b2Contact* m_prev; - b2Contact* m_next; - - // Nodes for connecting bodies. - b2ContactEdge m_nodeA; - b2ContactEdge m_nodeB; - - b2Fixture* m_fixtureA; - b2Fixture* m_fixtureB; - - int32 m_indexA; - int32 m_indexB; - - b2Manifold m_manifold; - - int32 m_toiCount; - float32 m_toi; - - float32 m_friction; - float32 m_restitution; - - float32 m_tangentSpeed; -}; - -inline b2Manifold* b2Contact::GetManifold() -{ - return &m_manifold; -} - -inline const b2Manifold* b2Contact::GetManifold() const -{ - return &m_manifold; -} - -inline void b2Contact::GetWorldManifold(b2WorldManifold* worldManifold) const -{ - const b2Body* bodyA = m_fixtureA->GetBody(); - const b2Body* bodyB = m_fixtureB->GetBody(); - const b2Shape* shapeA = m_fixtureA->GetShape(); - const b2Shape* shapeB = m_fixtureB->GetShape(); - - worldManifold->Initialize(&m_manifold, bodyA->GetTransform(), shapeA->m_radius, bodyB->GetTransform(), shapeB->m_radius); -} - -inline void b2Contact::SetEnabled(bool flag) -{ - if (flag) - { - m_flags |= e_enabledFlag; - } - else - { - m_flags &= ~e_enabledFlag; - } -} - -inline bool b2Contact::IsEnabled() const -{ - return (m_flags & e_enabledFlag) == e_enabledFlag; -} - -inline bool b2Contact::IsTouching() const -{ - return (m_flags & e_touchingFlag) == e_touchingFlag; -} - -inline b2Contact* b2Contact::GetNext() -{ - return m_next; -} - -inline const b2Contact* b2Contact::GetNext() const -{ - return m_next; -} - -inline b2Fixture* b2Contact::GetFixtureA() -{ - return m_fixtureA; -} - -inline const b2Fixture* b2Contact::GetFixtureA() const -{ - return m_fixtureA; -} - -inline b2Fixture* b2Contact::GetFixtureB() -{ - return m_fixtureB; -} - -inline int32 b2Contact::GetChildIndexA() const -{ - return m_indexA; -} - -inline const b2Fixture* b2Contact::GetFixtureB() const -{ - return m_fixtureB; -} - -inline int32 b2Contact::GetChildIndexB() const -{ - return m_indexB; -} - -inline void b2Contact::FlagForFiltering() -{ - m_flags |= e_filterFlag; -} - -inline void b2Contact::SetFriction(float32 friction) -{ - m_friction = friction; -} - -inline float32 b2Contact::GetFriction() const -{ - return m_friction; -} - -inline void b2Contact::ResetFriction() -{ - m_friction = b2MixFriction(m_fixtureA->m_friction, m_fixtureB->m_friction); -} - -inline void b2Contact::SetRestitution(float32 restitution) -{ - m_restitution = restitution; -} - -inline float32 b2Contact::GetRestitution() const -{ - return m_restitution; -} - -inline void b2Contact::ResetRestitution() -{ - m_restitution = b2MixRestitution(m_fixtureA->m_restitution, m_fixtureB->m_restitution); -} - -inline void b2Contact::SetTangentSpeed(float32 speed) -{ - m_tangentSpeed = speed; -} - -inline float32 b2Contact::GetTangentSpeed() const -{ - return m_tangentSpeed; -} - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2ContactSolver.cpp b/sources/Box2D/Dynamics/Contacts/b2ContactSolver.cpp deleted file mode 100755 index 06cff524..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2ContactSolver.cpp +++ /dev/null @@ -1,838 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 - -#include -#include -#include -#include -#include - -#define B2_DEBUG_SOLVER 0 - -bool g_blockSolve = true; - -struct b2ContactPositionConstraint -{ - b2Vec2 localPoints[b2_maxManifoldPoints]; - b2Vec2 localNormal; - b2Vec2 localPoint; - int32 indexA; - int32 indexB; - float32 invMassA, invMassB; - b2Vec2 localCenterA, localCenterB; - float32 invIA, invIB; - b2Manifold::Type type; - float32 radiusA, radiusB; - int32 pointCount; -}; - -b2ContactSolver::b2ContactSolver(b2ContactSolverDef* def) -{ - m_step = def->step; - m_allocator = def->allocator; - m_count = def->count; - m_positionConstraints = (b2ContactPositionConstraint*)m_allocator->Allocate(m_count * sizeof(b2ContactPositionConstraint)); - m_velocityConstraints = (b2ContactVelocityConstraint*)m_allocator->Allocate(m_count * sizeof(b2ContactVelocityConstraint)); - m_positions = def->positions; - m_velocities = def->velocities; - m_contacts = def->contacts; - - // Initialize position independent portions of the constraints. - for (int32 i = 0; i < m_count; ++i) - { - b2Contact* contact = m_contacts[i]; - - b2Fixture* fixtureA = contact->m_fixtureA; - b2Fixture* fixtureB = contact->m_fixtureB; - b2Shape* shapeA = fixtureA->GetShape(); - b2Shape* shapeB = fixtureB->GetShape(); - float32 radiusA = shapeA->m_radius; - float32 radiusB = shapeB->m_radius; - b2Body* bodyA = fixtureA->GetBody(); - b2Body* bodyB = fixtureB->GetBody(); - b2Manifold* manifold = contact->GetManifold(); - - int32 pointCount = manifold->pointCount; - b2Assert(pointCount > 0); - - b2ContactVelocityConstraint* vc = m_velocityConstraints + i; - vc->friction = contact->m_friction; - vc->restitution = contact->m_restitution; - vc->tangentSpeed = contact->m_tangentSpeed; - vc->indexA = bodyA->m_islandIndex; - vc->indexB = bodyB->m_islandIndex; - vc->invMassA = bodyA->m_invMass; - vc->invMassB = bodyB->m_invMass; - vc->invIA = bodyA->m_invI; - vc->invIB = bodyB->m_invI; - vc->contactIndex = i; - vc->pointCount = pointCount; - vc->K.SetZero(); - vc->normalMass.SetZero(); - - b2ContactPositionConstraint* pc = m_positionConstraints + i; - pc->indexA = bodyA->m_islandIndex; - pc->indexB = bodyB->m_islandIndex; - pc->invMassA = bodyA->m_invMass; - pc->invMassB = bodyB->m_invMass; - pc->localCenterA = bodyA->m_sweep.localCenter; - pc->localCenterB = bodyB->m_sweep.localCenter; - pc->invIA = bodyA->m_invI; - pc->invIB = bodyB->m_invI; - pc->localNormal = manifold->localNormal; - pc->localPoint = manifold->localPoint; - pc->pointCount = pointCount; - pc->radiusA = radiusA; - pc->radiusB = radiusB; - pc->type = manifold->type; - - for (int32 j = 0; j < pointCount; ++j) - { - b2ManifoldPoint* cp = manifold->points + j; - b2VelocityConstraintPoint* vcp = vc->points + j; - - if (m_step.warmStarting) - { - vcp->normalImpulse = m_step.dtRatio * cp->normalImpulse; - vcp->tangentImpulse = m_step.dtRatio * cp->tangentImpulse; - } - else - { - vcp->normalImpulse = 0.0f; - vcp->tangentImpulse = 0.0f; - } - - vcp->rA.SetZero(); - vcp->rB.SetZero(); - vcp->normalMass = 0.0f; - vcp->tangentMass = 0.0f; - vcp->velocityBias = 0.0f; - - pc->localPoints[j] = cp->localPoint; - } - } -} - -b2ContactSolver::~b2ContactSolver() -{ - m_allocator->Free(m_velocityConstraints); - m_allocator->Free(m_positionConstraints); -} - -// Initialize position dependent portions of the velocity constraints. -void b2ContactSolver::InitializeVelocityConstraints() -{ - for (int32 i = 0; i < m_count; ++i) - { - b2ContactVelocityConstraint* vc = m_velocityConstraints + i; - b2ContactPositionConstraint* pc = m_positionConstraints + i; - - float32 radiusA = pc->radiusA; - float32 radiusB = pc->radiusB; - b2Manifold* manifold = m_contacts[vc->contactIndex]->GetManifold(); - - int32 indexA = vc->indexA; - int32 indexB = vc->indexB; - - float32 mA = vc->invMassA; - float32 mB = vc->invMassB; - float32 iA = vc->invIA; - float32 iB = vc->invIB; - b2Vec2 localCenterA = pc->localCenterA; - b2Vec2 localCenterB = pc->localCenterB; - - b2Vec2 cA = m_positions[indexA].c; - float32 aA = m_positions[indexA].a; - b2Vec2 vA = m_velocities[indexA].v; - float32 wA = m_velocities[indexA].w; - - b2Vec2 cB = m_positions[indexB].c; - float32 aB = m_positions[indexB].a; - b2Vec2 vB = m_velocities[indexB].v; - float32 wB = m_velocities[indexB].w; - - b2Assert(manifold->pointCount > 0); - - b2Transform xfA, xfB; - xfA.q.Set(aA); - xfB.q.Set(aB); - xfA.p = cA - b2Mul(xfA.q, localCenterA); - xfB.p = cB - b2Mul(xfB.q, localCenterB); - - b2WorldManifold worldManifold; - worldManifold.Initialize(manifold, xfA, radiusA, xfB, radiusB); - - vc->normal = worldManifold.normal; - - int32 pointCount = vc->pointCount; - for (int32 j = 0; j < pointCount; ++j) - { - b2VelocityConstraintPoint* vcp = vc->points + j; - - vcp->rA = worldManifold.points[j] - cA; - vcp->rB = worldManifold.points[j] - cB; - - float32 rnA = b2Cross(vcp->rA, vc->normal); - float32 rnB = b2Cross(vcp->rB, vc->normal); - - float32 kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB; - - vcp->normalMass = kNormal > 0.0f ? 1.0f / kNormal : 0.0f; - - b2Vec2 tangent = b2Cross(vc->normal, 1.0f); - - float32 rtA = b2Cross(vcp->rA, tangent); - float32 rtB = b2Cross(vcp->rB, tangent); - - float32 kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB; - - vcp->tangentMass = kTangent > 0.0f ? 1.0f / kTangent : 0.0f; - - // Setup a velocity bias for restitution. - vcp->velocityBias = 0.0f; - float32 vRel = b2Dot(vc->normal, vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA)); - if (vRel < -b2_velocityThreshold) - { - vcp->velocityBias = -vc->restitution * vRel; - } - } - - // If we have two points, then prepare the block solver. - if (vc->pointCount == 2 && g_blockSolve) - { - b2VelocityConstraintPoint* vcp1 = vc->points + 0; - b2VelocityConstraintPoint* vcp2 = vc->points + 1; - - float32 rn1A = b2Cross(vcp1->rA, vc->normal); - float32 rn1B = b2Cross(vcp1->rB, vc->normal); - float32 rn2A = b2Cross(vcp2->rA, vc->normal); - float32 rn2B = b2Cross(vcp2->rB, vc->normal); - - float32 k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B; - float32 k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B; - float32 k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B; - - // Ensure a reasonable condition number. - const float32 k_maxConditionNumber = 1000.0f; - if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) - { - // K is safe to invert. - vc->K.ex.Set(k11, k12); - vc->K.ey.Set(k12, k22); - vc->normalMass = vc->K.GetInverse(); - } - else - { - // The constraints are redundant, just use one. - // TODO_ERIN use deepest? - vc->pointCount = 1; - } - } - } -} - -void b2ContactSolver::WarmStart() -{ - // Warm start. - for (int32 i = 0; i < m_count; ++i) - { - b2ContactVelocityConstraint* vc = m_velocityConstraints + i; - - int32 indexA = vc->indexA; - int32 indexB = vc->indexB; - float32 mA = vc->invMassA; - float32 iA = vc->invIA; - float32 mB = vc->invMassB; - float32 iB = vc->invIB; - int32 pointCount = vc->pointCount; - - b2Vec2 vA = m_velocities[indexA].v; - float32 wA = m_velocities[indexA].w; - b2Vec2 vB = m_velocities[indexB].v; - float32 wB = m_velocities[indexB].w; - - b2Vec2 normal = vc->normal; - b2Vec2 tangent = b2Cross(normal, 1.0f); - - for (int32 j = 0; j < pointCount; ++j) - { - b2VelocityConstraintPoint* vcp = vc->points + j; - b2Vec2 P = vcp->normalImpulse * normal + vcp->tangentImpulse * tangent; - wA -= iA * b2Cross(vcp->rA, P); - vA -= mA * P; - wB += iB * b2Cross(vcp->rB, P); - vB += mB * P; - } - - m_velocities[indexA].v = vA; - m_velocities[indexA].w = wA; - m_velocities[indexB].v = vB; - m_velocities[indexB].w = wB; - } -} - -void b2ContactSolver::SolveVelocityConstraints() -{ - for (int32 i = 0; i < m_count; ++i) - { - b2ContactVelocityConstraint* vc = m_velocityConstraints + i; - - int32 indexA = vc->indexA; - int32 indexB = vc->indexB; - float32 mA = vc->invMassA; - float32 iA = vc->invIA; - float32 mB = vc->invMassB; - float32 iB = vc->invIB; - int32 pointCount = vc->pointCount; - - b2Vec2 vA = m_velocities[indexA].v; - float32 wA = m_velocities[indexA].w; - b2Vec2 vB = m_velocities[indexB].v; - float32 wB = m_velocities[indexB].w; - - b2Vec2 normal = vc->normal; - b2Vec2 tangent = b2Cross(normal, 1.0f); - float32 friction = vc->friction; - - b2Assert(pointCount == 1 || pointCount == 2); - - // Solve tangent constraints first because non-penetration is more important - // than friction. - for (int32 j = 0; j < pointCount; ++j) - { - b2VelocityConstraintPoint* vcp = vc->points + j; - - // Relative velocity at contact - b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA); - - // Compute tangent force - float32 vt = b2Dot(dv, tangent) - vc->tangentSpeed; - float32 lambda = vcp->tangentMass * (-vt); - - // b2Clamp the accumulated force - float32 maxFriction = friction * vcp->normalImpulse; - float32 newImpulse = b2Clamp(vcp->tangentImpulse + lambda, -maxFriction, maxFriction); - lambda = newImpulse - vcp->tangentImpulse; - vcp->tangentImpulse = newImpulse; - - // Apply contact impulse - b2Vec2 P = lambda * tangent; - - vA -= mA * P; - wA -= iA * b2Cross(vcp->rA, P); - - vB += mB * P; - wB += iB * b2Cross(vcp->rB, P); - } - - // Solve normal constraints - if (pointCount == 1 || g_blockSolve == false) - { - for (int32 i = 0; i < pointCount; ++i) - { - b2VelocityConstraintPoint* vcp = vc->points + i; - - // Relative velocity at contact - b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA); - - // Compute normal impulse - float32 vn = b2Dot(dv, normal); - float32 lambda = -vcp->normalMass * (vn - vcp->velocityBias); - - // b2Clamp the accumulated impulse - float32 newImpulse = b2Max(vcp->normalImpulse + lambda, 0.0f); - lambda = newImpulse - vcp->normalImpulse; - vcp->normalImpulse = newImpulse; - - // Apply contact impulse - b2Vec2 P = lambda * normal; - vA -= mA * P; - wA -= iA * b2Cross(vcp->rA, P); - - vB += mB * P; - wB += iB * b2Cross(vcp->rB, P); - } - } - else - { - // Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on Box2D_Lite). - // Build the mini LCP for this contact patch - // - // vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2 - // - // A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n ) - // b = vn0 - velocityBias - // - // The system is solved using the "Total enumeration method" (s. Murty). The complementary constraint vn_i * x_i - // implies that we must have in any solution either vn_i = 0 or x_i = 0. So for the 2D contact problem the cases - // vn1 = 0 and vn2 = 0, x1 = 0 and x2 = 0, x1 = 0 and vn2 = 0, x2 = 0 and vn1 = 0 need to be tested. The first valid - // solution that satisfies the problem is chosen. - // - // In order to account of the accumulated impulse 'a' (because of the iterative nature of the solver which only requires - // that the accumulated impulse is clamped and not the incremental impulse) we change the impulse variable (x_i). - // - // Substitute: - // - // x = a + d - // - // a := old total impulse - // x := new total impulse - // d := incremental impulse - // - // For the current iteration we extend the formula for the incremental impulse - // to compute the new total impulse: - // - // vn = A * d + b - // = A * (x - a) + b - // = A * x + b - A * a - // = A * x + b' - // b' = b - A * a; - - b2VelocityConstraintPoint* cp1 = vc->points + 0; - b2VelocityConstraintPoint* cp2 = vc->points + 1; - - b2Vec2 a(cp1->normalImpulse, cp2->normalImpulse); - b2Assert(a.x >= 0.0f && a.y >= 0.0f); - - // Relative velocity at contact - b2Vec2 dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA); - b2Vec2 dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA); - - // Compute normal velocity - float32 vn1 = b2Dot(dv1, normal); - float32 vn2 = b2Dot(dv2, normal); - - b2Vec2 b; - b.x = vn1 - cp1->velocityBias; - b.y = vn2 - cp2->velocityBias; - - // Compute b' - b -= b2Mul(vc->K, a); - - const float32 k_errorTol = 1e-3f; - B2_NOT_USED(k_errorTol); - - for (;;) - { - // - // Case 1: vn = 0 - // - // 0 = A * x + b' - // - // Solve for x: - // - // x = - inv(A) * b' - // - b2Vec2 x = - b2Mul(vc->normalMass, b); - - if (x.x >= 0.0f && x.y >= 0.0f) - { - // Get the incremental impulse - b2Vec2 d = x - a; - - // Apply incremental impulse - b2Vec2 P1 = d.x * normal; - b2Vec2 P2 = d.y * normal; - vA -= mA * (P1 + P2); - wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2)); - - vB += mB * (P1 + P2); - wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2)); - - // Accumulate - cp1->normalImpulse = x.x; - cp2->normalImpulse = x.y; - -#if B2_DEBUG_SOLVER == 1 - // Postconditions - dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA); - dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA); - - // Compute normal velocity - vn1 = b2Dot(dv1, normal); - vn2 = b2Dot(dv2, normal); - - b2Assert(b2Abs(vn1 - cp1->velocityBias) < k_errorTol); - b2Assert(b2Abs(vn2 - cp2->velocityBias) < k_errorTol); -#endif - break; - } - - // - // Case 2: vn1 = 0 and x2 = 0 - // - // 0 = a11 * x1 + a12 * 0 + b1' - // vn2 = a21 * x1 + a22 * 0 + b2' - // - x.x = - cp1->normalMass * b.x; - x.y = 0.0f; - vn1 = 0.0f; - vn2 = vc->K.ex.y * x.x + b.y; - - if (x.x >= 0.0f && vn2 >= 0.0f) - { - // Get the incremental impulse - b2Vec2 d = x - a; - - // Apply incremental impulse - b2Vec2 P1 = d.x * normal; - b2Vec2 P2 = d.y * normal; - vA -= mA * (P1 + P2); - wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2)); - - vB += mB * (P1 + P2); - wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2)); - - // Accumulate - cp1->normalImpulse = x.x; - cp2->normalImpulse = x.y; - -#if B2_DEBUG_SOLVER == 1 - // Postconditions - dv1 = vB + b2Cross(wB, cp1->rB) - vA - b2Cross(wA, cp1->rA); - - // Compute normal velocity - vn1 = b2Dot(dv1, normal); - - b2Assert(b2Abs(vn1 - cp1->velocityBias) < k_errorTol); -#endif - break; - } - - - // - // Case 3: vn2 = 0 and x1 = 0 - // - // vn1 = a11 * 0 + a12 * x2 + b1' - // 0 = a21 * 0 + a22 * x2 + b2' - // - x.x = 0.0f; - x.y = - cp2->normalMass * b.y; - vn1 = vc->K.ey.x * x.y + b.x; - vn2 = 0.0f; - - if (x.y >= 0.0f && vn1 >= 0.0f) - { - // Resubstitute for the incremental impulse - b2Vec2 d = x - a; - - // Apply incremental impulse - b2Vec2 P1 = d.x * normal; - b2Vec2 P2 = d.y * normal; - vA -= mA * (P1 + P2); - wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2)); - - vB += mB * (P1 + P2); - wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2)); - - // Accumulate - cp1->normalImpulse = x.x; - cp2->normalImpulse = x.y; - -#if B2_DEBUG_SOLVER == 1 - // Postconditions - dv2 = vB + b2Cross(wB, cp2->rB) - vA - b2Cross(wA, cp2->rA); - - // Compute normal velocity - vn2 = b2Dot(dv2, normal); - - b2Assert(b2Abs(vn2 - cp2->velocityBias) < k_errorTol); -#endif - break; - } - - // - // Case 4: x1 = 0 and x2 = 0 - // - // vn1 = b1 - // vn2 = b2; - x.x = 0.0f; - x.y = 0.0f; - vn1 = b.x; - vn2 = b.y; - - if (vn1 >= 0.0f && vn2 >= 0.0f ) - { - // Resubstitute for the incremental impulse - b2Vec2 d = x - a; - - // Apply incremental impulse - b2Vec2 P1 = d.x * normal; - b2Vec2 P2 = d.y * normal; - vA -= mA * (P1 + P2); - wA -= iA * (b2Cross(cp1->rA, P1) + b2Cross(cp2->rA, P2)); - - vB += mB * (P1 + P2); - wB += iB * (b2Cross(cp1->rB, P1) + b2Cross(cp2->rB, P2)); - - // Accumulate - cp1->normalImpulse = x.x; - cp2->normalImpulse = x.y; - - break; - } - - // No solution, give up. This is hit sometimes, but it doesn't seem to matter. - break; - } - } - - m_velocities[indexA].v = vA; - m_velocities[indexA].w = wA; - m_velocities[indexB].v = vB; - m_velocities[indexB].w = wB; - } -} - -void b2ContactSolver::StoreImpulses() -{ - for (int32 i = 0; i < m_count; ++i) - { - b2ContactVelocityConstraint* vc = m_velocityConstraints + i; - b2Manifold* manifold = m_contacts[vc->contactIndex]->GetManifold(); - - for (int32 j = 0; j < vc->pointCount; ++j) - { - manifold->points[j].normalImpulse = vc->points[j].normalImpulse; - manifold->points[j].tangentImpulse = vc->points[j].tangentImpulse; - } - } -} - -struct b2PositionSolverManifold -{ - void Initialize(b2ContactPositionConstraint* pc, const b2Transform& xfA, const b2Transform& xfB, int32 index) - { - b2Assert(pc->pointCount > 0); - - switch (pc->type) - { - case b2Manifold::e_circles: - { - b2Vec2 pointA = b2Mul(xfA, pc->localPoint); - b2Vec2 pointB = b2Mul(xfB, pc->localPoints[0]); - normal = pointB - pointA; - normal.Normalize(); - point = 0.5f * (pointA + pointB); - separation = b2Dot(pointB - pointA, normal) - pc->radiusA - pc->radiusB; - } - break; - - case b2Manifold::e_faceA: - { - normal = b2Mul(xfA.q, pc->localNormal); - b2Vec2 planePoint = b2Mul(xfA, pc->localPoint); - - b2Vec2 clipPoint = b2Mul(xfB, pc->localPoints[index]); - separation = b2Dot(clipPoint - planePoint, normal) - pc->radiusA - pc->radiusB; - point = clipPoint; - } - break; - - case b2Manifold::e_faceB: - { - normal = b2Mul(xfB.q, pc->localNormal); - b2Vec2 planePoint = b2Mul(xfB, pc->localPoint); - - b2Vec2 clipPoint = b2Mul(xfA, pc->localPoints[index]); - separation = b2Dot(clipPoint - planePoint, normal) - pc->radiusA - pc->radiusB; - point = clipPoint; - - // Ensure normal points from A to B - normal = -normal; - } - break; - } - } - - b2Vec2 normal; - b2Vec2 point; - float32 separation; -}; - -// Sequential solver. -bool b2ContactSolver::SolvePositionConstraints() -{ - float32 minSeparation = 0.0f; - - for (int32 i = 0; i < m_count; ++i) - { - b2ContactPositionConstraint* pc = m_positionConstraints + i; - - int32 indexA = pc->indexA; - int32 indexB = pc->indexB; - b2Vec2 localCenterA = pc->localCenterA; - float32 mA = pc->invMassA; - float32 iA = pc->invIA; - b2Vec2 localCenterB = pc->localCenterB; - float32 mB = pc->invMassB; - float32 iB = pc->invIB; - int32 pointCount = pc->pointCount; - - b2Vec2 cA = m_positions[indexA].c; - float32 aA = m_positions[indexA].a; - - b2Vec2 cB = m_positions[indexB].c; - float32 aB = m_positions[indexB].a; - - // Solve normal constraints - for (int32 j = 0; j < pointCount; ++j) - { - b2Transform xfA, xfB; - xfA.q.Set(aA); - xfB.q.Set(aB); - xfA.p = cA - b2Mul(xfA.q, localCenterA); - xfB.p = cB - b2Mul(xfB.q, localCenterB); - - b2PositionSolverManifold psm; - psm.Initialize(pc, xfA, xfB, j); - b2Vec2 normal = psm.normal; - - b2Vec2 point = psm.point; - float32 separation = psm.separation; - - b2Vec2 rA = point - cA; - b2Vec2 rB = point - cB; - - // Track max constraint error. - minSeparation = b2Min(minSeparation, separation); - - // Prevent large corrections and allow slop. - float32 C = b2Clamp(b2_baumgarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0.0f); - - // Compute the effective mass. - float32 rnA = b2Cross(rA, normal); - float32 rnB = b2Cross(rB, normal); - float32 K = mA + mB + iA * rnA * rnA + iB * rnB * rnB; - - // Compute normal impulse - float32 impulse = K > 0.0f ? - C / K : 0.0f; - - b2Vec2 P = impulse * normal; - - cA -= mA * P; - aA -= iA * b2Cross(rA, P); - - cB += mB * P; - aB += iB * b2Cross(rB, P); - } - - m_positions[indexA].c = cA; - m_positions[indexA].a = aA; - - m_positions[indexB].c = cB; - m_positions[indexB].a = aB; - } - - // We can't expect minSpeparation >= -b2_linearSlop because we don't - // push the separation above -b2_linearSlop. - return minSeparation >= -3.0f * b2_linearSlop; -} - -// Sequential position solver for position constraints. -bool b2ContactSolver::SolveTOIPositionConstraints(int32 toiIndexA, int32 toiIndexB) -{ - float32 minSeparation = 0.0f; - - for (int32 i = 0; i < m_count; ++i) - { - b2ContactPositionConstraint* pc = m_positionConstraints + i; - - int32 indexA = pc->indexA; - int32 indexB = pc->indexB; - b2Vec2 localCenterA = pc->localCenterA; - b2Vec2 localCenterB = pc->localCenterB; - int32 pointCount = pc->pointCount; - - float32 mA = 0.0f; - float32 iA = 0.0f; - if (indexA == toiIndexA || indexA == toiIndexB) - { - mA = pc->invMassA; - iA = pc->invIA; - } - - float32 mB = 0.0f; - float32 iB = 0.; - if (indexB == toiIndexA || indexB == toiIndexB) - { - mB = pc->invMassB; - iB = pc->invIB; - } - - b2Vec2 cA = m_positions[indexA].c; - float32 aA = m_positions[indexA].a; - - b2Vec2 cB = m_positions[indexB].c; - float32 aB = m_positions[indexB].a; - - // Solve normal constraints - for (int32 j = 0; j < pointCount; ++j) - { - b2Transform xfA, xfB; - xfA.q.Set(aA); - xfB.q.Set(aB); - xfA.p = cA - b2Mul(xfA.q, localCenterA); - xfB.p = cB - b2Mul(xfB.q, localCenterB); - - b2PositionSolverManifold psm; - psm.Initialize(pc, xfA, xfB, j); - b2Vec2 normal = psm.normal; - - b2Vec2 point = psm.point; - float32 separation = psm.separation; - - b2Vec2 rA = point - cA; - b2Vec2 rB = point - cB; - - // Track max constraint error. - minSeparation = b2Min(minSeparation, separation); - - // Prevent large corrections and allow slop. - float32 C = b2Clamp(b2_toiBaugarte * (separation + b2_linearSlop), -b2_maxLinearCorrection, 0.0f); - - // Compute the effective mass. - float32 rnA = b2Cross(rA, normal); - float32 rnB = b2Cross(rB, normal); - float32 K = mA + mB + iA * rnA * rnA + iB * rnB * rnB; - - // Compute normal impulse - float32 impulse = K > 0.0f ? - C / K : 0.0f; - - b2Vec2 P = impulse * normal; - - cA -= mA * P; - aA -= iA * b2Cross(rA, P); - - cB += mB * P; - aB += iB * b2Cross(rB, P); - } - - m_positions[indexA].c = cA; - m_positions[indexA].a = aA; - - m_positions[indexB].c = cB; - m_positions[indexB].a = aB; - } - - // We can't expect minSpeparation >= -b2_linearSlop because we don't - // push the separation above -b2_linearSlop. - return minSeparation >= -1.5f * b2_linearSlop; -} diff --git a/sources/Box2D/Dynamics/Contacts/b2ContactSolver.h b/sources/Box2D/Dynamics/Contacts/b2ContactSolver.h deleted file mode 100755 index cb568a33..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2ContactSolver.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CONTACT_SOLVER_H -#define B2_CONTACT_SOLVER_H - -#include -#include -#include - -class b2Contact; -class b2Body; -class b2StackAllocator; -struct b2ContactPositionConstraint; - -struct b2VelocityConstraintPoint -{ - b2Vec2 rA; - b2Vec2 rB; - float32 normalImpulse; - float32 tangentImpulse; - float32 normalMass; - float32 tangentMass; - float32 velocityBias; -}; - -struct b2ContactVelocityConstraint -{ - b2VelocityConstraintPoint points[b2_maxManifoldPoints]; - b2Vec2 normal; - b2Mat22 normalMass; - b2Mat22 K; - int32 indexA; - int32 indexB; - float32 invMassA, invMassB; - float32 invIA, invIB; - float32 friction; - float32 restitution; - float32 tangentSpeed; - int32 pointCount; - int32 contactIndex; -}; - -struct b2ContactSolverDef -{ - b2TimeStep step; - b2Contact** contacts; - int32 count; - b2Position* positions; - b2Velocity* velocities; - b2StackAllocator* allocator; -}; - -class b2ContactSolver -{ -public: - b2ContactSolver(b2ContactSolverDef* def); - ~b2ContactSolver(); - - void InitializeVelocityConstraints(); - - void WarmStart(); - void SolveVelocityConstraints(); - void StoreImpulses(); - - bool SolvePositionConstraints(); - bool SolveTOIPositionConstraints(int32 toiIndexA, int32 toiIndexB); - - b2TimeStep m_step; - b2Position* m_positions; - b2Velocity* m_velocities; - b2StackAllocator* m_allocator; - b2ContactPositionConstraint* m_positionConstraints; - b2ContactVelocityConstraint* m_velocityConstraints; - b2Contact** m_contacts; - int m_count; -}; - -#endif - diff --git a/sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp b/sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp deleted file mode 100755 index ee622685..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -#include - -b2Contact* b2EdgeAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2EdgeAndCircleContact)); - return new (mem) b2EdgeAndCircleContact(fixtureA, fixtureB); -} - -void b2EdgeAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2EdgeAndCircleContact*)contact)->~b2EdgeAndCircleContact(); - allocator->Free(contact, sizeof(b2EdgeAndCircleContact)); -} - -b2EdgeAndCircleContact::b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) -: b2Contact(fixtureA, 0, fixtureB, 0) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); - b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); -} - -void b2EdgeAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2CollideEdgeAndCircle( manifold, - (b2EdgeShape*)m_fixtureA->GetShape(), xfA, - (b2CircleShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h b/sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h deleted file mode 100755 index 11b61b88..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_EDGE_AND_CIRCLE_CONTACT_H -#define B2_EDGE_AND_CIRCLE_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2EdgeAndCircleContact : public b2Contact -{ -public: - static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2EdgeAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); - ~b2EdgeAndCircleContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp b/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp deleted file mode 100755 index 379ce243..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2006-2010 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -#include - -b2Contact* b2EdgeAndPolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2EdgeAndPolygonContact)); - return new (mem) b2EdgeAndPolygonContact(fixtureA, fixtureB); -} - -void b2EdgeAndPolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2EdgeAndPolygonContact*)contact)->~b2EdgeAndPolygonContact(); - allocator->Free(contact, sizeof(b2EdgeAndPolygonContact)); -} - -b2EdgeAndPolygonContact::b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) -: b2Contact(fixtureA, 0, fixtureB, 0) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_edge); - b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); -} - -void b2EdgeAndPolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2CollideEdgeAndPolygon( manifold, - (b2EdgeShape*)m_fixtureA->GetShape(), xfA, - (b2PolygonShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h b/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h deleted file mode 100755 index 74b27ee0..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_EDGE_AND_POLYGON_CONTACT_H -#define B2_EDGE_AND_POLYGON_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2EdgeAndPolygonContact : public b2Contact -{ -public: - static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2EdgeAndPolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); - ~b2EdgeAndPolygonContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp b/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp deleted file mode 100755 index 41da9f19..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -#include - -b2Contact* b2PolygonAndCircleContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2PolygonAndCircleContact)); - return new (mem) b2PolygonAndCircleContact(fixtureA, fixtureB); -} - -void b2PolygonAndCircleContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2PolygonAndCircleContact*)contact)->~b2PolygonAndCircleContact(); - allocator->Free(contact, sizeof(b2PolygonAndCircleContact)); -} - -b2PolygonAndCircleContact::b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB) -: b2Contact(fixtureA, 0, fixtureB, 0) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); - b2Assert(m_fixtureB->GetType() == b2Shape::e_circle); -} - -void b2PolygonAndCircleContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2CollidePolygonAndCircle( manifold, - (b2PolygonShape*)m_fixtureA->GetShape(), xfA, - (b2CircleShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h b/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h deleted file mode 100755 index 6beca16a..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_POLYGON_AND_CIRCLE_CONTACT_H -#define B2_POLYGON_AND_CIRCLE_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2PolygonAndCircleContact : public b2Contact -{ -public: - static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2PolygonAndCircleContact(b2Fixture* fixtureA, b2Fixture* fixtureB); - ~b2PolygonAndCircleContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Contacts/b2PolygonContact.cpp b/sources/Box2D/Dynamics/Contacts/b2PolygonContact.cpp deleted file mode 100755 index e466190e..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2PolygonContact.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include - -#include - -b2Contact* b2PolygonContact::Create(b2Fixture* fixtureA, int32, b2Fixture* fixtureB, int32, b2BlockAllocator* allocator) -{ - void* mem = allocator->Allocate(sizeof(b2PolygonContact)); - return new (mem) b2PolygonContact(fixtureA, fixtureB); -} - -void b2PolygonContact::Destroy(b2Contact* contact, b2BlockAllocator* allocator) -{ - ((b2PolygonContact*)contact)->~b2PolygonContact(); - allocator->Free(contact, sizeof(b2PolygonContact)); -} - -b2PolygonContact::b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB) - : b2Contact(fixtureA, 0, fixtureB, 0) -{ - b2Assert(m_fixtureA->GetType() == b2Shape::e_polygon); - b2Assert(m_fixtureB->GetType() == b2Shape::e_polygon); -} - -void b2PolygonContact::Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) -{ - b2CollidePolygons( manifold, - (b2PolygonShape*)m_fixtureA->GetShape(), xfA, - (b2PolygonShape*)m_fixtureB->GetShape(), xfB); -} diff --git a/sources/Box2D/Dynamics/Contacts/b2PolygonContact.h b/sources/Box2D/Dynamics/Contacts/b2PolygonContact.h deleted file mode 100755 index 45932148..00000000 --- a/sources/Box2D/Dynamics/Contacts/b2PolygonContact.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_POLYGON_CONTACT_H -#define B2_POLYGON_CONTACT_H - -#include - -class b2BlockAllocator; - -class b2PolygonContact : public b2Contact -{ -public: - static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, - b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); - static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); - - b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); - ~b2PolygonContact() {} - - void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2DistanceJoint.cpp b/sources/Box2D/Dynamics/Joints/b2DistanceJoint.cpp deleted file mode 100755 index 1ced7d9d..00000000 --- a/sources/Box2D/Dynamics/Joints/b2DistanceJoint.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// 1-D constrained system -// m (v2 - v1) = lambda -// v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass. -// x2 = x1 + h * v2 - -// 1-D mass-damper-spring system -// m (v2 - v1) + h * d * v2 + h * k * - -// C = norm(p2 - p1) - L -// u = (p2 - p1) / norm(p2 - p1) -// Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1)) -// J = [-u -cross(r1, u) u cross(r2, u)] -// K = J * invM * JT -// = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2 - -void b2DistanceJointDef::Initialize(b2Body* b1, b2Body* b2, - const b2Vec2& anchor1, const b2Vec2& anchor2) -{ - bodyA = b1; - bodyB = b2; - localAnchorA = bodyA->GetLocalPoint(anchor1); - localAnchorB = bodyB->GetLocalPoint(anchor2); - b2Vec2 d = anchor2 - anchor1; - length = d.Length(); -} - -b2DistanceJoint::b2DistanceJoint(const b2DistanceJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - m_length = def->length; - m_frequencyHz = def->frequencyHz; - m_dampingRatio = def->dampingRatio; - m_impulse = 0.0f; - m_gamma = 0.0f; - m_bias = 0.0f; -} - -void b2DistanceJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - m_u = cB + m_rB - cA - m_rA; - - // Handle singularity. - float32 length = m_u.Length(); - if (length > b2_linearSlop) - { - m_u *= 1.0f / length; - } - else - { - m_u.Set(0.0f, 0.0f); - } - - float32 crAu = b2Cross(m_rA, m_u); - float32 crBu = b2Cross(m_rB, m_u); - float32 invMass = m_invMassA + m_invIA * crAu * crAu + m_invMassB + m_invIB * crBu * crBu; - - // Compute the effective mass matrix. - m_mass = invMass != 0.0f ? 1.0f / invMass : 0.0f; - - if (m_frequencyHz > 0.0f) - { - float32 C = length - m_length; - - // Frequency - float32 omega = 2.0f * b2_pi * m_frequencyHz; - - // Damping coefficient - float32 d = 2.0f * m_mass * m_dampingRatio * omega; - - // Spring stiffness - float32 k = m_mass * omega * omega; - - // magic formulas - float32 h = data.step.dt; - m_gamma = h * (d + h * k); - m_gamma = m_gamma != 0.0f ? 1.0f / m_gamma : 0.0f; - m_bias = C * h * k * m_gamma; - - invMass += m_gamma; - m_mass = invMass != 0.0f ? 1.0f / invMass : 0.0f; - } - else - { - m_gamma = 0.0f; - m_bias = 0.0f; - } - - if (data.step.warmStarting) - { - // Scale the impulse to support a variable time step. - m_impulse *= data.step.dtRatio; - - b2Vec2 P = m_impulse * m_u; - vA -= m_invMassA * P; - wA -= m_invIA * b2Cross(m_rA, P); - vB += m_invMassB * P; - wB += m_invIB * b2Cross(m_rB, P); - } - else - { - m_impulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2DistanceJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - // Cdot = dot(u, v + cross(w, r)) - b2Vec2 vpA = vA + b2Cross(wA, m_rA); - b2Vec2 vpB = vB + b2Cross(wB, m_rB); - float32 Cdot = b2Dot(m_u, vpB - vpA); - - float32 impulse = -m_mass * (Cdot + m_bias + m_gamma * m_impulse); - m_impulse += impulse; - - b2Vec2 P = impulse * m_u; - vA -= m_invMassA * P; - wA -= m_invIA * b2Cross(m_rA, P); - vB += m_invMassB * P; - wB += m_invIB * b2Cross(m_rB, P); - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2DistanceJoint::SolvePositionConstraints(const b2SolverData& data) -{ - if (m_frequencyHz > 0.0f) - { - // There is no position correction for soft distance constraints. - return true; - } - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - b2Vec2 u = cB + rB - cA - rA; - - float32 length = u.Normalize(); - float32 C = length - m_length; - C = b2Clamp(C, -b2_maxLinearCorrection, b2_maxLinearCorrection); - - float32 impulse = -m_mass * C; - b2Vec2 P = impulse * u; - - cA -= m_invMassA * P; - aA -= m_invIA * b2Cross(rA, P); - cB += m_invMassB * P; - aB += m_invIB * b2Cross(rB, P); - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return b2Abs(C) < b2_linearSlop; -} - -b2Vec2 b2DistanceJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2DistanceJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2DistanceJoint::GetReactionForce(float32 inv_dt) const -{ - b2Vec2 F = (inv_dt * m_impulse) * m_u; - return F; -} - -float32 b2DistanceJoint::GetReactionTorque(float32 inv_dt) const -{ - B2_NOT_USED(inv_dt); - return 0.0f; -} - -void b2DistanceJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2DistanceJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.length = %.15lef;\n", m_length); - b2Log(" jd.frequencyHz = %.15lef;\n", m_frequencyHz); - b2Log(" jd.dampingRatio = %.15lef;\n", m_dampingRatio); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2DistanceJoint.h b/sources/Box2D/Dynamics/Joints/b2DistanceJoint.h deleted file mode 100755 index 9d0528b9..00000000 --- a/sources/Box2D/Dynamics/Joints/b2DistanceJoint.h +++ /dev/null @@ -1,169 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_DISTANCE_JOINT_H -#define B2_DISTANCE_JOINT_H - -#include - -/// Distance joint definition. This requires defining an -/// anchor point on both bodies and the non-zero length of the -/// distance joint. The definition uses local anchor points -/// so that the initial configuration can violate the constraint -/// slightly. This helps when saving and loading a game. -/// @warning Do not use a zero or short length. -struct b2DistanceJointDef : public b2JointDef -{ - b2DistanceJointDef() - { - type = e_distanceJoint; - localAnchorA.Set(0.0f, 0.0f); - localAnchorB.Set(0.0f, 0.0f); - length = 1.0f; - frequencyHz = 0.0f; - dampingRatio = 0.0f; - } - - /// Initialize the bodies, anchors, and length using the world - /// anchors. - void Initialize(b2Body* bodyA, b2Body* bodyB, - const b2Vec2& anchorA, const b2Vec2& anchorB); - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The natural length between the anchor points. - float32 length; - - /// The mass-spring-damper frequency in Hertz. A value of 0 - /// disables softness. - float32 frequencyHz; - - /// The damping ratio. 0 = no damping, 1 = critical damping. - float32 dampingRatio; -}; - -/// A distance joint constrains two points on two bodies -/// to remain at a fixed distance from each other. You can view -/// this as a massless, rigid rod. -class b2DistanceJoint : public b2Joint -{ -public: - - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - /// Get the reaction force given the inverse time step. - /// Unit is N. - b2Vec2 GetReactionForce(float32 inv_dt) const; - - /// Get the reaction torque given the inverse time step. - /// Unit is N*m. This is always zero for a distance joint. - float32 GetReactionTorque(float32 inv_dt) const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// Set/get the natural length. - /// Manipulating the length can lead to non-physical behavior when the frequency is zero. - void SetLength(float32 length); - float32 GetLength() const; - - /// Set/get frequency in Hz. - void SetFrequency(float32 hz); - float32 GetFrequency() const; - - /// Set/get damping ratio. - void SetDampingRatio(float32 ratio); - float32 GetDampingRatio() const; - - /// Dump joint to dmLog - void Dump(); - -protected: - - friend class b2Joint; - b2DistanceJoint(const b2DistanceJointDef* data); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - float32 m_frequencyHz; - float32 m_dampingRatio; - float32 m_bias; - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - float32 m_gamma; - float32 m_impulse; - float32 m_length; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_u; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - float32 m_mass; -}; - -inline void b2DistanceJoint::SetLength(float32 length) -{ - m_length = length; -} - -inline float32 b2DistanceJoint::GetLength() const -{ - return m_length; -} - -inline void b2DistanceJoint::SetFrequency(float32 hz) -{ - m_frequencyHz = hz; -} - -inline float32 b2DistanceJoint::GetFrequency() const -{ - return m_frequencyHz; -} - -inline void b2DistanceJoint::SetDampingRatio(float32 ratio) -{ - m_dampingRatio = ratio; -} - -inline float32 b2DistanceJoint::GetDampingRatio() const -{ - return m_dampingRatio; -} - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2FrictionJoint.cpp b/sources/Box2D/Dynamics/Joints/b2FrictionJoint.cpp deleted file mode 100755 index 075e72bb..00000000 --- a/sources/Box2D/Dynamics/Joints/b2FrictionJoint.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Point-to-point constraint -// Cdot = v2 - v1 -// = v2 + cross(w2, r2) - v1 - cross(w1, r1) -// J = [-I -r1_skew I r2_skew ] -// Identity used: -// w k % (rx i + ry j) = w * (-ry i + rx j) - -// Angle constraint -// Cdot = w2 - w1 -// J = [0 0 -1 0 0 1] -// K = invI1 + invI2 - -void b2FrictionJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor) -{ - bodyA = bA; - bodyB = bB; - localAnchorA = bodyA->GetLocalPoint(anchor); - localAnchorB = bodyB->GetLocalPoint(anchor); -} - -b2FrictionJoint::b2FrictionJoint(const b2FrictionJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - - m_linearImpulse.SetZero(); - m_angularImpulse = 0.0f; - - m_maxForce = def->maxForce; - m_maxTorque = def->maxTorque; -} - -void b2FrictionJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - // Compute the effective mass matrix. - m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - // J = [-I -r1_skew I r2_skew] - // [ 0 -1 0 1] - // r_skew = [-ry; rx] - - // Matlab - // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB] - // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB] - // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB] - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Mat22 K; - K.ex.x = mA + mB + iA * m_rA.y * m_rA.y + iB * m_rB.y * m_rB.y; - K.ex.y = -iA * m_rA.x * m_rA.y - iB * m_rB.x * m_rB.y; - K.ey.x = K.ex.y; - K.ey.y = mA + mB + iA * m_rA.x * m_rA.x + iB * m_rB.x * m_rB.x; - - m_linearMass = K.GetInverse(); - - m_angularMass = iA + iB; - if (m_angularMass > 0.0f) - { - m_angularMass = 1.0f / m_angularMass; - } - - if (data.step.warmStarting) - { - // Scale impulses to support a variable time step. - m_linearImpulse *= data.step.dtRatio; - m_angularImpulse *= data.step.dtRatio; - - b2Vec2 P(m_linearImpulse.x, m_linearImpulse.y); - vA -= mA * P; - wA -= iA * (b2Cross(m_rA, P) + m_angularImpulse); - vB += mB * P; - wB += iB * (b2Cross(m_rB, P) + m_angularImpulse); - } - else - { - m_linearImpulse.SetZero(); - m_angularImpulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2FrictionJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - float32 h = data.step.dt; - - // Solve angular friction - { - float32 Cdot = wB - wA; - float32 impulse = -m_angularMass * Cdot; - - float32 oldImpulse = m_angularImpulse; - float32 maxImpulse = h * m_maxTorque; - m_angularImpulse = b2Clamp(m_angularImpulse + impulse, -maxImpulse, maxImpulse); - impulse = m_angularImpulse - oldImpulse; - - wA -= iA * impulse; - wB += iB * impulse; - } - - // Solve linear friction - { - b2Vec2 Cdot = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA); - - b2Vec2 impulse = -b2Mul(m_linearMass, Cdot); - b2Vec2 oldImpulse = m_linearImpulse; - m_linearImpulse += impulse; - - float32 maxImpulse = h * m_maxForce; - - if (m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) - { - m_linearImpulse.Normalize(); - m_linearImpulse *= maxImpulse; - } - - impulse = m_linearImpulse - oldImpulse; - - vA -= mA * impulse; - wA -= iA * b2Cross(m_rA, impulse); - - vB += mB * impulse; - wB += iB * b2Cross(m_rB, impulse); - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2FrictionJoint::SolvePositionConstraints(const b2SolverData& data) -{ - B2_NOT_USED(data); - - return true; -} - -b2Vec2 b2FrictionJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2FrictionJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2FrictionJoint::GetReactionForce(float32 inv_dt) const -{ - return inv_dt * m_linearImpulse; -} - -float32 b2FrictionJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * m_angularImpulse; -} - -void b2FrictionJoint::SetMaxForce(float32 force) -{ - b2Assert(b2IsValid(force) && force >= 0.0f); - m_maxForce = force; -} - -float32 b2FrictionJoint::GetMaxForce() const -{ - return m_maxForce; -} - -void b2FrictionJoint::SetMaxTorque(float32 torque) -{ - b2Assert(b2IsValid(torque) && torque >= 0.0f); - m_maxTorque = torque; -} - -float32 b2FrictionJoint::GetMaxTorque() const -{ - return m_maxTorque; -} - -void b2FrictionJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2FrictionJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.maxForce = %.15lef;\n", m_maxForce); - b2Log(" jd.maxTorque = %.15lef;\n", m_maxTorque); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2FrictionJoint.h b/sources/Box2D/Dynamics/Joints/b2FrictionJoint.h deleted file mode 100755 index 785d9ac1..00000000 --- a/sources/Box2D/Dynamics/Joints/b2FrictionJoint.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_FRICTION_JOINT_H -#define B2_FRICTION_JOINT_H - -#include - -/// Friction joint definition. -struct b2FrictionJointDef : public b2JointDef -{ - b2FrictionJointDef() - { - type = e_frictionJoint; - localAnchorA.SetZero(); - localAnchorB.SetZero(); - maxForce = 0.0f; - maxTorque = 0.0f; - } - - /// Initialize the bodies, anchors, axis, and reference angle using the world - /// anchor and world axis. - void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor); - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The maximum friction force in N. - float32 maxForce; - - /// The maximum friction torque in N-m. - float32 maxTorque; -}; - -/// Friction joint. This is used for top-down friction. -/// It provides 2D translational friction and angular friction. -class b2FrictionJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// Set the maximum friction force in N. - void SetMaxForce(float32 force); - - /// Get the maximum friction force in N. - float32 GetMaxForce() const; - - /// Set the maximum friction torque in N*m. - void SetMaxTorque(float32 torque); - - /// Get the maximum friction torque in N*m. - float32 GetMaxTorque() const; - - /// Dump joint to dmLog - void Dump(); - -protected: - - friend class b2Joint; - - b2FrictionJoint(const b2FrictionJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - - // Solver shared - b2Vec2 m_linearImpulse; - float32 m_angularImpulse; - float32 m_maxForce; - float32 m_maxTorque; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - b2Mat22 m_linearMass; - float32 m_angularMass; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2GearJoint.cpp b/sources/Box2D/Dynamics/Joints/b2GearJoint.cpp deleted file mode 100755 index 233d972a..00000000 --- a/sources/Box2D/Dynamics/Joints/b2GearJoint.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/* -* Copyright (c) 2007-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include - -// Gear Joint: -// C0 = (coordinate1 + ratio * coordinate2)_initial -// C = (coordinate1 + ratio * coordinate2) - C0 = 0 -// J = [J1 ratio * J2] -// K = J * invM * JT -// = J1 * invM1 * J1T + ratio * ratio * J2 * invM2 * J2T -// -// Revolute: -// coordinate = rotation -// Cdot = angularVelocity -// J = [0 0 1] -// K = J * invM * JT = invI -// -// Prismatic: -// coordinate = dot(p - pg, ug) -// Cdot = dot(v + cross(w, r), ug) -// J = [ug cross(r, ug)] -// K = J * invM * JT = invMass + invI * cross(r, ug)^2 - -b2GearJoint::b2GearJoint(const b2GearJointDef* def) -: b2Joint(def) -{ - m_joint1 = def->joint1; - m_joint2 = def->joint2; - - m_typeA = m_joint1->GetType(); - m_typeB = m_joint2->GetType(); - - b2Assert(m_typeA == e_revoluteJoint || m_typeA == e_prismaticJoint); - b2Assert(m_typeB == e_revoluteJoint || m_typeB == e_prismaticJoint); - - float32 coordinateA, coordinateB; - - // TODO_ERIN there might be some problem with the joint edges in b2Joint. - - m_bodyC = m_joint1->GetBodyA(); - m_bodyA = m_joint1->GetBodyB(); - - // Get geometry of joint1 - b2Transform xfA = m_bodyA->m_xf; - float32 aA = m_bodyA->m_sweep.a; - b2Transform xfC = m_bodyC->m_xf; - float32 aC = m_bodyC->m_sweep.a; - - if (m_typeA == e_revoluteJoint) - { - b2RevoluteJoint* revolute = (b2RevoluteJoint*)def->joint1; - m_localAnchorC = revolute->m_localAnchorA; - m_localAnchorA = revolute->m_localAnchorB; - m_referenceAngleA = revolute->m_referenceAngle; - m_localAxisC.SetZero(); - - coordinateA = aA - aC - m_referenceAngleA; - } - else - { - b2PrismaticJoint* prismatic = (b2PrismaticJoint*)def->joint1; - m_localAnchorC = prismatic->m_localAnchorA; - m_localAnchorA = prismatic->m_localAnchorB; - m_referenceAngleA = prismatic->m_referenceAngle; - m_localAxisC = prismatic->m_localXAxisA; - - b2Vec2 pC = m_localAnchorC; - b2Vec2 pA = b2MulT(xfC.q, b2Mul(xfA.q, m_localAnchorA) + (xfA.p - xfC.p)); - coordinateA = b2Dot(pA - pC, m_localAxisC); - } - - m_bodyD = m_joint2->GetBodyA(); - m_bodyB = m_joint2->GetBodyB(); - - // Get geometry of joint2 - b2Transform xfB = m_bodyB->m_xf; - float32 aB = m_bodyB->m_sweep.a; - b2Transform xfD = m_bodyD->m_xf; - float32 aD = m_bodyD->m_sweep.a; - - if (m_typeB == e_revoluteJoint) - { - b2RevoluteJoint* revolute = (b2RevoluteJoint*)def->joint2; - m_localAnchorD = revolute->m_localAnchorA; - m_localAnchorB = revolute->m_localAnchorB; - m_referenceAngleB = revolute->m_referenceAngle; - m_localAxisD.SetZero(); - - coordinateB = aB - aD - m_referenceAngleB; - } - else - { - b2PrismaticJoint* prismatic = (b2PrismaticJoint*)def->joint2; - m_localAnchorD = prismatic->m_localAnchorA; - m_localAnchorB = prismatic->m_localAnchorB; - m_referenceAngleB = prismatic->m_referenceAngle; - m_localAxisD = prismatic->m_localXAxisA; - - b2Vec2 pD = m_localAnchorD; - b2Vec2 pB = b2MulT(xfD.q, b2Mul(xfB.q, m_localAnchorB) + (xfB.p - xfD.p)); - coordinateB = b2Dot(pB - pD, m_localAxisD); - } - - m_ratio = def->ratio; - - m_constant = coordinateA + m_ratio * coordinateB; - - m_impulse = 0.0f; -} - -void b2GearJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_indexC = m_bodyC->m_islandIndex; - m_indexD = m_bodyD->m_islandIndex; - m_lcA = m_bodyA->m_sweep.localCenter; - m_lcB = m_bodyB->m_sweep.localCenter; - m_lcC = m_bodyC->m_sweep.localCenter; - m_lcD = m_bodyD->m_sweep.localCenter; - m_mA = m_bodyA->m_invMass; - m_mB = m_bodyB->m_invMass; - m_mC = m_bodyC->m_invMass; - m_mD = m_bodyD->m_invMass; - m_iA = m_bodyA->m_invI; - m_iB = m_bodyB->m_invI; - m_iC = m_bodyC->m_invI; - m_iD = m_bodyD->m_invI; - - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - float32 aC = data.positions[m_indexC].a; - b2Vec2 vC = data.velocities[m_indexC].v; - float32 wC = data.velocities[m_indexC].w; - - float32 aD = data.positions[m_indexD].a; - b2Vec2 vD = data.velocities[m_indexD].v; - float32 wD = data.velocities[m_indexD].w; - - b2Rot qA(aA), qB(aB), qC(aC), qD(aD); - - m_mass = 0.0f; - - if (m_typeA == e_revoluteJoint) - { - m_JvAC.SetZero(); - m_JwA = 1.0f; - m_JwC = 1.0f; - m_mass += m_iA + m_iC; - } - else - { - b2Vec2 u = b2Mul(qC, m_localAxisC); - b2Vec2 rC = b2Mul(qC, m_localAnchorC - m_lcC); - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_lcA); - m_JvAC = u; - m_JwC = b2Cross(rC, u); - m_JwA = b2Cross(rA, u); - m_mass += m_mC + m_mA + m_iC * m_JwC * m_JwC + m_iA * m_JwA * m_JwA; - } - - if (m_typeB == e_revoluteJoint) - { - m_JvBD.SetZero(); - m_JwB = m_ratio; - m_JwD = m_ratio; - m_mass += m_ratio * m_ratio * (m_iB + m_iD); - } - else - { - b2Vec2 u = b2Mul(qD, m_localAxisD); - b2Vec2 rD = b2Mul(qD, m_localAnchorD - m_lcD); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_lcB); - m_JvBD = m_ratio * u; - m_JwD = m_ratio * b2Cross(rD, u); - m_JwB = m_ratio * b2Cross(rB, u); - m_mass += m_ratio * m_ratio * (m_mD + m_mB) + m_iD * m_JwD * m_JwD + m_iB * m_JwB * m_JwB; - } - - // Compute effective mass. - m_mass = m_mass > 0.0f ? 1.0f / m_mass : 0.0f; - - if (data.step.warmStarting) - { - vA += (m_mA * m_impulse) * m_JvAC; - wA += m_iA * m_impulse * m_JwA; - vB += (m_mB * m_impulse) * m_JvBD; - wB += m_iB * m_impulse * m_JwB; - vC -= (m_mC * m_impulse) * m_JvAC; - wC -= m_iC * m_impulse * m_JwC; - vD -= (m_mD * m_impulse) * m_JvBD; - wD -= m_iD * m_impulse * m_JwD; - } - else - { - m_impulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; - data.velocities[m_indexC].v = vC; - data.velocities[m_indexC].w = wC; - data.velocities[m_indexD].v = vD; - data.velocities[m_indexD].w = wD; -} - -void b2GearJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - b2Vec2 vC = data.velocities[m_indexC].v; - float32 wC = data.velocities[m_indexC].w; - b2Vec2 vD = data.velocities[m_indexD].v; - float32 wD = data.velocities[m_indexD].w; - - float32 Cdot = b2Dot(m_JvAC, vA - vC) + b2Dot(m_JvBD, vB - vD); - Cdot += (m_JwA * wA - m_JwC * wC) + (m_JwB * wB - m_JwD * wD); - - float32 impulse = -m_mass * Cdot; - m_impulse += impulse; - - vA += (m_mA * impulse) * m_JvAC; - wA += m_iA * impulse * m_JwA; - vB += (m_mB * impulse) * m_JvBD; - wB += m_iB * impulse * m_JwB; - vC -= (m_mC * impulse) * m_JvAC; - wC -= m_iC * impulse * m_JwC; - vD -= (m_mD * impulse) * m_JvBD; - wD -= m_iD * impulse * m_JwD; - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; - data.velocities[m_indexC].v = vC; - data.velocities[m_indexC].w = wC; - data.velocities[m_indexD].v = vD; - data.velocities[m_indexD].w = wD; -} - -bool b2GearJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 cC = data.positions[m_indexC].c; - float32 aC = data.positions[m_indexC].a; - b2Vec2 cD = data.positions[m_indexD].c; - float32 aD = data.positions[m_indexD].a; - - b2Rot qA(aA), qB(aB), qC(aC), qD(aD); - - float32 linearError = 0.0f; - - float32 coordinateA, coordinateB; - - b2Vec2 JvAC, JvBD; - float32 JwA, JwB, JwC, JwD; - float32 mass = 0.0f; - - if (m_typeA == e_revoluteJoint) - { - JvAC.SetZero(); - JwA = 1.0f; - JwC = 1.0f; - mass += m_iA + m_iC; - - coordinateA = aA - aC - m_referenceAngleA; - } - else - { - b2Vec2 u = b2Mul(qC, m_localAxisC); - b2Vec2 rC = b2Mul(qC, m_localAnchorC - m_lcC); - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_lcA); - JvAC = u; - JwC = b2Cross(rC, u); - JwA = b2Cross(rA, u); - mass += m_mC + m_mA + m_iC * JwC * JwC + m_iA * JwA * JwA; - - b2Vec2 pC = m_localAnchorC - m_lcC; - b2Vec2 pA = b2MulT(qC, rA + (cA - cC)); - coordinateA = b2Dot(pA - pC, m_localAxisC); - } - - if (m_typeB == e_revoluteJoint) - { - JvBD.SetZero(); - JwB = m_ratio; - JwD = m_ratio; - mass += m_ratio * m_ratio * (m_iB + m_iD); - - coordinateB = aB - aD - m_referenceAngleB; - } - else - { - b2Vec2 u = b2Mul(qD, m_localAxisD); - b2Vec2 rD = b2Mul(qD, m_localAnchorD - m_lcD); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_lcB); - JvBD = m_ratio * u; - JwD = m_ratio * b2Cross(rD, u); - JwB = m_ratio * b2Cross(rB, u); - mass += m_ratio * m_ratio * (m_mD + m_mB) + m_iD * JwD * JwD + m_iB * JwB * JwB; - - b2Vec2 pD = m_localAnchorD - m_lcD; - b2Vec2 pB = b2MulT(qD, rB + (cB - cD)); - coordinateB = b2Dot(pB - pD, m_localAxisD); - } - - float32 C = (coordinateA + m_ratio * coordinateB) - m_constant; - - float32 impulse = 0.0f; - if (mass > 0.0f) - { - impulse = -C / mass; - } - - cA += m_mA * impulse * JvAC; - aA += m_iA * impulse * JwA; - cB += m_mB * impulse * JvBD; - aB += m_iB * impulse * JwB; - cC -= m_mC * impulse * JvAC; - aC -= m_iC * impulse * JwC; - cD -= m_mD * impulse * JvBD; - aD -= m_iD * impulse * JwD; - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - data.positions[m_indexC].c = cC; - data.positions[m_indexC].a = aC; - data.positions[m_indexD].c = cD; - data.positions[m_indexD].a = aD; - - // TODO_ERIN not implemented - return linearError < b2_linearSlop; -} - -b2Vec2 b2GearJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2GearJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2GearJoint::GetReactionForce(float32 inv_dt) const -{ - b2Vec2 P = m_impulse * m_JvAC; - return inv_dt * P; -} - -float32 b2GearJoint::GetReactionTorque(float32 inv_dt) const -{ - float32 L = m_impulse * m_JwA; - return inv_dt * L; -} - -void b2GearJoint::SetRatio(float32 ratio) -{ - b2Assert(b2IsValid(ratio)); - m_ratio = ratio; -} - -float32 b2GearJoint::GetRatio() const -{ - return m_ratio; -} - -void b2GearJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - int32 index1 = m_joint1->m_index; - int32 index2 = m_joint2->m_index; - - b2Log(" b2GearJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.joint1 = joints[%d];\n", index1); - b2Log(" jd.joint2 = joints[%d];\n", index2); - b2Log(" jd.ratio = %.15lef;\n", m_ratio); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2GearJoint.h b/sources/Box2D/Dynamics/Joints/b2GearJoint.h deleted file mode 100755 index 48cdfd88..00000000 --- a/sources/Box2D/Dynamics/Joints/b2GearJoint.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_GEAR_JOINT_H -#define B2_GEAR_JOINT_H - -#include - -/// Gear joint definition. This definition requires two existing -/// revolute or prismatic joints (any combination will work). -struct b2GearJointDef : public b2JointDef -{ - b2GearJointDef() - { - type = e_gearJoint; - joint1 = NULL; - joint2 = NULL; - ratio = 1.0f; - } - - /// The first revolute/prismatic joint attached to the gear joint. - b2Joint* joint1; - - /// The second revolute/prismatic joint attached to the gear joint. - b2Joint* joint2; - - /// The gear ratio. - /// @see b2GearJoint for explanation. - float32 ratio; -}; - -/// A gear joint is used to connect two joints together. Either joint -/// can be a revolute or prismatic joint. You specify a gear ratio -/// to bind the motions together: -/// coordinate1 + ratio * coordinate2 = constant -/// The ratio can be negative or positive. If one joint is a revolute joint -/// and the other joint is a prismatic joint, then the ratio will have units -/// of length or units of 1/length. -/// @warning You have to manually destroy the gear joint if joint1 or joint2 -/// is destroyed. -class b2GearJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// Get the first joint. - b2Joint* GetJoint1() { return m_joint1; } - - /// Get the second joint. - b2Joint* GetJoint2() { return m_joint2; } - - /// Set/Get the gear ratio. - void SetRatio(float32 ratio); - float32 GetRatio() const; - - /// Dump joint to dmLog - void Dump(); - -protected: - - friend class b2Joint; - b2GearJoint(const b2GearJointDef* data); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - b2Joint* m_joint1; - b2Joint* m_joint2; - - b2JointType m_typeA; - b2JointType m_typeB; - - // Body A is connected to body C - // Body B is connected to body D - b2Body* m_bodyC; - b2Body* m_bodyD; - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - b2Vec2 m_localAnchorC; - b2Vec2 m_localAnchorD; - - b2Vec2 m_localAxisC; - b2Vec2 m_localAxisD; - - float32 m_referenceAngleA; - float32 m_referenceAngleB; - - float32 m_constant; - float32 m_ratio; - - float32 m_impulse; - - // Solver temp - int32 m_indexA, m_indexB, m_indexC, m_indexD; - b2Vec2 m_lcA, m_lcB, m_lcC, m_lcD; - float32 m_mA, m_mB, m_mC, m_mD; - float32 m_iA, m_iB, m_iC, m_iD; - b2Vec2 m_JvAC, m_JvBD; - float32 m_JwA, m_JwB, m_JwC, m_JwD; - float32 m_mass; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2Joint.cpp b/sources/Box2D/Dynamics/Joints/b2Joint.cpp deleted file mode 100755 index 7a6cf7a4..00000000 --- a/sources/Box2D/Dynamics/Joints/b2Joint.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -b2Joint* b2Joint::Create(const b2JointDef* def, b2BlockAllocator* allocator) -{ - b2Joint* joint = NULL; - - switch (def->type) - { - case e_distanceJoint: - { - void* mem = allocator->Allocate(sizeof(b2DistanceJoint)); - joint = new (mem) b2DistanceJoint(static_cast(def)); - } - break; - - case e_mouseJoint: - { - void* mem = allocator->Allocate(sizeof(b2MouseJoint)); - joint = new (mem) b2MouseJoint(static_cast(def)); - } - break; - - case e_prismaticJoint: - { - void* mem = allocator->Allocate(sizeof(b2PrismaticJoint)); - joint = new (mem) b2PrismaticJoint(static_cast(def)); - } - break; - - case e_revoluteJoint: - { - void* mem = allocator->Allocate(sizeof(b2RevoluteJoint)); - joint = new (mem) b2RevoluteJoint(static_cast(def)); - } - break; - - case e_pulleyJoint: - { - void* mem = allocator->Allocate(sizeof(b2PulleyJoint)); - joint = new (mem) b2PulleyJoint(static_cast(def)); - } - break; - - case e_gearJoint: - { - void* mem = allocator->Allocate(sizeof(b2GearJoint)); - joint = new (mem) b2GearJoint(static_cast(def)); - } - break; - - case e_wheelJoint: - { - void* mem = allocator->Allocate(sizeof(b2WheelJoint)); - joint = new (mem) b2WheelJoint(static_cast(def)); - } - break; - - case e_weldJoint: - { - void* mem = allocator->Allocate(sizeof(b2WeldJoint)); - joint = new (mem) b2WeldJoint(static_cast(def)); - } - break; - - case e_frictionJoint: - { - void* mem = allocator->Allocate(sizeof(b2FrictionJoint)); - joint = new (mem) b2FrictionJoint(static_cast(def)); - } - break; - - case e_ropeJoint: - { - void* mem = allocator->Allocate(sizeof(b2RopeJoint)); - joint = new (mem) b2RopeJoint(static_cast(def)); - } - break; - - case e_motorJoint: - { - void* mem = allocator->Allocate(sizeof(b2MotorJoint)); - joint = new (mem) b2MotorJoint(static_cast(def)); - } - break; - - default: - b2Assert(false); - break; - } - - return joint; -} - -void b2Joint::Destroy(b2Joint* joint, b2BlockAllocator* allocator) -{ - b2NotifyObjectDestroyed(joint, b2ObjectType::JOIN, typeid(*joint).name()); - joint->~b2Joint(); - switch (joint->m_type) - { - case e_distanceJoint: - allocator->Free(joint, sizeof(b2DistanceJoint)); - break; - - case e_mouseJoint: - allocator->Free(joint, sizeof(b2MouseJoint)); - break; - - case e_prismaticJoint: - allocator->Free(joint, sizeof(b2PrismaticJoint)); - break; - - case e_revoluteJoint: - allocator->Free(joint, sizeof(b2RevoluteJoint)); - break; - - case e_pulleyJoint: - allocator->Free(joint, sizeof(b2PulleyJoint)); - break; - - case e_gearJoint: - allocator->Free(joint, sizeof(b2GearJoint)); - break; - - case e_wheelJoint: - allocator->Free(joint, sizeof(b2WheelJoint)); - break; - - case e_weldJoint: - allocator->Free(joint, sizeof(b2WeldJoint)); - break; - - case e_frictionJoint: - allocator->Free(joint, sizeof(b2FrictionJoint)); - break; - - case e_ropeJoint: - allocator->Free(joint, sizeof(b2RopeJoint)); - break; - - case e_motorJoint: - allocator->Free(joint, sizeof(b2MotorJoint)); - break; - - default: - b2Assert(false); - break; - } -} - -b2Joint::b2Joint(const b2JointDef* def) -{ - b2Assert(def->bodyA != def->bodyB); - - m_type = def->type; - m_prev = NULL; - m_next = NULL; - m_bodyA = def->bodyA; - m_bodyB = def->bodyB; - m_index = 0; - m_collideConnected = def->collideConnected; - m_islandFlag = false; - m_userData = def->userData; - - m_edgeA.joint = NULL; - m_edgeA.other = NULL; - m_edgeA.prev = NULL; - m_edgeA.next = NULL; - - m_edgeB.joint = NULL; - m_edgeB.other = NULL; - m_edgeB.prev = NULL; - m_edgeB.next = NULL; -} - -bool b2Joint::IsActive() const -{ - return m_bodyA->IsActive() && m_bodyB->IsActive(); -} diff --git a/sources/Box2D/Dynamics/Joints/b2Joint.h b/sources/Box2D/Dynamics/Joints/b2Joint.h deleted file mode 100755 index f6002e50..00000000 --- a/sources/Box2D/Dynamics/Joints/b2Joint.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_JOINT_H -#define B2_JOINT_H - -#include - -class b2Body; -class b2Joint; -struct b2SolverData; -class b2BlockAllocator; - -enum b2JointType -{ - e_unknownJoint, - e_revoluteJoint, - e_prismaticJoint, - e_distanceJoint, - e_pulleyJoint, - e_mouseJoint, - e_gearJoint, - e_wheelJoint, - e_weldJoint, - e_frictionJoint, - e_ropeJoint, - e_motorJoint -}; - -enum b2LimitState -{ - e_inactiveLimit, - e_atLowerLimit, - e_atUpperLimit, - e_equalLimits -}; - -struct b2Jacobian -{ - b2Vec2 linear; - float32 angularA; - float32 angularB; -}; - -/// A joint edge is used to connect bodies and joints together -/// in a joint graph where each body is a node and each joint -/// is an edge. A joint edge belongs to a doubly linked list -/// maintained in each attached body. Each joint has two joint -/// nodes, one for each attached body. -struct b2JointEdge -{ - b2Body* other; ///< provides quick access to the other body attached. - b2Joint* joint; ///< the joint - b2JointEdge* prev; ///< the previous joint edge in the body's joint list - b2JointEdge* next; ///< the next joint edge in the body's joint list -}; - -/// Joint definitions are used to construct joints. -struct b2JointDef -{ - b2JointDef() - { - type = e_unknownJoint; - userData = NULL; - bodyA = NULL; - bodyB = NULL; - collideConnected = false; - } - - /// The joint type is set automatically for concrete joint types. - b2JointType type; - - /// Use this to attach application specific data to your joints. - void* userData; - - /// The first attached body. - b2Body* bodyA; - - /// The second attached body. - b2Body* bodyB; - - /// Set this flag to true if the attached bodies should collide. - bool collideConnected; -}; - -/// The base joint class. Joints are used to constraint two bodies together in -/// various fashions. Some joints also feature limits and motors. -class b2Joint -{ -public: - - /// Get the type of the concrete joint. - b2JointType GetType() const; - - /// Get the first body attached to this joint. - b2Body* GetBodyA(); - - /// Get the second body attached to this joint. - b2Body* GetBodyB(); - - /// Get the anchor point on bodyA in world coordinates. - virtual b2Vec2 GetAnchorA() const = 0; - - /// Get the anchor point on bodyB in world coordinates. - virtual b2Vec2 GetAnchorB() const = 0; - - /// Get the reaction force on bodyB at the joint anchor in Newtons. - virtual b2Vec2 GetReactionForce(float32 inv_dt) const = 0; - - /// Get the reaction torque on bodyB in N*m. - virtual float32 GetReactionTorque(float32 inv_dt) const = 0; - - /// Get the next joint the world joint list. - b2Joint* GetNext(); - const b2Joint* GetNext() const; - - /// Get the user data pointer. - void* GetUserData() const; - - /// Set the user data pointer. - void SetUserData(void* data); - - /// Short-cut function to determine if either body is inactive. - bool IsActive() const; - - /// Get collide connected. - /// Note: modifying the collide connect flag won't work correctly because - /// the flag is only checked when fixture AABBs begin to overlap. - bool GetCollideConnected() const; - - /// Dump this joint to the log file. - virtual void Dump() { b2Log("// Dump is not supported for this joint type.\n"); } - - /// Shift the origin for any points stored in world coordinates. - virtual void ShiftOrigin(const b2Vec2& newOrigin) { B2_NOT_USED(newOrigin); } - -protected: - friend class b2World; - friend class b2Body; - friend class b2Island; - friend class b2GearJoint; - - static b2Joint* Create(const b2JointDef* def, b2BlockAllocator* allocator); - static void Destroy(b2Joint* joint, b2BlockAllocator* allocator); - - b2Joint(const b2JointDef* def); - virtual ~b2Joint() {} - - virtual void InitVelocityConstraints(const b2SolverData& data) = 0; - virtual void SolveVelocityConstraints(const b2SolverData& data) = 0; - - // This returns true if the position errors are within tolerance. - virtual bool SolvePositionConstraints(const b2SolverData& data) = 0; - - b2JointType m_type; - b2Joint* m_prev; - b2Joint* m_next; - b2JointEdge m_edgeA; - b2JointEdge m_edgeB; - b2Body* m_bodyA; - b2Body* m_bodyB; - - int32 m_index; - - bool m_islandFlag; - bool m_collideConnected; - - void* m_userData; -}; - -inline b2JointType b2Joint::GetType() const -{ - return m_type; -} - -inline b2Body* b2Joint::GetBodyA() -{ - return m_bodyA; -} - -inline b2Body* b2Joint::GetBodyB() -{ - return m_bodyB; -} - -inline b2Joint* b2Joint::GetNext() -{ - return m_next; -} - -inline const b2Joint* b2Joint::GetNext() const -{ - return m_next; -} - -inline void* b2Joint::GetUserData() const -{ - return m_userData; -} - -inline void b2Joint::SetUserData(void* data) -{ - m_userData = data; -} - -inline bool b2Joint::GetCollideConnected() const -{ - return m_collideConnected; -} - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2MotorJoint.cpp b/sources/Box2D/Dynamics/Joints/b2MotorJoint.cpp deleted file mode 100755 index a07a6401..00000000 --- a/sources/Box2D/Dynamics/Joints/b2MotorJoint.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* -* Copyright (c) 2006-2012 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Point-to-point constraint -// Cdot = v2 - v1 -// = v2 + cross(w2, r2) - v1 - cross(w1, r1) -// J = [-I -r1_skew I r2_skew ] -// Identity used: -// w k % (rx i + ry j) = w * (-ry i + rx j) - -// Angle constraint -// Cdot = w2 - w1 -// J = [0 0 -1 0 0 1] -// K = invI1 + invI2 - -void b2MotorJointDef::Initialize(b2Body* bA, b2Body* bB) -{ - bodyA = bA; - bodyB = bB; - b2Vec2 xB = bodyB->GetPosition(); - linearOffset = bodyA->GetLocalPoint(xB); - - float32 angleA = bodyA->GetAngle(); - float32 angleB = bodyB->GetAngle(); - angularOffset = angleB - angleA; -} - -b2MotorJoint::b2MotorJoint(const b2MotorJointDef* def) -: b2Joint(def) -{ - m_linearOffset = def->linearOffset; - m_angularOffset = def->angularOffset; - - m_linearImpulse.SetZero(); - m_angularImpulse = 0.0f; - - m_maxForce = def->maxForce; - m_maxTorque = def->maxTorque; - m_correctionFactor = def->correctionFactor; -} - -void b2MotorJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - // Compute the effective mass matrix. - m_rA = b2Mul(qA, -m_localCenterA); - m_rB = b2Mul(qB, -m_localCenterB); - - // J = [-I -r1_skew I r2_skew] - // [ 0 -1 0 1] - // r_skew = [-ry; rx] - - // Matlab - // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB] - // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB] - // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB] - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Mat22 K; - K.ex.x = mA + mB + iA * m_rA.y * m_rA.y + iB * m_rB.y * m_rB.y; - K.ex.y = -iA * m_rA.x * m_rA.y - iB * m_rB.x * m_rB.y; - K.ey.x = K.ex.y; - K.ey.y = mA + mB + iA * m_rA.x * m_rA.x + iB * m_rB.x * m_rB.x; - - m_linearMass = K.GetInverse(); - - m_angularMass = iA + iB; - if (m_angularMass > 0.0f) - { - m_angularMass = 1.0f / m_angularMass; - } - - m_linearError = cB + m_rB - cA - m_rA - b2Mul(qA, m_linearOffset); - m_angularError = aB - aA - m_angularOffset; - - if (data.step.warmStarting) - { - // Scale impulses to support a variable time step. - m_linearImpulse *= data.step.dtRatio; - m_angularImpulse *= data.step.dtRatio; - - b2Vec2 P(m_linearImpulse.x, m_linearImpulse.y); - vA -= mA * P; - wA -= iA * (b2Cross(m_rA, P) + m_angularImpulse); - vB += mB * P; - wB += iB * (b2Cross(m_rB, P) + m_angularImpulse); - } - else - { - m_linearImpulse.SetZero(); - m_angularImpulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2MotorJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - float32 h = data.step.dt; - float32 inv_h = data.step.inv_dt; - - // Solve angular friction - { - float32 Cdot = wB - wA + inv_h * m_correctionFactor * m_angularError; - float32 impulse = -m_angularMass * Cdot; - - float32 oldImpulse = m_angularImpulse; - float32 maxImpulse = h * m_maxTorque; - m_angularImpulse = b2Clamp(m_angularImpulse + impulse, -maxImpulse, maxImpulse); - impulse = m_angularImpulse - oldImpulse; - - wA -= iA * impulse; - wB += iB * impulse; - } - - // Solve linear friction - { - b2Vec2 Cdot = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA) + inv_h * m_correctionFactor * m_linearError; - - b2Vec2 impulse = -b2Mul(m_linearMass, Cdot); - b2Vec2 oldImpulse = m_linearImpulse; - m_linearImpulse += impulse; - - float32 maxImpulse = h * m_maxForce; - - if (m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) - { - m_linearImpulse.Normalize(); - m_linearImpulse *= maxImpulse; - } - - impulse = m_linearImpulse - oldImpulse; - - vA -= mA * impulse; - wA -= iA * b2Cross(m_rA, impulse); - - vB += mB * impulse; - wB += iB * b2Cross(m_rB, impulse); - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2MotorJoint::SolvePositionConstraints(const b2SolverData& data) -{ - B2_NOT_USED(data); - - return true; -} - -b2Vec2 b2MotorJoint::GetAnchorA() const -{ - return m_bodyA->GetPosition(); -} - -b2Vec2 b2MotorJoint::GetAnchorB() const -{ - return m_bodyB->GetPosition(); -} - -b2Vec2 b2MotorJoint::GetReactionForce(float32 inv_dt) const -{ - return inv_dt * m_linearImpulse; -} - -float32 b2MotorJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * m_angularImpulse; -} - -void b2MotorJoint::SetMaxForce(float32 force) -{ - b2Assert(b2IsValid(force) && force >= 0.0f); - m_maxForce = force; -} - -float32 b2MotorJoint::GetMaxForce() const -{ - return m_maxForce; -} - -void b2MotorJoint::SetMaxTorque(float32 torque) -{ - b2Assert(b2IsValid(torque) && torque >= 0.0f); - m_maxTorque = torque; -} - -float32 b2MotorJoint::GetMaxTorque() const -{ - return m_maxTorque; -} - -void b2MotorJoint::SetCorrectionFactor(float32 factor) -{ - b2Assert(b2IsValid(factor) && 0.0f <= factor && factor <= 1.0f); - m_correctionFactor = factor; -} - -float32 b2MotorJoint::GetCorrectionFactor() const -{ - return m_correctionFactor; -} - -void b2MotorJoint::SetLinearOffset(const b2Vec2& linearOffset) -{ - if (linearOffset.x != m_linearOffset.x || linearOffset.y != m_linearOffset.y) - { - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_linearOffset = linearOffset; - } -} - -const b2Vec2& b2MotorJoint::GetLinearOffset() const -{ - return m_linearOffset; -} - -void b2MotorJoint::SetAngularOffset(float32 angularOffset) -{ - if (angularOffset != m_angularOffset) - { - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_angularOffset = angularOffset; - } -} - -float32 b2MotorJoint::GetAngularOffset() const -{ - return m_angularOffset; -} - -void b2MotorJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2MotorJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.linearOffset.Set(%.15lef, %.15lef);\n", m_linearOffset.x, m_linearOffset.y); - b2Log(" jd.angularOffset = %.15lef;\n", m_angularOffset); - b2Log(" jd.maxForce = %.15lef;\n", m_maxForce); - b2Log(" jd.maxTorque = %.15lef;\n", m_maxTorque); - b2Log(" jd.correctionFactor = %.15lef;\n", m_correctionFactor); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2MotorJoint.h b/sources/Box2D/Dynamics/Joints/b2MotorJoint.h deleted file mode 100755 index 486225b9..00000000 --- a/sources/Box2D/Dynamics/Joints/b2MotorJoint.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -* Copyright (c) 2006-2012 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_MOTOR_JOINT_H -#define B2_MOTOR_JOINT_H - -#include - -/// Motor joint definition. -struct b2MotorJointDef : public b2JointDef -{ - b2MotorJointDef() - { - type = e_motorJoint; - linearOffset.SetZero(); - angularOffset = 0.0f; - maxForce = 1.0f; - maxTorque = 1.0f; - correctionFactor = 0.3f; - } - - /// Initialize the bodies and offsets using the current transforms. - void Initialize(b2Body* bodyA, b2Body* bodyB); - - /// Position of bodyB minus the position of bodyA, in bodyA's frame, in meters. - b2Vec2 linearOffset; - - /// The bodyB angle minus bodyA angle in radians. - float32 angularOffset; - - /// The maximum motor force in N. - float32 maxForce; - - /// The maximum motor torque in N-m. - float32 maxTorque; - - /// Position correction factor in the range [0,1]. - float32 correctionFactor; -}; - -/// A motor joint is used to control the relative motion -/// between two bodies. A typical usage is to control the movement -/// of a dynamic body with respect to the ground. -class b2MotorJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// Set/get the target linear offset, in frame A, in meters. - void SetLinearOffset(const b2Vec2& linearOffset); - const b2Vec2& GetLinearOffset() const; - - /// Set/get the target angular offset, in radians. - void SetAngularOffset(float32 angularOffset); - float32 GetAngularOffset() const; - - /// Set the maximum friction force in N. - void SetMaxForce(float32 force); - - /// Get the maximum friction force in N. - float32 GetMaxForce() const; - - /// Set the maximum friction torque in N*m. - void SetMaxTorque(float32 torque); - - /// Get the maximum friction torque in N*m. - float32 GetMaxTorque() const; - - /// Set the position correction factor in the range [0,1]. - void SetCorrectionFactor(float32 factor); - - /// Get the position correction factor in the range [0,1]. - float32 GetCorrectionFactor() const; - - /// Dump to b2Log - void Dump(); - -protected: - - friend class b2Joint; - - b2MotorJoint(const b2MotorJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - // Solver shared - b2Vec2 m_linearOffset; - float32 m_angularOffset; - b2Vec2 m_linearImpulse; - float32 m_angularImpulse; - float32 m_maxForce; - float32 m_maxTorque; - float32 m_correctionFactor; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - b2Vec2 m_linearError; - float32 m_angularError; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - b2Mat22 m_linearMass; - float32 m_angularMass; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2MouseJoint.cpp b/sources/Box2D/Dynamics/Joints/b2MouseJoint.cpp deleted file mode 100755 index eb1de9d3..00000000 --- a/sources/Box2D/Dynamics/Joints/b2MouseJoint.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// p = attached point, m = mouse point -// C = p - m -// Cdot = v -// = v + cross(w, r) -// J = [I r_skew] -// Identity used: -// w k % (rx i + ry j) = w * (-ry i + rx j) - -b2MouseJoint::b2MouseJoint(const b2MouseJointDef* def) -: b2Joint(def) -{ - b2Assert(def->target.IsValid()); - b2Assert(b2IsValid(def->maxForce) && def->maxForce >= 0.0f); - b2Assert(b2IsValid(def->frequencyHz) && def->frequencyHz >= 0.0f); - b2Assert(b2IsValid(def->dampingRatio) && def->dampingRatio >= 0.0f); - - m_targetA = def->target; - m_localAnchorB = b2MulT(m_bodyB->GetTransform(), m_targetA); - - m_maxForce = def->maxForce; - m_impulse.SetZero(); - - m_frequencyHz = def->frequencyHz; - m_dampingRatio = def->dampingRatio; - - m_beta = 0.0f; - m_gamma = 0.0f; -} - -void b2MouseJoint::SetTarget(const b2Vec2& target) -{ - if (m_bodyB->IsAwake() == false) - { - m_bodyB->SetAwake(true); - } - m_targetA = target; -} - -const b2Vec2& b2MouseJoint::GetTarget() const -{ - return m_targetA; -} - -void b2MouseJoint::SetMaxForce(float32 force) -{ - m_maxForce = force; -} - -float32 b2MouseJoint::GetMaxForce() const -{ - return m_maxForce; -} - -void b2MouseJoint::SetFrequency(float32 hz) -{ - m_frequencyHz = hz; -} - -float32 b2MouseJoint::GetFrequency() const -{ - return m_frequencyHz; -} - -void b2MouseJoint::SetDampingRatio(float32 ratio) -{ - m_dampingRatio = ratio; -} - -float32 b2MouseJoint::GetDampingRatio() const -{ - return m_dampingRatio; -} - -void b2MouseJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexB = m_bodyB->m_islandIndex; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassB = m_bodyB->m_invMass; - m_invIB = m_bodyB->m_invI; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qB(aB); - - float32 mass = m_bodyB->GetMass(); - - // Frequency - float32 omega = 2.0f * b2_pi * m_frequencyHz; - - // Damping coefficient - float32 d = 2.0f * mass * m_dampingRatio * omega; - - // Spring stiffness - float32 k = mass * (omega * omega); - - // magic formulas - // gamma has units of inverse mass. - // beta has units of inverse time. - float32 h = data.step.dt; - b2Assert(d + h * k > b2_epsilon); - m_gamma = h * (d + h * k); - if (m_gamma != 0.0f) - { - m_gamma = 1.0f / m_gamma; - } - m_beta = h * k * m_gamma; - - // Compute the effective mass matrix. - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - // K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)] - // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y] - // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x] - b2Mat22 K; - K.ex.x = m_invMassB + m_invIB * m_rB.y * m_rB.y + m_gamma; - K.ex.y = -m_invIB * m_rB.x * m_rB.y; - K.ey.x = K.ex.y; - K.ey.y = m_invMassB + m_invIB * m_rB.x * m_rB.x + m_gamma; - - m_mass = K.GetInverse(); - - m_C = cB + m_rB - m_targetA; - m_C *= m_beta; - - // Cheat with some damping - wB *= 0.98f; - - if (data.step.warmStarting) - { - m_impulse *= data.step.dtRatio; - vB += m_invMassB * m_impulse; - wB += m_invIB * b2Cross(m_rB, m_impulse); - } - else - { - m_impulse.SetZero(); - } - - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2MouseJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - // Cdot = v + cross(w, r) - b2Vec2 Cdot = vB + b2Cross(wB, m_rB); - b2Vec2 impulse = b2Mul(m_mass, -(Cdot + m_C + m_gamma * m_impulse)); - - b2Vec2 oldImpulse = m_impulse; - m_impulse += impulse; - float32 maxImpulse = data.step.dt * m_maxForce; - if (m_impulse.LengthSquared() > maxImpulse * maxImpulse) - { - m_impulse *= maxImpulse / m_impulse.Length(); - } - impulse = m_impulse - oldImpulse; - - vB += m_invMassB * impulse; - wB += m_invIB * b2Cross(m_rB, impulse); - - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2MouseJoint::SolvePositionConstraints(const b2SolverData& data) -{ - B2_NOT_USED(data); - return true; -} - -b2Vec2 b2MouseJoint::GetAnchorA() const -{ - return m_targetA; -} - -b2Vec2 b2MouseJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2MouseJoint::GetReactionForce(float32 inv_dt) const -{ - return inv_dt * m_impulse; -} - -float32 b2MouseJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * 0.0f; -} - -void b2MouseJoint::ShiftOrigin(const b2Vec2& newOrigin) -{ - m_targetA -= newOrigin; -} diff --git a/sources/Box2D/Dynamics/Joints/b2MouseJoint.h b/sources/Box2D/Dynamics/Joints/b2MouseJoint.h deleted file mode 100755 index aba70ec1..00000000 --- a/sources/Box2D/Dynamics/Joints/b2MouseJoint.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_MOUSE_JOINT_H -#define B2_MOUSE_JOINT_H - -#include - -/// Mouse joint definition. This requires a world target point, -/// tuning parameters, and the time step. -struct b2MouseJointDef : public b2JointDef -{ - b2MouseJointDef() - { - type = e_mouseJoint; - target.Set(0.0f, 0.0f); - maxForce = 0.0f; - frequencyHz = 5.0f; - dampingRatio = 0.7f; - } - - /// The initial world target point. This is assumed - /// to coincide with the body anchor initially. - b2Vec2 target; - - /// The maximum constraint force that can be exerted - /// to move the candidate body. Usually you will express - /// as some multiple of the weight (multiplier * mass * gravity). - float32 maxForce; - - /// The response speed. - float32 frequencyHz; - - /// The damping ratio. 0 = no damping, 1 = critical damping. - float32 dampingRatio; -}; - -/// A mouse joint is used to make a point on a body track a -/// specified world point. This a soft constraint with a maximum -/// force. This allows the constraint to stretch and without -/// applying huge forces. -/// NOTE: this joint is not documented in the manual because it was -/// developed to be used in the testbed. If you want to learn how to -/// use the mouse joint, look at the testbed. -class b2MouseJoint : public b2Joint -{ -public: - - /// Implements b2Joint. - b2Vec2 GetAnchorA() const; - - /// Implements b2Joint. - b2Vec2 GetAnchorB() const; - - /// Implements b2Joint. - b2Vec2 GetReactionForce(float32 inv_dt) const; - - /// Implements b2Joint. - float32 GetReactionTorque(float32 inv_dt) const; - - /// Use this to update the target point. - void SetTarget(const b2Vec2& target); - const b2Vec2& GetTarget() const; - - /// Set/get the maximum force in Newtons. - void SetMaxForce(float32 force); - float32 GetMaxForce() const; - - /// Set/get the frequency in Hertz. - void SetFrequency(float32 hz); - float32 GetFrequency() const; - - /// Set/get the damping ratio (dimensionless). - void SetDampingRatio(float32 ratio); - float32 GetDampingRatio() const; - - /// The mouse joint does not support dumping. - void Dump() { b2Log("Mouse joint dumping is not supported.\n"); } - - /// Implement b2Joint::ShiftOrigin - void ShiftOrigin(const b2Vec2& newOrigin); - -protected: - friend class b2Joint; - - b2MouseJoint(const b2MouseJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - b2Vec2 m_localAnchorB; - b2Vec2 m_targetA; - float32 m_frequencyHz; - float32 m_dampingRatio; - float32 m_beta; - - // Solver shared - b2Vec2 m_impulse; - float32 m_maxForce; - float32 m_gamma; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_rB; - b2Vec2 m_localCenterB; - float32 m_invMassB; - float32 m_invIB; - b2Mat22 m_mass; - b2Vec2 m_C; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp b/sources/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp deleted file mode 100755 index 2da77b84..00000000 --- a/sources/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp +++ /dev/null @@ -1,629 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Linear constraint (point-to-line) -// d = p2 - p1 = x2 + r2 - x1 - r1 -// C = dot(perp, d) -// Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 - cross(w1, r1)) -// = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) + dot(cross(r2, perp), v2) -// J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)] -// -// Angular constraint -// C = a2 - a1 + a_initial -// Cdot = w2 - w1 -// J = [0 0 -1 0 0 1] -// -// K = J * invM * JT -// -// J = [-a -s1 a s2] -// [0 -1 0 1] -// a = perp -// s1 = cross(d + r1, a) = cross(p2 - x1, a) -// s2 = cross(r2, a) = cross(p2 - x2, a) - - -// Motor/Limit linear constraint -// C = dot(ax1, d) -// Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2) -// J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)] - -// Block Solver -// We develop a block solver that includes the joint limit. This makes the limit stiff (inelastic) even -// when the mass has poor distribution (leading to large torques about the joint anchor points). -// -// The Jacobian has 3 rows: -// J = [-uT -s1 uT s2] // linear -// [0 -1 0 1] // angular -// [-vT -a1 vT a2] // limit -// -// u = perp -// v = axis -// s1 = cross(d + r1, u), s2 = cross(r2, u) -// a1 = cross(d + r1, v), a2 = cross(r2, v) - -// M * (v2 - v1) = JT * df -// J * v2 = bias -// -// v2 = v1 + invM * JT * df -// J * (v1 + invM * JT * df) = bias -// K * df = bias - J * v1 = -Cdot -// K = J * invM * JT -// Cdot = J * v1 - bias -// -// Now solve for f2. -// df = f2 - f1 -// K * (f2 - f1) = -Cdot -// f2 = invK * (-Cdot) + f1 -// -// Clamp accumulated limit impulse. -// lower: f2(3) = max(f2(3), 0) -// upper: f2(3) = min(f2(3), 0) -// -// Solve for correct f2(1:2) -// K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1 -// = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3) -// K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) + K(1:2,1:2) * f1(1:2) -// f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) + f1(1:2) -// -// Now compute impulse to be applied: -// df = f2 - f1 - -void b2PrismaticJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor, const b2Vec2& axis) -{ - bodyA = bA; - bodyB = bB; - localAnchorA = bodyA->GetLocalPoint(anchor); - localAnchorB = bodyB->GetLocalPoint(anchor); - localAxisA = bodyA->GetLocalVector(axis); - referenceAngle = bodyB->GetAngle() - bodyA->GetAngle(); -} - -b2PrismaticJoint::b2PrismaticJoint(const b2PrismaticJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - m_localXAxisA = def->localAxisA; - m_localXAxisA.Normalize(); - m_localYAxisA = b2Cross(1.0f, m_localXAxisA); - m_referenceAngle = def->referenceAngle; - - m_impulse.SetZero(); - m_motorMass = 0.0f; - m_motorImpulse = 0.0f; - - m_lowerTranslation = def->lowerTranslation; - m_upperTranslation = def->upperTranslation; - m_maxMotorForce = def->maxMotorForce; - m_motorSpeed = def->motorSpeed; - m_enableLimit = def->enableLimit; - m_enableMotor = def->enableMotor; - m_limitState = e_inactiveLimit; - - m_axis.SetZero(); - m_perp.SetZero(); -} - -void b2PrismaticJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - // Compute the effective masses. - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - b2Vec2 d = (cB - cA) + rB - rA; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - // Compute motor Jacobian and effective mass. - { - m_axis = b2Mul(qA, m_localXAxisA); - m_a1 = b2Cross(d + rA, m_axis); - m_a2 = b2Cross(rB, m_axis); - - m_motorMass = mA + mB + iA * m_a1 * m_a1 + iB * m_a2 * m_a2; - if (m_motorMass > 0.0f) - { - m_motorMass = 1.0f / m_motorMass; - } - } - - // Prismatic constraint. - { - m_perp = b2Mul(qA, m_localYAxisA); - - m_s1 = b2Cross(d + rA, m_perp); - m_s2 = b2Cross(rB, m_perp); - - float32 s1test; - s1test = b2Cross(rA, m_perp); - - float32 k11 = mA + mB + iA * m_s1 * m_s1 + iB * m_s2 * m_s2; - float32 k12 = iA * m_s1 + iB * m_s2; - float32 k13 = iA * m_s1 * m_a1 + iB * m_s2 * m_a2; - float32 k22 = iA + iB; - if (k22 == 0.0f) - { - // For bodies with fixed rotation. - k22 = 1.0f; - } - float32 k23 = iA * m_a1 + iB * m_a2; - float32 k33 = mA + mB + iA * m_a1 * m_a1 + iB * m_a2 * m_a2; - - m_K.ex.Set(k11, k12, k13); - m_K.ey.Set(k12, k22, k23); - m_K.ez.Set(k13, k23, k33); - } - - // Compute motor and limit terms. - if (m_enableLimit) - { - float32 jointTranslation = b2Dot(m_axis, d); - if (b2Abs(m_upperTranslation - m_lowerTranslation) < 2.0f * b2_linearSlop) - { - m_limitState = e_equalLimits; - } - else if (jointTranslation <= m_lowerTranslation) - { - if (m_limitState != e_atLowerLimit) - { - m_limitState = e_atLowerLimit; - m_impulse.z = 0.0f; - } - } - else if (jointTranslation >= m_upperTranslation) - { - if (m_limitState != e_atUpperLimit) - { - m_limitState = e_atUpperLimit; - m_impulse.z = 0.0f; - } - } - else - { - m_limitState = e_inactiveLimit; - m_impulse.z = 0.0f; - } - } - else - { - m_limitState = e_inactiveLimit; - m_impulse.z = 0.0f; - } - - if (m_enableMotor == false) - { - m_motorImpulse = 0.0f; - } - - if (data.step.warmStarting) - { - // Account for variable time step. - m_impulse *= data.step.dtRatio; - m_motorImpulse *= data.step.dtRatio; - - b2Vec2 P = m_impulse.x * m_perp + (m_motorImpulse + m_impulse.z) * m_axis; - float32 LA = m_impulse.x * m_s1 + m_impulse.y + (m_motorImpulse + m_impulse.z) * m_a1; - float32 LB = m_impulse.x * m_s2 + m_impulse.y + (m_motorImpulse + m_impulse.z) * m_a2; - - vA -= mA * P; - wA -= iA * LA; - - vB += mB * P; - wB += iB * LB; - } - else - { - m_impulse.SetZero(); - m_motorImpulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2PrismaticJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - // Solve linear motor constraint. - if (m_enableMotor && m_limitState != e_equalLimits) - { - float32 Cdot = b2Dot(m_axis, vB - vA) + m_a2 * wB - m_a1 * wA; - float32 impulse = m_motorMass * (m_motorSpeed - Cdot); - float32 oldImpulse = m_motorImpulse; - float32 maxImpulse = data.step.dt * m_maxMotorForce; - m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse); - impulse = m_motorImpulse - oldImpulse; - - b2Vec2 P = impulse * m_axis; - float32 LA = impulse * m_a1; - float32 LB = impulse * m_a2; - - vA -= mA * P; - wA -= iA * LA; - - vB += mB * P; - wB += iB * LB; - } - - b2Vec2 Cdot1; - Cdot1.x = b2Dot(m_perp, vB - vA) + m_s2 * wB - m_s1 * wA; - Cdot1.y = wB - wA; - - if (m_enableLimit && m_limitState != e_inactiveLimit) - { - // Solve prismatic and limit constraint in block form. - float32 Cdot2; - Cdot2 = b2Dot(m_axis, vB - vA) + m_a2 * wB - m_a1 * wA; - b2Vec3 Cdot(Cdot1.x, Cdot1.y, Cdot2); - - b2Vec3 f1 = m_impulse; - b2Vec3 df = m_K.Solve33(-Cdot); - m_impulse += df; - - if (m_limitState == e_atLowerLimit) - { - m_impulse.z = b2Max(m_impulse.z, 0.0f); - } - else if (m_limitState == e_atUpperLimit) - { - m_impulse.z = b2Min(m_impulse.z, 0.0f); - } - - // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) + f1(1:2) - b2Vec2 b = -Cdot1 - (m_impulse.z - f1.z) * b2Vec2(m_K.ez.x, m_K.ez.y); - b2Vec2 f2r = m_K.Solve22(b) + b2Vec2(f1.x, f1.y); - m_impulse.x = f2r.x; - m_impulse.y = f2r.y; - - df = m_impulse - f1; - - b2Vec2 P = df.x * m_perp + df.z * m_axis; - float32 LA = df.x * m_s1 + df.y + df.z * m_a1; - float32 LB = df.x * m_s2 + df.y + df.z * m_a2; - - vA -= mA * P; - wA -= iA * LA; - - vB += mB * P; - wB += iB * LB; - } - else - { - // Limit is inactive, just solve the prismatic constraint in block form. - b2Vec2 df = m_K.Solve22(-Cdot1); - m_impulse.x += df.x; - m_impulse.y += df.y; - - b2Vec2 P = df.x * m_perp; - float32 LA = df.x * m_s1 + df.y; - float32 LB = df.x * m_s2 + df.y; - - vA -= mA * P; - wA -= iA * LA; - - vB += mB * P; - wB += iB * LB; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2PrismaticJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - // Compute fresh Jacobians - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - b2Vec2 d = cB + rB - cA - rA; - - b2Vec2 axis = b2Mul(qA, m_localXAxisA); - float32 a1 = b2Cross(d + rA, axis); - float32 a2 = b2Cross(rB, axis); - b2Vec2 perp = b2Mul(qA, m_localYAxisA); - - float32 s1 = b2Cross(d + rA, perp); - float32 s2 = b2Cross(rB, perp); - - b2Vec3 impulse; - b2Vec2 C1; - C1.x = b2Dot(perp, d); - C1.y = aB - aA - m_referenceAngle; - - float32 linearError = b2Abs(C1.x); - float32 angularError = b2Abs(C1.y); - - bool active = false; - float32 C2 = 0.0f; - if (m_enableLimit) - { - float32 translation = b2Dot(axis, d); - if (b2Abs(m_upperTranslation - m_lowerTranslation) < 2.0f * b2_linearSlop) - { - // Prevent large angular corrections - C2 = b2Clamp(translation, -b2_maxLinearCorrection, b2_maxLinearCorrection); - linearError = b2Max(linearError, b2Abs(translation)); - active = true; - } - else if (translation <= m_lowerTranslation) - { - // Prevent large linear corrections and allow some slop. - C2 = b2Clamp(translation - m_lowerTranslation + b2_linearSlop, -b2_maxLinearCorrection, 0.0f); - linearError = b2Max(linearError, m_lowerTranslation - translation); - active = true; - } - else if (translation >= m_upperTranslation) - { - // Prevent large linear corrections and allow some slop. - C2 = b2Clamp(translation - m_upperTranslation - b2_linearSlop, 0.0f, b2_maxLinearCorrection); - linearError = b2Max(linearError, translation - m_upperTranslation); - active = true; - } - } - - if (active) - { - float32 k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2; - float32 k12 = iA * s1 + iB * s2; - float32 k13 = iA * s1 * a1 + iB * s2 * a2; - float32 k22 = iA + iB; - if (k22 == 0.0f) - { - // For fixed rotation - k22 = 1.0f; - } - float32 k23 = iA * a1 + iB * a2; - float32 k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2; - - b2Mat33 K; - K.ex.Set(k11, k12, k13); - K.ey.Set(k12, k22, k23); - K.ez.Set(k13, k23, k33); - - b2Vec3 C; - C.x = C1.x; - C.y = C1.y; - C.z = C2; - - impulse = K.Solve33(-C); - } - else - { - float32 k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2; - float32 k12 = iA * s1 + iB * s2; - float32 k22 = iA + iB; - if (k22 == 0.0f) - { - k22 = 1.0f; - } - - b2Mat22 K; - K.ex.Set(k11, k12); - K.ey.Set(k12, k22); - - b2Vec2 impulse1 = K.Solve(-C1); - impulse.x = impulse1.x; - impulse.y = impulse1.y; - impulse.z = 0.0f; - } - - b2Vec2 P = impulse.x * perp + impulse.z * axis; - float32 LA = impulse.x * s1 + impulse.y + impulse.z * a1; - float32 LB = impulse.x * s2 + impulse.y + impulse.z * a2; - - cA -= mA * P; - aA -= iA * LA; - cB += mB * P; - aB += iB * LB; - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return linearError <= b2_linearSlop && angularError <= b2_angularSlop; -} - -b2Vec2 b2PrismaticJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2PrismaticJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2PrismaticJoint::GetReactionForce(float32 inv_dt) const -{ - return inv_dt * (m_impulse.x * m_perp + (m_motorImpulse + m_impulse.z) * m_axis); -} - -float32 b2PrismaticJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * m_impulse.y; -} - -float32 b2PrismaticJoint::GetJointTranslation() const -{ - b2Vec2 pA = m_bodyA->GetWorldPoint(m_localAnchorA); - b2Vec2 pB = m_bodyB->GetWorldPoint(m_localAnchorB); - b2Vec2 d = pB - pA; - b2Vec2 axis = m_bodyA->GetWorldVector(m_localXAxisA); - - float32 translation = b2Dot(d, axis); - return translation; -} - -float32 b2PrismaticJoint::GetJointSpeed() const -{ - b2Body* bA = m_bodyA; - b2Body* bB = m_bodyB; - - b2Vec2 rA = b2Mul(bA->m_xf.q, m_localAnchorA - bA->m_sweep.localCenter); - b2Vec2 rB = b2Mul(bB->m_xf.q, m_localAnchorB - bB->m_sweep.localCenter); - b2Vec2 p1 = bA->m_sweep.c + rA; - b2Vec2 p2 = bB->m_sweep.c + rB; - b2Vec2 d = p2 - p1; - b2Vec2 axis = b2Mul(bA->m_xf.q, m_localXAxisA); - - b2Vec2 vA = bA->m_linearVelocity; - b2Vec2 vB = bB->m_linearVelocity; - float32 wA = bA->m_angularVelocity; - float32 wB = bB->m_angularVelocity; - - float32 speed = b2Dot(d, b2Cross(wA, axis)) + b2Dot(axis, vB + b2Cross(wB, rB) - vA - b2Cross(wA, rA)); - return speed; -} - -bool b2PrismaticJoint::IsLimitEnabled() const -{ - return m_enableLimit; -} - -void b2PrismaticJoint::EnableLimit(bool flag) -{ - if (flag != m_enableLimit) - { - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_enableLimit = flag; - m_impulse.z = 0.0f; - } -} - -float32 b2PrismaticJoint::GetLowerLimit() const -{ - return m_lowerTranslation; -} - -float32 b2PrismaticJoint::GetUpperLimit() const -{ - return m_upperTranslation; -} - -void b2PrismaticJoint::SetLimits(float32 lower, float32 upper) -{ - b2Assert(lower <= upper); - if (lower != m_lowerTranslation || upper != m_upperTranslation) - { - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_lowerTranslation = lower; - m_upperTranslation = upper; - m_impulse.z = 0.0f; - } -} - -bool b2PrismaticJoint::IsMotorEnabled() const -{ - return m_enableMotor; -} - -void b2PrismaticJoint::EnableMotor(bool flag) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_enableMotor = flag; -} - -void b2PrismaticJoint::SetMotorSpeed(float32 speed) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_motorSpeed = speed; -} - -void b2PrismaticJoint::SetMaxMotorForce(float32 force) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_maxMotorForce = force; -} - -float32 b2PrismaticJoint::GetMotorForce(float32 inv_dt) const -{ - return inv_dt * m_motorImpulse; -} - -void b2PrismaticJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2PrismaticJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.localAxisA.Set(%.15lef, %.15lef);\n", m_localXAxisA.x, m_localXAxisA.y); - b2Log(" jd.referenceAngle = %.15lef;\n", m_referenceAngle); - b2Log(" jd.enableLimit = bool(%d);\n", m_enableLimit); - b2Log(" jd.lowerTranslation = %.15lef;\n", m_lowerTranslation); - b2Log(" jd.upperTranslation = %.15lef;\n", m_upperTranslation); - b2Log(" jd.enableMotor = bool(%d);\n", m_enableMotor); - b2Log(" jd.motorSpeed = %.15lef;\n", m_motorSpeed); - b2Log(" jd.maxMotorForce = %.15lef;\n", m_maxMotorForce); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2PrismaticJoint.h b/sources/Box2D/Dynamics/Joints/b2PrismaticJoint.h deleted file mode 100755 index 8d0f3422..00000000 --- a/sources/Box2D/Dynamics/Joints/b2PrismaticJoint.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_PRISMATIC_JOINT_H -#define B2_PRISMATIC_JOINT_H - -#include - -/// Prismatic joint definition. This requires defining a line of -/// motion using an axis and an anchor point. The definition uses local -/// anchor points and a local axis so that the initial configuration -/// can violate the constraint slightly. The joint translation is zero -/// when the local anchor points coincide in world space. Using local -/// anchors and a local axis helps when saving and loading a game. -struct b2PrismaticJointDef : public b2JointDef -{ - b2PrismaticJointDef() - { - type = e_prismaticJoint; - localAnchorA.SetZero(); - localAnchorB.SetZero(); - localAxisA.Set(1.0f, 0.0f); - referenceAngle = 0.0f; - enableLimit = false; - lowerTranslation = 0.0f; - upperTranslation = 0.0f; - enableMotor = false; - maxMotorForce = 0.0f; - motorSpeed = 0.0f; - } - - /// Initialize the bodies, anchors, axis, and reference angle using the world - /// anchor and unit world axis. - void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor, const b2Vec2& axis); - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The local translation unit axis in bodyA. - b2Vec2 localAxisA; - - /// The constrained angle between the bodies: bodyB_angle - bodyA_angle. - float32 referenceAngle; - - /// Enable/disable the joint limit. - bool enableLimit; - - /// The lower translation limit, usually in meters. - float32 lowerTranslation; - - /// The upper translation limit, usually in meters. - float32 upperTranslation; - - /// Enable/disable the joint motor. - bool enableMotor; - - /// The maximum motor torque, usually in N-m. - float32 maxMotorForce; - - /// The desired motor speed in radians per second. - float32 motorSpeed; -}; - -/// A prismatic joint. This joint provides one degree of freedom: translation -/// along an axis fixed in bodyA. Relative rotation is prevented. You can -/// use a joint limit to restrict the range of motion and a joint motor to -/// drive the motion or to model joint friction. -class b2PrismaticJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// The local joint axis relative to bodyA. - const b2Vec2& GetLocalAxisA() const { return m_localXAxisA; } - - /// Get the reference angle. - float32 GetReferenceAngle() const { return m_referenceAngle; } - - /// Get the current joint translation, usually in meters. - float32 GetJointTranslation() const; - - /// Get the current joint translation speed, usually in meters per second. - float32 GetJointSpeed() const; - - /// Is the joint limit enabled? - bool IsLimitEnabled() const; - - /// Enable/disable the joint limit. - void EnableLimit(bool flag); - - /// Get the lower joint limit, usually in meters. - float32 GetLowerLimit() const; - - /// Get the upper joint limit, usually in meters. - float32 GetUpperLimit() const; - - /// Set the joint limits, usually in meters. - void SetLimits(float32 lower, float32 upper); - - /// Is the joint motor enabled? - bool IsMotorEnabled() const; - - /// Enable/disable the joint motor. - void EnableMotor(bool flag); - - /// Set the motor speed, usually in meters per second. - void SetMotorSpeed(float32 speed); - - /// Get the motor speed, usually in meters per second. - float32 GetMotorSpeed() const; - - /// Set the maximum motor force, usually in N. - void SetMaxMotorForce(float32 force); - float32 GetMaxMotorForce() const { return m_maxMotorForce; } - - /// Get the current motor force given the inverse time step, usually in N. - float32 GetMotorForce(float32 inv_dt) const; - - /// Dump to b2Log - void Dump(); - -protected: - friend class b2Joint; - friend class b2GearJoint; - b2PrismaticJoint(const b2PrismaticJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - b2Vec2 m_localXAxisA; - b2Vec2 m_localYAxisA; - float32 m_referenceAngle; - b2Vec3 m_impulse; - float32 m_motorImpulse; - float32 m_lowerTranslation; - float32 m_upperTranslation; - float32 m_maxMotorForce; - float32 m_motorSpeed; - bool m_enableLimit; - bool m_enableMotor; - b2LimitState m_limitState; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - b2Vec2 m_axis, m_perp; - float32 m_s1, m_s2; - float32 m_a1, m_a2; - b2Mat33 m_K; - float32 m_motorMass; -}; - -inline float32 b2PrismaticJoint::GetMotorSpeed() const -{ - return m_motorSpeed; -} - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2PulleyJoint.cpp b/sources/Box2D/Dynamics/Joints/b2PulleyJoint.cpp deleted file mode 100755 index f8b22853..00000000 --- a/sources/Box2D/Dynamics/Joints/b2PulleyJoint.cpp +++ /dev/null @@ -1,348 +0,0 @@ -/* -* Copyright (c) 2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Pulley: -// length1 = norm(p1 - s1) -// length2 = norm(p2 - s2) -// C0 = (length1 + ratio * length2)_initial -// C = C0 - (length1 + ratio * length2) -// u1 = (p1 - s1) / norm(p1 - s1) -// u2 = (p2 - s2) / norm(p2 - s2) -// Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2)) -// J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)] -// K = J * invM * JT -// = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 * cross(r2, u2)^2) - -void b2PulleyJointDef::Initialize(b2Body* bA, b2Body* bB, - const b2Vec2& groundA, const b2Vec2& groundB, - const b2Vec2& anchorA, const b2Vec2& anchorB, - float32 r) -{ - bodyA = bA; - bodyB = bB; - groundAnchorA = groundA; - groundAnchorB = groundB; - localAnchorA = bodyA->GetLocalPoint(anchorA); - localAnchorB = bodyB->GetLocalPoint(anchorB); - b2Vec2 dA = anchorA - groundA; - lengthA = dA.Length(); - b2Vec2 dB = anchorB - groundB; - lengthB = dB.Length(); - ratio = r; - b2Assert(ratio > b2_epsilon); -} - -b2PulleyJoint::b2PulleyJoint(const b2PulleyJointDef* def) -: b2Joint(def) -{ - m_groundAnchorA = def->groundAnchorA; - m_groundAnchorB = def->groundAnchorB; - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - - m_lengthA = def->lengthA; - m_lengthB = def->lengthB; - - b2Assert(def->ratio != 0.0f); - m_ratio = def->ratio; - - m_constant = def->lengthA + m_ratio * def->lengthB; - - m_impulse = 0.0f; -} - -void b2PulleyJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - // Get the pulley axes. - m_uA = cA + m_rA - m_groundAnchorA; - m_uB = cB + m_rB - m_groundAnchorB; - - float32 lengthA = m_uA.Length(); - float32 lengthB = m_uB.Length(); - - if (lengthA > 10.0f * b2_linearSlop) - { - m_uA *= 1.0f / lengthA; - } - else - { - m_uA.SetZero(); - } - - if (lengthB > 10.0f * b2_linearSlop) - { - m_uB *= 1.0f / lengthB; - } - else - { - m_uB.SetZero(); - } - - // Compute effective mass. - float32 ruA = b2Cross(m_rA, m_uA); - float32 ruB = b2Cross(m_rB, m_uB); - - float32 mA = m_invMassA + m_invIA * ruA * ruA; - float32 mB = m_invMassB + m_invIB * ruB * ruB; - - m_mass = mA + m_ratio * m_ratio * mB; - - if (m_mass > 0.0f) - { - m_mass = 1.0f / m_mass; - } - - if (data.step.warmStarting) - { - // Scale impulses to support variable time steps. - m_impulse *= data.step.dtRatio; - - // Warm starting. - b2Vec2 PA = -(m_impulse) * m_uA; - b2Vec2 PB = (-m_ratio * m_impulse) * m_uB; - - vA += m_invMassA * PA; - wA += m_invIA * b2Cross(m_rA, PA); - vB += m_invMassB * PB; - wB += m_invIB * b2Cross(m_rB, PB); - } - else - { - m_impulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2PulleyJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Vec2 vpA = vA + b2Cross(wA, m_rA); - b2Vec2 vpB = vB + b2Cross(wB, m_rB); - - float32 Cdot = -b2Dot(m_uA, vpA) - m_ratio * b2Dot(m_uB, vpB); - float32 impulse = -m_mass * Cdot; - m_impulse += impulse; - - b2Vec2 PA = -impulse * m_uA; - b2Vec2 PB = -m_ratio * impulse * m_uB; - vA += m_invMassA * PA; - wA += m_invIA * b2Cross(m_rA, PA); - vB += m_invMassB * PB; - wB += m_invIB * b2Cross(m_rB, PB); - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2PulleyJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - // Get the pulley axes. - b2Vec2 uA = cA + rA - m_groundAnchorA; - b2Vec2 uB = cB + rB - m_groundAnchorB; - - float32 lengthA = uA.Length(); - float32 lengthB = uB.Length(); - - if (lengthA > 10.0f * b2_linearSlop) - { - uA *= 1.0f / lengthA; - } - else - { - uA.SetZero(); - } - - if (lengthB > 10.0f * b2_linearSlop) - { - uB *= 1.0f / lengthB; - } - else - { - uB.SetZero(); - } - - // Compute effective mass. - float32 ruA = b2Cross(rA, uA); - float32 ruB = b2Cross(rB, uB); - - float32 mA = m_invMassA + m_invIA * ruA * ruA; - float32 mB = m_invMassB + m_invIB * ruB * ruB; - - float32 mass = mA + m_ratio * m_ratio * mB; - - if (mass > 0.0f) - { - mass = 1.0f / mass; - } - - float32 C = m_constant - lengthA - m_ratio * lengthB; - float32 linearError = b2Abs(C); - - float32 impulse = -mass * C; - - b2Vec2 PA = -impulse * uA; - b2Vec2 PB = -m_ratio * impulse * uB; - - cA += m_invMassA * PA; - aA += m_invIA * b2Cross(rA, PA); - cB += m_invMassB * PB; - aB += m_invIB * b2Cross(rB, PB); - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return linearError < b2_linearSlop; -} - -b2Vec2 b2PulleyJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2PulleyJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2PulleyJoint::GetReactionForce(float32 inv_dt) const -{ - b2Vec2 P = m_impulse * m_uB; - return inv_dt * P; -} - -float32 b2PulleyJoint::GetReactionTorque(float32 inv_dt) const -{ - B2_NOT_USED(inv_dt); - return 0.0f; -} - -b2Vec2 b2PulleyJoint::GetGroundAnchorA() const -{ - return m_groundAnchorA; -} - -b2Vec2 b2PulleyJoint::GetGroundAnchorB() const -{ - return m_groundAnchorB; -} - -float32 b2PulleyJoint::GetLengthA() const -{ - return m_lengthA; -} - -float32 b2PulleyJoint::GetLengthB() const -{ - return m_lengthB; -} - -float32 b2PulleyJoint::GetRatio() const -{ - return m_ratio; -} - -float32 b2PulleyJoint::GetCurrentLengthA() const -{ - b2Vec2 p = m_bodyA->GetWorldPoint(m_localAnchorA); - b2Vec2 s = m_groundAnchorA; - b2Vec2 d = p - s; - return d.Length(); -} - -float32 b2PulleyJoint::GetCurrentLengthB() const -{ - b2Vec2 p = m_bodyB->GetWorldPoint(m_localAnchorB); - b2Vec2 s = m_groundAnchorB; - b2Vec2 d = p - s; - return d.Length(); -} - -void b2PulleyJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2PulleyJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.groundAnchorA.Set(%.15lef, %.15lef);\n", m_groundAnchorA.x, m_groundAnchorA.y); - b2Log(" jd.groundAnchorB.Set(%.15lef, %.15lef);\n", m_groundAnchorB.x, m_groundAnchorB.y); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.lengthA = %.15lef;\n", m_lengthA); - b2Log(" jd.lengthB = %.15lef;\n", m_lengthB); - b2Log(" jd.ratio = %.15lef;\n", m_ratio); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} - -void b2PulleyJoint::ShiftOrigin(const b2Vec2& newOrigin) -{ - m_groundAnchorA -= newOrigin; - m_groundAnchorB -= newOrigin; -} diff --git a/sources/Box2D/Dynamics/Joints/b2PulleyJoint.h b/sources/Box2D/Dynamics/Joints/b2PulleyJoint.h deleted file mode 100755 index 2dcdd34a..00000000 --- a/sources/Box2D/Dynamics/Joints/b2PulleyJoint.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_PULLEY_JOINT_H -#define B2_PULLEY_JOINT_H - -#include - -const float32 b2_minPulleyLength = 2.0f; - -/// Pulley joint definition. This requires two ground anchors, -/// two dynamic body anchor points, and a pulley ratio. -struct b2PulleyJointDef : public b2JointDef -{ - b2PulleyJointDef() - { - type = e_pulleyJoint; - groundAnchorA.Set(-1.0f, 1.0f); - groundAnchorB.Set(1.0f, 1.0f); - localAnchorA.Set(-1.0f, 0.0f); - localAnchorB.Set(1.0f, 0.0f); - lengthA = 0.0f; - lengthB = 0.0f; - ratio = 1.0f; - collideConnected = true; - } - - /// Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors. - void Initialize(b2Body* bodyA, b2Body* bodyB, - const b2Vec2& groundAnchorA, const b2Vec2& groundAnchorB, - const b2Vec2& anchorA, const b2Vec2& anchorB, - float32 ratio); - - /// The first ground anchor in world coordinates. This point never moves. - b2Vec2 groundAnchorA; - - /// The second ground anchor in world coordinates. This point never moves. - b2Vec2 groundAnchorB; - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The a reference length for the segment attached to bodyA. - float32 lengthA; - - /// The a reference length for the segment attached to bodyB. - float32 lengthB; - - /// The pulley ratio, used to simulate a block-and-tackle. - float32 ratio; -}; - -/// The pulley joint is connected to two bodies and two fixed ground points. -/// The pulley supports a ratio such that: -/// length1 + ratio * length2 <= constant -/// Yes, the force transmitted is scaled by the ratio. -/// Warning: the pulley joint can get a bit squirrelly by itself. They often -/// work better when combined with prismatic joints. You should also cover the -/// the anchor points with static shapes to prevent one side from going to -/// zero length. -class b2PulleyJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// Get the first ground anchor. - b2Vec2 GetGroundAnchorA() const; - - /// Get the second ground anchor. - b2Vec2 GetGroundAnchorB() const; - - /// Get the current length of the segment attached to bodyA. - float32 GetLengthA() const; - - /// Get the current length of the segment attached to bodyB. - float32 GetLengthB() const; - - /// Get the pulley ratio. - float32 GetRatio() const; - - /// Get the current length of the segment attached to bodyA. - float32 GetCurrentLengthA() const; - - /// Get the current length of the segment attached to bodyB. - float32 GetCurrentLengthB() const; - - /// Dump joint to dmLog - void Dump(); - - /// Implement b2Joint::ShiftOrigin - void ShiftOrigin(const b2Vec2& newOrigin); - -protected: - - friend class b2Joint; - b2PulleyJoint(const b2PulleyJointDef* data); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - b2Vec2 m_groundAnchorA; - b2Vec2 m_groundAnchorB; - float32 m_lengthA; - float32 m_lengthB; - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - float32 m_constant; - float32 m_ratio; - float32 m_impulse; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_uA; - b2Vec2 m_uB; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - float32 m_mass; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp b/sources/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp deleted file mode 100755 index d48cae81..00000000 --- a/sources/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp +++ /dev/null @@ -1,502 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Point-to-point constraint -// C = p2 - p1 -// Cdot = v2 - v1 -// = v2 + cross(w2, r2) - v1 - cross(w1, r1) -// J = [-I -r1_skew I r2_skew ] -// Identity used: -// w k % (rx i + ry j) = w * (-ry i + rx j) - -// Motor constraint -// Cdot = w2 - w1 -// J = [0 0 -1 0 0 1] -// K = invI1 + invI2 - -void b2RevoluteJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor) -{ - bodyA = bA; - bodyB = bB; - localAnchorA = bodyA->GetLocalPoint(anchor); - localAnchorB = bodyB->GetLocalPoint(anchor); - referenceAngle = bodyB->GetAngle() - bodyA->GetAngle(); -} - -b2RevoluteJoint::b2RevoluteJoint(const b2RevoluteJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - m_referenceAngle = def->referenceAngle; - - m_impulse.SetZero(); - m_motorImpulse = 0.0f; - - m_lowerAngle = def->lowerAngle; - m_upperAngle = def->upperAngle; - m_maxMotorTorque = def->maxMotorTorque; - m_motorSpeed = def->motorSpeed; - m_enableLimit = def->enableLimit; - m_enableMotor = def->enableMotor; - m_limitState = e_inactiveLimit; -} - -void b2RevoluteJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - // J = [-I -r1_skew I r2_skew] - // [ 0 -1 0 1] - // r_skew = [-ry; rx] - - // Matlab - // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB] - // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB] - // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB] - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - bool fixedRotation = (iA + iB == 0.0f); - - m_mass.ex.x = mA + mB + m_rA.y * m_rA.y * iA + m_rB.y * m_rB.y * iB; - m_mass.ey.x = -m_rA.y * m_rA.x * iA - m_rB.y * m_rB.x * iB; - m_mass.ez.x = -m_rA.y * iA - m_rB.y * iB; - m_mass.ex.y = m_mass.ey.x; - m_mass.ey.y = mA + mB + m_rA.x * m_rA.x * iA + m_rB.x * m_rB.x * iB; - m_mass.ez.y = m_rA.x * iA + m_rB.x * iB; - m_mass.ex.z = m_mass.ez.x; - m_mass.ey.z = m_mass.ez.y; - m_mass.ez.z = iA + iB; - - m_motorMass = iA + iB; - if (m_motorMass > 0.0f) - { - m_motorMass = 1.0f / m_motorMass; - } - - if (m_enableMotor == false || fixedRotation) - { - m_motorImpulse = 0.0f; - } - - if (m_enableLimit && fixedRotation == false) - { - float32 jointAngle = aB - aA - m_referenceAngle; - if (b2Abs(m_upperAngle - m_lowerAngle) < 2.0f * b2_angularSlop) - { - m_limitState = e_equalLimits; - } - else if (jointAngle <= m_lowerAngle) - { - if (m_limitState != e_atLowerLimit) - { - m_impulse.z = 0.0f; - } - m_limitState = e_atLowerLimit; - } - else if (jointAngle >= m_upperAngle) - { - if (m_limitState != e_atUpperLimit) - { - m_impulse.z = 0.0f; - } - m_limitState = e_atUpperLimit; - } - else - { - m_limitState = e_inactiveLimit; - m_impulse.z = 0.0f; - } - } - else - { - m_limitState = e_inactiveLimit; - } - - if (data.step.warmStarting) - { - // Scale impulses to support a variable time step. - m_impulse *= data.step.dtRatio; - m_motorImpulse *= data.step.dtRatio; - - b2Vec2 P(m_impulse.x, m_impulse.y); - - vA -= mA * P; - wA -= iA * (b2Cross(m_rA, P) + m_motorImpulse + m_impulse.z); - - vB += mB * P; - wB += iB * (b2Cross(m_rB, P) + m_motorImpulse + m_impulse.z); - } - else - { - m_impulse.SetZero(); - m_motorImpulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2RevoluteJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - bool fixedRotation = (iA + iB == 0.0f); - - // Solve motor constraint. - if (m_enableMotor && m_limitState != e_equalLimits && fixedRotation == false) - { - float32 Cdot = wB - wA - m_motorSpeed; - float32 impulse = -m_motorMass * Cdot; - float32 oldImpulse = m_motorImpulse; - float32 maxImpulse = data.step.dt * m_maxMotorTorque; - m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse); - impulse = m_motorImpulse - oldImpulse; - - wA -= iA * impulse; - wB += iB * impulse; - } - - // Solve limit constraint. - if (m_enableLimit && m_limitState != e_inactiveLimit && fixedRotation == false) - { - b2Vec2 Cdot1 = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA); - float32 Cdot2 = wB - wA; - b2Vec3 Cdot(Cdot1.x, Cdot1.y, Cdot2); - - b2Vec3 impulse = -m_mass.Solve33(Cdot); - - if (m_limitState == e_equalLimits) - { - m_impulse += impulse; - } - else if (m_limitState == e_atLowerLimit) - { - float32 newImpulse = m_impulse.z + impulse.z; - if (newImpulse < 0.0f) - { - b2Vec2 rhs = -Cdot1 + m_impulse.z * b2Vec2(m_mass.ez.x, m_mass.ez.y); - b2Vec2 reduced = m_mass.Solve22(rhs); - impulse.x = reduced.x; - impulse.y = reduced.y; - impulse.z = -m_impulse.z; - m_impulse.x += reduced.x; - m_impulse.y += reduced.y; - m_impulse.z = 0.0f; - } - else - { - m_impulse += impulse; - } - } - else if (m_limitState == e_atUpperLimit) - { - float32 newImpulse = m_impulse.z + impulse.z; - if (newImpulse > 0.0f) - { - b2Vec2 rhs = -Cdot1 + m_impulse.z * b2Vec2(m_mass.ez.x, m_mass.ez.y); - b2Vec2 reduced = m_mass.Solve22(rhs); - impulse.x = reduced.x; - impulse.y = reduced.y; - impulse.z = -m_impulse.z; - m_impulse.x += reduced.x; - m_impulse.y += reduced.y; - m_impulse.z = 0.0f; - } - else - { - m_impulse += impulse; - } - } - - b2Vec2 P(impulse.x, impulse.y); - - vA -= mA * P; - wA -= iA * (b2Cross(m_rA, P) + impulse.z); - - vB += mB * P; - wB += iB * (b2Cross(m_rB, P) + impulse.z); - } - else - { - // Solve point-to-point constraint - b2Vec2 Cdot = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA); - b2Vec2 impulse = m_mass.Solve22(-Cdot); - - m_impulse.x += impulse.x; - m_impulse.y += impulse.y; - - vA -= mA * impulse; - wA -= iA * b2Cross(m_rA, impulse); - - vB += mB * impulse; - wB += iB * b2Cross(m_rB, impulse); - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2RevoluteJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - float32 angularError = 0.0f; - float32 positionError = 0.0f; - - bool fixedRotation = (m_invIA + m_invIB == 0.0f); - - // Solve angular limit constraint. - if (m_enableLimit && m_limitState != e_inactiveLimit && fixedRotation == false) - { - float32 angle = aB - aA - m_referenceAngle; - float32 limitImpulse = 0.0f; - - if (m_limitState == e_equalLimits) - { - // Prevent large angular corrections - float32 C = b2Clamp(angle - m_lowerAngle, -b2_maxAngularCorrection, b2_maxAngularCorrection); - limitImpulse = -m_motorMass * C; - angularError = b2Abs(C); - } - else if (m_limitState == e_atLowerLimit) - { - float32 C = angle - m_lowerAngle; - angularError = -C; - - // Prevent large angular corrections and allow some slop. - C = b2Clamp(C + b2_angularSlop, -b2_maxAngularCorrection, 0.0f); - limitImpulse = -m_motorMass * C; - } - else if (m_limitState == e_atUpperLimit) - { - float32 C = angle - m_upperAngle; - angularError = C; - - // Prevent large angular corrections and allow some slop. - C = b2Clamp(C - b2_angularSlop, 0.0f, b2_maxAngularCorrection); - limitImpulse = -m_motorMass * C; - } - - aA -= m_invIA * limitImpulse; - aB += m_invIB * limitImpulse; - } - - // Solve point-to-point constraint. - { - qA.Set(aA); - qB.Set(aB); - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - b2Vec2 C = cB + rB - cA - rA; - positionError = C.Length(); - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Mat22 K; - K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y; - K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y; - K.ey.x = K.ex.y; - K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x; - - b2Vec2 impulse = -K.Solve(C); - - cA -= mA * impulse; - aA -= iA * b2Cross(rA, impulse); - - cB += mB * impulse; - aB += iB * b2Cross(rB, impulse); - } - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return positionError <= b2_linearSlop && angularError <= b2_angularSlop; -} - -b2Vec2 b2RevoluteJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2RevoluteJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2RevoluteJoint::GetReactionForce(float32 inv_dt) const -{ - b2Vec2 P(m_impulse.x, m_impulse.y); - return inv_dt * P; -} - -float32 b2RevoluteJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * m_impulse.z; -} - -float32 b2RevoluteJoint::GetJointAngle() const -{ - b2Body* bA = m_bodyA; - b2Body* bB = m_bodyB; - return bB->m_sweep.a - bA->m_sweep.a - m_referenceAngle; -} - -float32 b2RevoluteJoint::GetJointSpeed() const -{ - b2Body* bA = m_bodyA; - b2Body* bB = m_bodyB; - return bB->m_angularVelocity - bA->m_angularVelocity; -} - -bool b2RevoluteJoint::IsMotorEnabled() const -{ - return m_enableMotor; -} - -void b2RevoluteJoint::EnableMotor(bool flag) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_enableMotor = flag; -} - -float32 b2RevoluteJoint::GetMotorTorque(float32 inv_dt) const -{ - return inv_dt * m_motorImpulse; -} - -void b2RevoluteJoint::SetMotorSpeed(float32 speed) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_motorSpeed = speed; -} - -void b2RevoluteJoint::SetMaxMotorTorque(float32 torque) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_maxMotorTorque = torque; -} - -bool b2RevoluteJoint::IsLimitEnabled() const -{ - return m_enableLimit; -} - -void b2RevoluteJoint::EnableLimit(bool flag) -{ - if (flag != m_enableLimit) - { - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_enableLimit = flag; - m_impulse.z = 0.0f; - } -} - -float32 b2RevoluteJoint::GetLowerLimit() const -{ - return m_lowerAngle; -} - -float32 b2RevoluteJoint::GetUpperLimit() const -{ - return m_upperAngle; -} - -void b2RevoluteJoint::SetLimits(float32 lower, float32 upper) -{ - b2Assert(lower <= upper); - - if (lower != m_lowerAngle || upper != m_upperAngle) - { - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_impulse.z = 0.0f; - m_lowerAngle = lower; - m_upperAngle = upper; - } -} - -void b2RevoluteJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2RevoluteJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.referenceAngle = %.15lef;\n", m_referenceAngle); - b2Log(" jd.enableLimit = bool(%d);\n", m_enableLimit); - b2Log(" jd.lowerAngle = %.15lef;\n", m_lowerAngle); - b2Log(" jd.upperAngle = %.15lef;\n", m_upperAngle); - b2Log(" jd.enableMotor = bool(%d);\n", m_enableMotor); - b2Log(" jd.motorSpeed = %.15lef;\n", m_motorSpeed); - b2Log(" jd.maxMotorTorque = %.15lef;\n", m_maxMotorTorque); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2RevoluteJoint.h b/sources/Box2D/Dynamics/Joints/b2RevoluteJoint.h deleted file mode 100755 index e62cdbcc..00000000 --- a/sources/Box2D/Dynamics/Joints/b2RevoluteJoint.h +++ /dev/null @@ -1,204 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_REVOLUTE_JOINT_H -#define B2_REVOLUTE_JOINT_H - -#include - -/// Revolute joint definition. This requires defining an -/// anchor point where the bodies are joined. The definition -/// uses local anchor points so that the initial configuration -/// can violate the constraint slightly. You also need to -/// specify the initial relative angle for joint limits. This -/// helps when saving and loading a game. -/// The local anchor points are measured from the body's origin -/// rather than the center of mass because: -/// 1. you might not know where the center of mass will be. -/// 2. if you add/remove shapes from a body and recompute the mass, -/// the joints will be broken. -struct b2RevoluteJointDef : public b2JointDef -{ - b2RevoluteJointDef() - { - type = e_revoluteJoint; - localAnchorA.Set(0.0f, 0.0f); - localAnchorB.Set(0.0f, 0.0f); - referenceAngle = 0.0f; - lowerAngle = 0.0f; - upperAngle = 0.0f; - maxMotorTorque = 0.0f; - motorSpeed = 0.0f; - enableLimit = false; - enableMotor = false; - } - - /// Initialize the bodies, anchors, and reference angle using a world - /// anchor point. - void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor); - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The bodyB angle minus bodyA angle in the reference state (radians). - float32 referenceAngle; - - /// A flag to enable joint limits. - bool enableLimit; - - /// The lower angle for the joint limit (radians). - float32 lowerAngle; - - /// The upper angle for the joint limit (radians). - float32 upperAngle; - - /// A flag to enable the joint motor. - bool enableMotor; - - /// The desired motor speed. Usually in radians per second. - float32 motorSpeed; - - /// The maximum motor torque used to achieve the desired motor speed. - /// Usually in N-m. - float32 maxMotorTorque; -}; - -/// A revolute joint constrains two bodies to share a common point while they -/// are free to rotate about the point. The relative rotation about the shared -/// point is the joint angle. You can limit the relative rotation with -/// a joint limit that specifies a lower and upper angle. You can use a motor -/// to drive the relative rotation about the shared point. A maximum motor torque -/// is provided so that infinite forces are not generated. -class b2RevoluteJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// Get the reference angle. - float32 GetReferenceAngle() const { return m_referenceAngle; } - - /// Get the current joint angle in radians. - float32 GetJointAngle() const; - - /// Get the current joint angle speed in radians per second. - float32 GetJointSpeed() const; - - /// Is the joint limit enabled? - bool IsLimitEnabled() const; - - /// Enable/disable the joint limit. - void EnableLimit(bool flag); - - /// Get the lower joint limit in radians. - float32 GetLowerLimit() const; - - /// Get the upper joint limit in radians. - float32 GetUpperLimit() const; - - /// Set the joint limits in radians. - void SetLimits(float32 lower, float32 upper); - - /// Is the joint motor enabled? - bool IsMotorEnabled() const; - - /// Enable/disable the joint motor. - void EnableMotor(bool flag); - - /// Set the motor speed in radians per second. - void SetMotorSpeed(float32 speed); - - /// Get the motor speed in radians per second. - float32 GetMotorSpeed() const; - - /// Set the maximum motor torque, usually in N-m. - void SetMaxMotorTorque(float32 torque); - float32 GetMaxMotorTorque() const { return m_maxMotorTorque; } - - /// Get the reaction force given the inverse time step. - /// Unit is N. - b2Vec2 GetReactionForce(float32 inv_dt) const; - - /// Get the reaction torque due to the joint limit given the inverse time step. - /// Unit is N*m. - float32 GetReactionTorque(float32 inv_dt) const; - - /// Get the current motor torque given the inverse time step. - /// Unit is N*m. - float32 GetMotorTorque(float32 inv_dt) const; - - /// Dump to b2Log. - void Dump(); - -protected: - - friend class b2Joint; - friend class b2GearJoint; - - b2RevoluteJoint(const b2RevoluteJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - b2Vec3 m_impulse; - float32 m_motorImpulse; - - bool m_enableMotor; - float32 m_maxMotorTorque; - float32 m_motorSpeed; - - bool m_enableLimit; - float32 m_referenceAngle; - float32 m_lowerAngle; - float32 m_upperAngle; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - b2Mat33 m_mass; // effective mass for point-to-point constraint. - float32 m_motorMass; // effective mass for motor/limit angular constraint. - b2LimitState m_limitState; -}; - -inline float32 b2RevoluteJoint::GetMotorSpeed() const -{ - return m_motorSpeed; -} - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2RopeJoint.cpp b/sources/Box2D/Dynamics/Joints/b2RopeJoint.cpp deleted file mode 100755 index 107ce1fa..00000000 --- a/sources/Box2D/Dynamics/Joints/b2RopeJoint.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* -* Copyright (c) 2007-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - - -// Limit: -// C = norm(pB - pA) - L -// u = (pB - pA) / norm(pB - pA) -// Cdot = dot(u, vB + cross(wB, rB) - vA - cross(wA, rA)) -// J = [-u -cross(rA, u) u cross(rB, u)] -// K = J * invM * JT -// = invMassA + invIA * cross(rA, u)^2 + invMassB + invIB * cross(rB, u)^2 - -b2RopeJoint::b2RopeJoint(const b2RopeJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - - m_maxLength = def->maxLength; - - m_mass = 0.0f; - m_impulse = 0.0f; - m_state = e_inactiveLimit; - m_length = 0.0f; -} - -void b2RopeJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - m_u = cB + m_rB - cA - m_rA; - - m_length = m_u.Length(); - - float32 C = m_length - m_maxLength; - if (C > 0.0f) - { - m_state = e_atUpperLimit; - } - else - { - m_state = e_inactiveLimit; - } - - if (m_length > b2_linearSlop) - { - m_u *= 1.0f / m_length; - } - else - { - m_u.SetZero(); - m_mass = 0.0f; - m_impulse = 0.0f; - return; - } - - // Compute effective mass. - float32 crA = b2Cross(m_rA, m_u); - float32 crB = b2Cross(m_rB, m_u); - float32 invMass = m_invMassA + m_invIA * crA * crA + m_invMassB + m_invIB * crB * crB; - - m_mass = invMass != 0.0f ? 1.0f / invMass : 0.0f; - - if (data.step.warmStarting) - { - // Scale the impulse to support a variable time step. - m_impulse *= data.step.dtRatio; - - b2Vec2 P = m_impulse * m_u; - vA -= m_invMassA * P; - wA -= m_invIA * b2Cross(m_rA, P); - vB += m_invMassB * P; - wB += m_invIB * b2Cross(m_rB, P); - } - else - { - m_impulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2RopeJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - // Cdot = dot(u, v + cross(w, r)) - b2Vec2 vpA = vA + b2Cross(wA, m_rA); - b2Vec2 vpB = vB + b2Cross(wB, m_rB); - float32 C = m_length - m_maxLength; - float32 Cdot = b2Dot(m_u, vpB - vpA); - - // Predictive constraint. - if (C < 0.0f) - { - Cdot += data.step.inv_dt * C; - } - - float32 impulse = -m_mass * Cdot; - float32 oldImpulse = m_impulse; - m_impulse = b2Min(0.0f, m_impulse + impulse); - impulse = m_impulse - oldImpulse; - - b2Vec2 P = impulse * m_u; - vA -= m_invMassA * P; - wA -= m_invIA * b2Cross(m_rA, P); - vB += m_invMassB * P; - wB += m_invIB * b2Cross(m_rB, P); - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2RopeJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - b2Vec2 u = cB + rB - cA - rA; - - float32 length = u.Normalize(); - float32 C = length - m_maxLength; - - C = b2Clamp(C, 0.0f, b2_maxLinearCorrection); - - float32 impulse = -m_mass * C; - b2Vec2 P = impulse * u; - - cA -= m_invMassA * P; - aA -= m_invIA * b2Cross(rA, P); - cB += m_invMassB * P; - aB += m_invIB * b2Cross(rB, P); - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return length - m_maxLength < b2_linearSlop; -} - -b2Vec2 b2RopeJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2RopeJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2RopeJoint::GetReactionForce(float32 inv_dt) const -{ - b2Vec2 F = (inv_dt * m_impulse) * m_u; - return F; -} - -float32 b2RopeJoint::GetReactionTorque(float32 inv_dt) const -{ - B2_NOT_USED(inv_dt); - return 0.0f; -} - -float32 b2RopeJoint::GetMaxLength() const -{ - return m_maxLength; -} - -b2LimitState b2RopeJoint::GetLimitState() const -{ - return m_state; -} - -void b2RopeJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2RopeJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.maxLength = %.15lef;\n", m_maxLength); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2RopeJoint.h b/sources/Box2D/Dynamics/Joints/b2RopeJoint.h deleted file mode 100755 index 30252460..00000000 --- a/sources/Box2D/Dynamics/Joints/b2RopeJoint.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_ROPE_JOINT_H -#define B2_ROPE_JOINT_H - -#include - -/// Rope joint definition. This requires two body anchor points and -/// a maximum lengths. -/// Note: by default the connected objects will not collide. -/// see collideConnected in b2JointDef. -struct b2RopeJointDef : public b2JointDef -{ - b2RopeJointDef() - { - type = e_ropeJoint; - localAnchorA.Set(-1.0f, 0.0f); - localAnchorB.Set(1.0f, 0.0f); - maxLength = 0.0f; - } - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The maximum length of the rope. - /// Warning: this must be larger than b2_linearSlop or - /// the joint will have no effect. - float32 maxLength; -}; - -/// A rope joint enforces a maximum distance between two points -/// on two bodies. It has no other effect. -/// Warning: if you attempt to change the maximum length during -/// the simulation you will get some non-physical behavior. -/// A model that would allow you to dynamically modify the length -/// would have some sponginess, so I chose not to implement it -/// that way. See b2DistanceJoint if you want to dynamically -/// control length. -class b2RopeJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// Set/Get the maximum length of the rope. - void SetMaxLength(float32 length) { m_maxLength = length; } - float32 GetMaxLength() const; - - b2LimitState GetLimitState() const; - - /// Dump joint to dmLog - void Dump(); - -protected: - - friend class b2Joint; - b2RopeJoint(const b2RopeJointDef* data); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - float32 m_maxLength; - float32 m_length; - float32 m_impulse; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_u; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - float32 m_mass; - b2LimitState m_state; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2WeldJoint.cpp b/sources/Box2D/Dynamics/Joints/b2WeldJoint.cpp deleted file mode 100755 index 5c5614d8..00000000 --- a/sources/Box2D/Dynamics/Joints/b2WeldJoint.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Point-to-point constraint -// C = p2 - p1 -// Cdot = v2 - v1 -// = v2 + cross(w2, r2) - v1 - cross(w1, r1) -// J = [-I -r1_skew I r2_skew ] -// Identity used: -// w k % (rx i + ry j) = w * (-ry i + rx j) - -// Angle constraint -// C = angle2 - angle1 - referenceAngle -// Cdot = w2 - w1 -// J = [0 0 -1 0 0 1] -// K = invI1 + invI2 - -void b2WeldJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor) -{ - bodyA = bA; - bodyB = bB; - localAnchorA = bodyA->GetLocalPoint(anchor); - localAnchorB = bodyB->GetLocalPoint(anchor); - referenceAngle = bodyB->GetAngle() - bodyA->GetAngle(); -} - -b2WeldJoint::b2WeldJoint(const b2WeldJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - m_referenceAngle = def->referenceAngle; - m_frequencyHz = def->frequencyHz; - m_dampingRatio = def->dampingRatio; - - m_impulse.SetZero(); -} - -void b2WeldJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - // J = [-I -r1_skew I r2_skew] - // [ 0 -1 0 1] - // r_skew = [-ry; rx] - - // Matlab - // K = [ mA+r1y^2*iA+mB+r2y^2*iB, -r1y*iA*r1x-r2y*iB*r2x, -r1y*iA-r2y*iB] - // [ -r1y*iA*r1x-r2y*iB*r2x, mA+r1x^2*iA+mB+r2x^2*iB, r1x*iA+r2x*iB] - // [ -r1y*iA-r2y*iB, r1x*iA+r2x*iB, iA+iB] - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Mat33 K; - K.ex.x = mA + mB + m_rA.y * m_rA.y * iA + m_rB.y * m_rB.y * iB; - K.ey.x = -m_rA.y * m_rA.x * iA - m_rB.y * m_rB.x * iB; - K.ez.x = -m_rA.y * iA - m_rB.y * iB; - K.ex.y = K.ey.x; - K.ey.y = mA + mB + m_rA.x * m_rA.x * iA + m_rB.x * m_rB.x * iB; - K.ez.y = m_rA.x * iA + m_rB.x * iB; - K.ex.z = K.ez.x; - K.ey.z = K.ez.y; - K.ez.z = iA + iB; - - if (m_frequencyHz > 0.0f) - { - K.GetInverse22(&m_mass); - - float32 invM = iA + iB; - float32 m = invM > 0.0f ? 1.0f / invM : 0.0f; - - float32 C = aB - aA - m_referenceAngle; - - // Frequency - float32 omega = 2.0f * b2_pi * m_frequencyHz; - - // Damping coefficient - float32 d = 2.0f * m * m_dampingRatio * omega; - - // Spring stiffness - float32 k = m * omega * omega; - - // magic formulas - float32 h = data.step.dt; - m_gamma = h * (d + h * k); - m_gamma = m_gamma != 0.0f ? 1.0f / m_gamma : 0.0f; - m_bias = C * h * k * m_gamma; - - invM += m_gamma; - m_mass.ez.z = invM != 0.0f ? 1.0f / invM : 0.0f; - } - else if (K.ez.z == 0.0f) - { - K.GetInverse22(&m_mass); - m_gamma = 0.0f; - m_bias = 0.0f; - } - else - { - K.GetSymInverse33(&m_mass); - m_gamma = 0.0f; - m_bias = 0.0f; - } - - if (data.step.warmStarting) - { - // Scale impulses to support a variable time step. - m_impulse *= data.step.dtRatio; - - b2Vec2 P(m_impulse.x, m_impulse.y); - - vA -= mA * P; - wA -= iA * (b2Cross(m_rA, P) + m_impulse.z); - - vB += mB * P; - wB += iB * (b2Cross(m_rB, P) + m_impulse.z); - } - else - { - m_impulse.SetZero(); - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2WeldJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - if (m_frequencyHz > 0.0f) - { - float32 Cdot2 = wB - wA; - - float32 impulse2 = -m_mass.ez.z * (Cdot2 + m_bias + m_gamma * m_impulse.z); - m_impulse.z += impulse2; - - wA -= iA * impulse2; - wB += iB * impulse2; - - b2Vec2 Cdot1 = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA); - - b2Vec2 impulse1 = -b2Mul22(m_mass, Cdot1); - m_impulse.x += impulse1.x; - m_impulse.y += impulse1.y; - - b2Vec2 P = impulse1; - - vA -= mA * P; - wA -= iA * b2Cross(m_rA, P); - - vB += mB * P; - wB += iB * b2Cross(m_rB, P); - } - else - { - b2Vec2 Cdot1 = vB + b2Cross(wB, m_rB) - vA - b2Cross(wA, m_rA); - float32 Cdot2 = wB - wA; - b2Vec3 Cdot(Cdot1.x, Cdot1.y, Cdot2); - - b2Vec3 impulse = -b2Mul(m_mass, Cdot); - m_impulse += impulse; - - b2Vec2 P(impulse.x, impulse.y); - - vA -= mA * P; - wA -= iA * (b2Cross(m_rA, P) + impulse.z); - - vB += mB * P; - wB += iB * (b2Cross(m_rB, P) + impulse.z); - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2WeldJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - - float32 positionError, angularError; - - b2Mat33 K; - K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB; - K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB; - K.ez.x = -rA.y * iA - rB.y * iB; - K.ex.y = K.ey.x; - K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB; - K.ez.y = rA.x * iA + rB.x * iB; - K.ex.z = K.ez.x; - K.ey.z = K.ez.y; - K.ez.z = iA + iB; - - if (m_frequencyHz > 0.0f) - { - b2Vec2 C1 = cB + rB - cA - rA; - - positionError = C1.Length(); - angularError = 0.0f; - - b2Vec2 P = -K.Solve22(C1); - - cA -= mA * P; - aA -= iA * b2Cross(rA, P); - - cB += mB * P; - aB += iB * b2Cross(rB, P); - } - else - { - b2Vec2 C1 = cB + rB - cA - rA; - float32 C2 = aB - aA - m_referenceAngle; - - positionError = C1.Length(); - angularError = b2Abs(C2); - - b2Vec3 C(C1.x, C1.y, C2); - - b2Vec3 impulse; - if (K.ez.z > 0.0f) - { - impulse = -K.Solve33(C); - } - else - { - b2Vec2 impulse2 = -K.Solve22(C1); - impulse.Set(impulse2.x, impulse2.y, 0.0f); - } - - b2Vec2 P(impulse.x, impulse.y); - - cA -= mA * P; - aA -= iA * (b2Cross(rA, P) + impulse.z); - - cB += mB * P; - aB += iB * (b2Cross(rB, P) + impulse.z); - } - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return positionError <= b2_linearSlop && angularError <= b2_angularSlop; -} - -b2Vec2 b2WeldJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2WeldJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2WeldJoint::GetReactionForce(float32 inv_dt) const -{ - b2Vec2 P(m_impulse.x, m_impulse.y); - return inv_dt * P; -} - -float32 b2WeldJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * m_impulse.z; -} - -void b2WeldJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2WeldJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.referenceAngle = %.15lef;\n", m_referenceAngle); - b2Log(" jd.frequencyHz = %.15lef;\n", m_frequencyHz); - b2Log(" jd.dampingRatio = %.15lef;\n", m_dampingRatio); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2WeldJoint.h b/sources/Box2D/Dynamics/Joints/b2WeldJoint.h deleted file mode 100755 index 2adfc26a..00000000 --- a/sources/Box2D/Dynamics/Joints/b2WeldJoint.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_WELD_JOINT_H -#define B2_WELD_JOINT_H - -#include - -/// Weld joint definition. You need to specify local anchor points -/// where they are attached and the relative body angle. The position -/// of the anchor points is important for computing the reaction torque. -struct b2WeldJointDef : public b2JointDef -{ - b2WeldJointDef() - { - type = e_weldJoint; - localAnchorA.Set(0.0f, 0.0f); - localAnchorB.Set(0.0f, 0.0f); - referenceAngle = 0.0f; - frequencyHz = 0.0f; - dampingRatio = 0.0f; - } - - /// Initialize the bodies, anchors, and reference angle using a world - /// anchor point. - void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor); - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The bodyB angle minus bodyA angle in the reference state (radians). - float32 referenceAngle; - - /// The mass-spring-damper frequency in Hertz. Rotation only. - /// Disable softness with a value of 0. - float32 frequencyHz; - - /// The damping ratio. 0 = no damping, 1 = critical damping. - float32 dampingRatio; -}; - -/// A weld joint essentially glues two bodies together. A weld joint may -/// distort somewhat because the island constraint solver is approximate. -class b2WeldJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// Get the reference angle. - float32 GetReferenceAngle() const { return m_referenceAngle; } - - /// Set/get frequency in Hz. - void SetFrequency(float32 hz) { m_frequencyHz = hz; } - float32 GetFrequency() const { return m_frequencyHz; } - - /// Set/get damping ratio. - void SetDampingRatio(float32 ratio) { m_dampingRatio = ratio; } - float32 GetDampingRatio() const { return m_dampingRatio; } - - /// Dump to b2Log - void Dump(); - -protected: - - friend class b2Joint; - - b2WeldJoint(const b2WeldJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - float32 m_frequencyHz; - float32 m_dampingRatio; - float32 m_bias; - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - float32 m_referenceAngle; - float32 m_gamma; - b2Vec3 m_impulse; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_rA; - b2Vec2 m_rB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - b2Mat33 m_mass; -}; - -#endif diff --git a/sources/Box2D/Dynamics/Joints/b2WheelJoint.cpp b/sources/Box2D/Dynamics/Joints/b2WheelJoint.cpp deleted file mode 100755 index 74eda681..00000000 --- a/sources/Box2D/Dynamics/Joints/b2WheelJoint.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include - -// Linear constraint (point-to-line) -// d = pB - pA = xB + rB - xA - rA -// C = dot(ay, d) -// Cdot = dot(d, cross(wA, ay)) + dot(ay, vB + cross(wB, rB) - vA - cross(wA, rA)) -// = -dot(ay, vA) - dot(cross(d + rA, ay), wA) + dot(ay, vB) + dot(cross(rB, ay), vB) -// J = [-ay, -cross(d + rA, ay), ay, cross(rB, ay)] - -// Spring linear constraint -// C = dot(ax, d) -// Cdot = = -dot(ax, vA) - dot(cross(d + rA, ax), wA) + dot(ax, vB) + dot(cross(rB, ax), vB) -// J = [-ax -cross(d+rA, ax) ax cross(rB, ax)] - -// Motor rotational constraint -// Cdot = wB - wA -// J = [0 0 -1 0 0 1] - -void b2WheelJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& anchor, const b2Vec2& axis) -{ - bodyA = bA; - bodyB = bB; - localAnchorA = bodyA->GetLocalPoint(anchor); - localAnchorB = bodyB->GetLocalPoint(anchor); - localAxisA = bodyA->GetLocalVector(axis); -} - -b2WheelJoint::b2WheelJoint(const b2WheelJointDef* def) -: b2Joint(def) -{ - m_localAnchorA = def->localAnchorA; - m_localAnchorB = def->localAnchorB; - m_localXAxisA = def->localAxisA; - m_localYAxisA = b2Cross(1.0f, m_localXAxisA); - - m_mass = 0.0f; - m_impulse = 0.0f; - m_motorMass = 0.0f; - m_motorImpulse = 0.0f; - m_springMass = 0.0f; - m_springImpulse = 0.0f; - - m_maxMotorTorque = def->maxMotorTorque; - m_motorSpeed = def->motorSpeed; - m_enableMotor = def->enableMotor; - - m_frequencyHz = def->frequencyHz; - m_dampingRatio = def->dampingRatio; - - m_bias = 0.0f; - m_gamma = 0.0f; - - m_ax.SetZero(); - m_ay.SetZero(); -} - -void b2WheelJoint::InitVelocityConstraints(const b2SolverData& data) -{ - m_indexA = m_bodyA->m_islandIndex; - m_indexB = m_bodyB->m_islandIndex; - m_localCenterA = m_bodyA->m_sweep.localCenter; - m_localCenterB = m_bodyB->m_sweep.localCenter; - m_invMassA = m_bodyA->m_invMass; - m_invMassB = m_bodyB->m_invMass; - m_invIA = m_bodyA->m_invI; - m_invIB = m_bodyB->m_invI; - - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - b2Rot qA(aA), qB(aB); - - // Compute the effective masses. - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - b2Vec2 d = cB + rB - cA - rA; - - // Point to line constraint - { - m_ay = b2Mul(qA, m_localYAxisA); - m_sAy = b2Cross(d + rA, m_ay); - m_sBy = b2Cross(rB, m_ay); - - m_mass = mA + mB + iA * m_sAy * m_sAy + iB * m_sBy * m_sBy; - - if (m_mass > 0.0f) - { - m_mass = 1.0f / m_mass; - } - } - - // Spring constraint - m_springMass = 0.0f; - m_bias = 0.0f; - m_gamma = 0.0f; - if (m_frequencyHz > 0.0f) - { - m_ax = b2Mul(qA, m_localXAxisA); - m_sAx = b2Cross(d + rA, m_ax); - m_sBx = b2Cross(rB, m_ax); - - float32 invMass = mA + mB + iA * m_sAx * m_sAx + iB * m_sBx * m_sBx; - - if (invMass > 0.0f) - { - m_springMass = 1.0f / invMass; - - float32 C = b2Dot(d, m_ax); - - // Frequency - float32 omega = 2.0f * b2_pi * m_frequencyHz; - - // Damping coefficient - float32 d = 2.0f * m_springMass * m_dampingRatio * omega; - - // Spring stiffness - float32 k = m_springMass * omega * omega; - - // magic formulas - float32 h = data.step.dt; - m_gamma = h * (d + h * k); - if (m_gamma > 0.0f) - { - m_gamma = 1.0f / m_gamma; - } - - m_bias = C * h * k * m_gamma; - - m_springMass = invMass + m_gamma; - if (m_springMass > 0.0f) - { - m_springMass = 1.0f / m_springMass; - } - } - } - else - { - m_springImpulse = 0.0f; - } - - // Rotational motor - if (m_enableMotor) - { - m_motorMass = iA + iB; - if (m_motorMass > 0.0f) - { - m_motorMass = 1.0f / m_motorMass; - } - } - else - { - m_motorMass = 0.0f; - m_motorImpulse = 0.0f; - } - - if (data.step.warmStarting) - { - // Account for variable time step. - m_impulse *= data.step.dtRatio; - m_springImpulse *= data.step.dtRatio; - m_motorImpulse *= data.step.dtRatio; - - b2Vec2 P = m_impulse * m_ay + m_springImpulse * m_ax; - float32 LA = m_impulse * m_sAy + m_springImpulse * m_sAx + m_motorImpulse; - float32 LB = m_impulse * m_sBy + m_springImpulse * m_sBx + m_motorImpulse; - - vA -= m_invMassA * P; - wA -= m_invIA * LA; - - vB += m_invMassB * P; - wB += m_invIB * LB; - } - else - { - m_impulse = 0.0f; - m_springImpulse = 0.0f; - m_motorImpulse = 0.0f; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -void b2WheelJoint::SolveVelocityConstraints(const b2SolverData& data) -{ - float32 mA = m_invMassA, mB = m_invMassB; - float32 iA = m_invIA, iB = m_invIB; - - b2Vec2 vA = data.velocities[m_indexA].v; - float32 wA = data.velocities[m_indexA].w; - b2Vec2 vB = data.velocities[m_indexB].v; - float32 wB = data.velocities[m_indexB].w; - - // Solve spring constraint - { - float32 Cdot = b2Dot(m_ax, vB - vA) + m_sBx * wB - m_sAx * wA; - float32 impulse = -m_springMass * (Cdot + m_bias + m_gamma * m_springImpulse); - m_springImpulse += impulse; - - b2Vec2 P = impulse * m_ax; - float32 LA = impulse * m_sAx; - float32 LB = impulse * m_sBx; - - vA -= mA * P; - wA -= iA * LA; - - vB += mB * P; - wB += iB * LB; - } - - // Solve rotational motor constraint - { - float32 Cdot = wB - wA - m_motorSpeed; - float32 impulse = -m_motorMass * Cdot; - - float32 oldImpulse = m_motorImpulse; - float32 maxImpulse = data.step.dt * m_maxMotorTorque; - m_motorImpulse = b2Clamp(m_motorImpulse + impulse, -maxImpulse, maxImpulse); - impulse = m_motorImpulse - oldImpulse; - - wA -= iA * impulse; - wB += iB * impulse; - } - - // Solve point to line constraint - { - float32 Cdot = b2Dot(m_ay, vB - vA) + m_sBy * wB - m_sAy * wA; - float32 impulse = -m_mass * Cdot; - m_impulse += impulse; - - b2Vec2 P = impulse * m_ay; - float32 LA = impulse * m_sAy; - float32 LB = impulse * m_sBy; - - vA -= mA * P; - wA -= iA * LA; - - vB += mB * P; - wB += iB * LB; - } - - data.velocities[m_indexA].v = vA; - data.velocities[m_indexA].w = wA; - data.velocities[m_indexB].v = vB; - data.velocities[m_indexB].w = wB; -} - -bool b2WheelJoint::SolvePositionConstraints(const b2SolverData& data) -{ - b2Vec2 cA = data.positions[m_indexA].c; - float32 aA = data.positions[m_indexA].a; - b2Vec2 cB = data.positions[m_indexB].c; - float32 aB = data.positions[m_indexB].a; - - b2Rot qA(aA), qB(aB); - - b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); - b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); - b2Vec2 d = (cB - cA) + rB - rA; - - b2Vec2 ay = b2Mul(qA, m_localYAxisA); - - float32 sAy = b2Cross(d + rA, ay); - float32 sBy = b2Cross(rB, ay); - - float32 C = b2Dot(d, ay); - - float32 k = m_invMassA + m_invMassB + m_invIA * m_sAy * m_sAy + m_invIB * m_sBy * m_sBy; - - float32 impulse; - if (k != 0.0f) - { - impulse = - C / k; - } - else - { - impulse = 0.0f; - } - - b2Vec2 P = impulse * ay; - float32 LA = impulse * sAy; - float32 LB = impulse * sBy; - - cA -= m_invMassA * P; - aA -= m_invIA * LA; - cB += m_invMassB * P; - aB += m_invIB * LB; - - data.positions[m_indexA].c = cA; - data.positions[m_indexA].a = aA; - data.positions[m_indexB].c = cB; - data.positions[m_indexB].a = aB; - - return b2Abs(C) <= b2_linearSlop; -} - -b2Vec2 b2WheelJoint::GetAnchorA() const -{ - return m_bodyA->GetWorldPoint(m_localAnchorA); -} - -b2Vec2 b2WheelJoint::GetAnchorB() const -{ - return m_bodyB->GetWorldPoint(m_localAnchorB); -} - -b2Vec2 b2WheelJoint::GetReactionForce(float32 inv_dt) const -{ - return inv_dt * (m_impulse * m_ay + m_springImpulse * m_ax); -} - -float32 b2WheelJoint::GetReactionTorque(float32 inv_dt) const -{ - return inv_dt * m_motorImpulse; -} - -float32 b2WheelJoint::GetJointTranslation() const -{ - b2Body* bA = m_bodyA; - b2Body* bB = m_bodyB; - - b2Vec2 pA = bA->GetWorldPoint(m_localAnchorA); - b2Vec2 pB = bB->GetWorldPoint(m_localAnchorB); - b2Vec2 d = pB - pA; - b2Vec2 axis = bA->GetWorldVector(m_localXAxisA); - - float32 translation = b2Dot(d, axis); - return translation; -} - -float32 b2WheelJoint::GetJointSpeed() const -{ - float32 wA = m_bodyA->m_angularVelocity; - float32 wB = m_bodyB->m_angularVelocity; - return wB - wA; -} - -bool b2WheelJoint::IsMotorEnabled() const -{ - return m_enableMotor; -} - -void b2WheelJoint::EnableMotor(bool flag) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_enableMotor = flag; -} - -void b2WheelJoint::SetMotorSpeed(float32 speed) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_motorSpeed = speed; -} - -void b2WheelJoint::SetMaxMotorTorque(float32 torque) -{ - m_bodyA->SetAwake(true); - m_bodyB->SetAwake(true); - m_maxMotorTorque = torque; -} - -float32 b2WheelJoint::GetMotorTorque(float32 inv_dt) const -{ - return inv_dt * m_motorImpulse; -} - -void b2WheelJoint::Dump() -{ - int32 indexA = m_bodyA->m_islandIndex; - int32 indexB = m_bodyB->m_islandIndex; - - b2Log(" b2WheelJointDef jd;\n"); - b2Log(" jd.bodyA = bodies[%d];\n", indexA); - b2Log(" jd.bodyB = bodies[%d];\n", indexB); - b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); - b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); - b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); - b2Log(" jd.localAxisA.Set(%.15lef, %.15lef);\n", m_localXAxisA.x, m_localXAxisA.y); - b2Log(" jd.enableMotor = bool(%d);\n", m_enableMotor); - b2Log(" jd.motorSpeed = %.15lef;\n", m_motorSpeed); - b2Log(" jd.maxMotorTorque = %.15lef;\n", m_maxMotorTorque); - b2Log(" jd.frequencyHz = %.15lef;\n", m_frequencyHz); - b2Log(" jd.dampingRatio = %.15lef;\n", m_dampingRatio); - b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); -} diff --git a/sources/Box2D/Dynamics/Joints/b2WheelJoint.h b/sources/Box2D/Dynamics/Joints/b2WheelJoint.h deleted file mode 100755 index 6e8b6454..00000000 --- a/sources/Box2D/Dynamics/Joints/b2WheelJoint.h +++ /dev/null @@ -1,211 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_WHEEL_JOINT_H -#define B2_WHEEL_JOINT_H - -#include - -/// Wheel joint definition. This requires defining a line of -/// motion using an axis and an anchor point. The definition uses local -/// anchor points and a local axis so that the initial configuration -/// can violate the constraint slightly. The joint translation is zero -/// when the local anchor points coincide in world space. Using local -/// anchors and a local axis helps when saving and loading a game. -struct b2WheelJointDef : public b2JointDef -{ - b2WheelJointDef() - { - type = e_wheelJoint; - localAnchorA.SetZero(); - localAnchorB.SetZero(); - localAxisA.Set(1.0f, 0.0f); - enableMotor = false; - maxMotorTorque = 0.0f; - motorSpeed = 0.0f; - frequencyHz = 2.0f; - dampingRatio = 0.7f; - } - - /// Initialize the bodies, anchors, axis, and reference angle using the world - /// anchor and world axis. - void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor, const b2Vec2& axis); - - /// The local anchor point relative to bodyA's origin. - b2Vec2 localAnchorA; - - /// The local anchor point relative to bodyB's origin. - b2Vec2 localAnchorB; - - /// The local translation axis in bodyA. - b2Vec2 localAxisA; - - /// Enable/disable the joint motor. - bool enableMotor; - - /// The maximum motor torque, usually in N-m. - float32 maxMotorTorque; - - /// The desired motor speed in radians per second. - float32 motorSpeed; - - /// Suspension frequency, zero indicates no suspension - float32 frequencyHz; - - /// Suspension damping ratio, one indicates critical damping - float32 dampingRatio; -}; - -/// A wheel joint. This joint provides two degrees of freedom: translation -/// along an axis fixed in bodyA and rotation in the plane. You can use a -/// joint limit to restrict the range of motion and a joint motor to drive -/// the rotation or to model rotational friction. -/// This joint is designed for vehicle suspensions. -class b2WheelJoint : public b2Joint -{ -public: - b2Vec2 GetAnchorA() const; - b2Vec2 GetAnchorB() const; - - b2Vec2 GetReactionForce(float32 inv_dt) const; - float32 GetReactionTorque(float32 inv_dt) const; - - /// The local anchor point relative to bodyA's origin. - const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; } - - /// The local anchor point relative to bodyB's origin. - const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; } - - /// The local joint axis relative to bodyA. - const b2Vec2& GetLocalAxisA() const { return m_localXAxisA; } - - /// Get the current joint translation, usually in meters. - float32 GetJointTranslation() const; - - /// Get the current joint translation speed, usually in meters per second. - float32 GetJointSpeed() const; - - /// Is the joint motor enabled? - bool IsMotorEnabled() const; - - /// Enable/disable the joint motor. - void EnableMotor(bool flag); - - /// Set the motor speed, usually in radians per second. - void SetMotorSpeed(float32 speed); - - /// Get the motor speed, usually in radians per second. - float32 GetMotorSpeed() const; - - /// Set/Get the maximum motor force, usually in N-m. - void SetMaxMotorTorque(float32 torque); - float32 GetMaxMotorTorque() const; - - /// Get the current motor torque given the inverse time step, usually in N-m. - float32 GetMotorTorque(float32 inv_dt) const; - - /// Set/Get the spring frequency in hertz. Setting the frequency to zero disables the spring. - void SetSpringFrequencyHz(float32 hz); - float32 GetSpringFrequencyHz() const; - - /// Set/Get the spring damping ratio - void SetSpringDampingRatio(float32 ratio); - float32 GetSpringDampingRatio() const; - - /// Dump to b2Log - void Dump(); - -protected: - - friend class b2Joint; - b2WheelJoint(const b2WheelJointDef* def); - - void InitVelocityConstraints(const b2SolverData& data); - void SolveVelocityConstraints(const b2SolverData& data); - bool SolvePositionConstraints(const b2SolverData& data); - - float32 m_frequencyHz; - float32 m_dampingRatio; - - // Solver shared - b2Vec2 m_localAnchorA; - b2Vec2 m_localAnchorB; - b2Vec2 m_localXAxisA; - b2Vec2 m_localYAxisA; - - float32 m_impulse; - float32 m_motorImpulse; - float32 m_springImpulse; - - float32 m_maxMotorTorque; - float32 m_motorSpeed; - bool m_enableMotor; - - // Solver temp - int32 m_indexA; - int32 m_indexB; - b2Vec2 m_localCenterA; - b2Vec2 m_localCenterB; - float32 m_invMassA; - float32 m_invMassB; - float32 m_invIA; - float32 m_invIB; - - b2Vec2 m_ax, m_ay; - float32 m_sAx, m_sBx; - float32 m_sAy, m_sBy; - - float32 m_mass; - float32 m_motorMass; - float32 m_springMass; - - float32 m_bias; - float32 m_gamma; -}; - -inline float32 b2WheelJoint::GetMotorSpeed() const -{ - return m_motorSpeed; -} - -inline float32 b2WheelJoint::GetMaxMotorTorque() const -{ - return m_maxMotorTorque; -} - -inline void b2WheelJoint::SetSpringFrequencyHz(float32 hz) -{ - m_frequencyHz = hz; -} - -inline float32 b2WheelJoint::GetSpringFrequencyHz() const -{ - return m_frequencyHz; -} - -inline void b2WheelJoint::SetSpringDampingRatio(float32 ratio) -{ - m_dampingRatio = ratio; -} - -inline float32 b2WheelJoint::GetSpringDampingRatio() const -{ - return m_dampingRatio; -} - -#endif diff --git a/sources/Box2D/Dynamics/b2Body.cpp b/sources/Box2D/Dynamics/b2Body.cpp deleted file mode 100755 index d99fc49f..00000000 --- a/sources/Box2D/Dynamics/b2Body.cpp +++ /dev/null @@ -1,549 +0,0 @@ -/* -* Copyright (c) 2006-2007 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include - -b2Body::b2Body(const b2BodyDef* bd, b2World* world) -{ - b2Assert(bd->position.IsValid()); - b2Assert(bd->linearVelocity.IsValid()); - b2Assert(b2IsValid(bd->angle)); - b2Assert(b2IsValid(bd->angularVelocity)); - b2Assert(b2IsValid(bd->angularDamping) && bd->angularDamping >= 0.0f); - b2Assert(b2IsValid(bd->linearDamping) && bd->linearDamping >= 0.0f); - - m_flags = 0; - - if (bd->bullet) - { - m_flags |= e_bulletFlag; - } - if (bd->fixedRotation) - { - m_flags |= e_fixedRotationFlag; - } - if (bd->allowSleep) - { - m_flags |= e_autoSleepFlag; - } - if (bd->awake) - { - m_flags |= e_awakeFlag; - } - if (bd->active) - { - m_flags |= e_activeFlag; - } - - m_world = world; - - m_xf.p = bd->position; - m_xf.q.Set(bd->angle); - - m_sweep.localCenter.SetZero(); - m_sweep.c0 = m_xf.p; - m_sweep.c = m_xf.p; - m_sweep.a0 = bd->angle; - m_sweep.a = bd->angle; - m_sweep.alpha0 = 0.0f; - - m_jointList = NULL; - m_contactList = NULL; - m_prev = NULL; - m_next = NULL; - - m_linearVelocity = bd->linearVelocity; - m_angularVelocity = bd->angularVelocity; - - m_linearDamping = bd->linearDamping; - m_angularDamping = bd->angularDamping; - m_gravityScale = bd->gravityScale; - - m_force.SetZero(); - m_torque = 0.0f; - - m_sleepTime = 0.0f; - - m_type = bd->type; - - if (m_type == b2_dynamicBody) - { - m_mass = 1.0f; - m_invMass = 1.0f; - } - else - { - m_mass = 0.0f; - m_invMass = 0.0f; - } - - m_I = 0.0f; - m_invI = 0.0f; - - m_userData = bd->userData; - - m_fixtureList = NULL; - m_fixtureCount = 0; -} - -b2Body::~b2Body() -{ - // shapes and joints are destroyed in b2World::Destroy -} - -void b2Body::SetType(b2BodyType type) -{ - b2Assert(m_world->IsLocked() == false); - if (m_world->IsLocked() == true) - { - return; - } - - if (m_type == type) - { - return; - } - - m_type = type; - - ResetMassData(); - - if (m_type == b2_staticBody) - { - m_linearVelocity.SetZero(); - m_angularVelocity = 0.0f; - m_sweep.a0 = m_sweep.a; - m_sweep.c0 = m_sweep.c; - SynchronizeFixtures(); - } - - SetAwake(true); - - m_force.SetZero(); - m_torque = 0.0f; - - // Delete the attached contacts. - b2ContactEdge* ce = m_contactList; - while (ce) - { - b2ContactEdge* ce0 = ce; - ce = ce->next; - m_world->m_contactManager.Destroy(ce0->contact); - } - m_contactList = NULL; - - // Touch the proxies so that new contacts will be created (when appropriate) - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - int32 proxyCount = f->m_proxyCount; - for (int32 i = 0; i < proxyCount; ++i) - { - broadPhase->TouchProxy(f->m_proxies[i].proxyId); - } - } -} - -b2Fixture* b2Body::CreateFixture(const b2FixtureDef* def) -{ - b2Assert(m_world->IsLocked() == false); - if (m_world->IsLocked() == true) - { - return NULL; - } - - b2BlockAllocator* allocator = &m_world->m_blockAllocator; - - void* memory = allocator->Allocate(sizeof(b2Fixture)); - b2Fixture* fixture = new (memory) b2Fixture; - fixture->Create(allocator, this, def); - - if (m_flags & e_activeFlag) - { - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - fixture->CreateProxies(broadPhase, m_xf); - } - - fixture->m_next = m_fixtureList; - m_fixtureList = fixture; - ++m_fixtureCount; - - fixture->m_body = this; - - // Adjust mass properties if needed. - if (fixture->m_density > 0.0f) - { - ResetMassData(); - } - - // Let the world know we have a new fixture. This will cause new contacts - // to be created at the beginning of the next time step. - m_world->m_flags |= b2World::e_newFixture; - - return fixture; -} - -b2Fixture* b2Body::CreateFixture(const b2Shape* shape, float32 density) -{ - b2FixtureDef def; - def.shape = shape; - def.density = density; - - return CreateFixture(&def); -} - -void b2Body::DestroyFixture(b2Fixture* fixture) -{ - b2Assert(m_world->IsLocked() == false); - if (m_world->IsLocked() == true) - { - return; - } - - b2Assert(fixture->m_body == this); - - // Remove the fixture from this body's singly linked list. - b2Assert(m_fixtureCount > 0); - b2Fixture** node = &m_fixtureList; - bool found = false; - while (*node != NULL) - { - if (*node == fixture) - { - *node = fixture->m_next; - found = true; - break; - } - - node = &(*node)->m_next; - } - - // You tried to remove a shape that is not attached to this body. - b2Assert(found); - - // Destroy any contacts associated with the fixture. - b2ContactEdge* edge = m_contactList; - while (edge) - { - b2Contact* c = edge->contact; - edge = edge->next; - - b2Fixture* fixtureA = c->GetFixtureA(); - b2Fixture* fixtureB = c->GetFixtureB(); - - if (fixture == fixtureA || fixture == fixtureB) - { - // This destroys the contact and removes it from - // this body's contact list. - m_world->m_contactManager.Destroy(c); - } - } - - b2BlockAllocator* allocator = &m_world->m_blockAllocator; - - if (m_flags & e_activeFlag) - { - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - fixture->DestroyProxies(broadPhase); - } - - fixture->Destroy(allocator); - fixture->m_body = NULL; - fixture->m_next = NULL; - fixture->~b2Fixture(); - allocator->Free(fixture, sizeof(b2Fixture)); - - --m_fixtureCount; - - // Reset the mass data. - ResetMassData(); -} - -void b2Body::ResetMassData() -{ - // Compute mass data from shapes. Each shape has its own density. - m_mass = 0.0f; - m_invMass = 0.0f; - m_I = 0.0f; - m_invI = 0.0f; - m_sweep.localCenter.SetZero(); - - // Static and kinematic bodies have zero mass. - if (m_type == b2_staticBody || m_type == b2_kinematicBody) - { - m_sweep.c0 = m_xf.p; - m_sweep.c = m_xf.p; - m_sweep.a0 = m_sweep.a; - return; - } - - b2Assert(m_type == b2_dynamicBody); - - // Accumulate mass over all fixtures. - b2Vec2 localCenter = b2Vec2_zero; - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - if (f->m_density == 0.0f) - { - continue; - } - - b2MassData massData; - f->GetMassData(&massData); - m_mass += massData.mass; - localCenter += massData.mass * massData.center; - m_I += massData.I; - } - - // Compute center of mass. - if (m_mass > 0.0f) - { - m_invMass = 1.0f / m_mass; - localCenter *= m_invMass; - } - else - { - // Force all dynamic bodies to have a positive mass. - m_mass = 1.0f; - m_invMass = 1.0f; - } - - if (m_I > 0.0f && (m_flags & e_fixedRotationFlag) == 0) - { - // Center the inertia about the center of mass. - m_I -= m_mass * b2Dot(localCenter, localCenter); - b2Assert(m_I > 0.0f); - m_invI = 1.0f / m_I; - - } - else - { - m_I = 0.0f; - m_invI = 0.0f; - } - - // Move center of mass. - b2Vec2 oldCenter = m_sweep.c; - m_sweep.localCenter = localCenter; - m_sweep.c0 = m_sweep.c = b2Mul(m_xf, m_sweep.localCenter); - - // Update center of mass velocity. - m_linearVelocity += b2Cross(m_angularVelocity, m_sweep.c - oldCenter); -} - -void b2Body::SetMassData(const b2MassData* massData) -{ - b2Assert(m_world->IsLocked() == false); - if (m_world->IsLocked() == true) - { - return; - } - - if (m_type != b2_dynamicBody) - { - return; - } - - m_invMass = 0.0f; - m_I = 0.0f; - m_invI = 0.0f; - - m_mass = massData->mass; - if (m_mass <= 0.0f) - { - m_mass = 1.0f; - } - - m_invMass = 1.0f / m_mass; - - if (massData->I > 0.0f && (m_flags & b2Body::e_fixedRotationFlag) == 0) - { - m_I = massData->I - m_mass * b2Dot(massData->center, massData->center); - b2Assert(m_I > 0.0f); - m_invI = 1.0f / m_I; - } - - // Move center of mass. - b2Vec2 oldCenter = m_sweep.c; - m_sweep.localCenter = massData->center; - m_sweep.c0 = m_sweep.c = b2Mul(m_xf, m_sweep.localCenter); - - // Update center of mass velocity. - m_linearVelocity += b2Cross(m_angularVelocity, m_sweep.c - oldCenter); -} - -bool b2Body::ShouldCollide(const b2Body* other) const -{ - // At least one body should be dynamic. - if (m_type != b2_dynamicBody && other->m_type != b2_dynamicBody) - { - return false; - } - - // Does a joint prevent collision? - for (b2JointEdge* jn = m_jointList; jn; jn = jn->next) - { - if (jn->other == other) - { - if (jn->joint->m_collideConnected == false) - { - return false; - } - } - } - - return true; -} - -void b2Body::SetTransform(const b2Vec2& position, float32 angle) -{ - b2Assert(m_world->IsLocked() == false); - if (m_world->IsLocked() == true) - { - return; - } - - m_xf.q.Set(angle); - m_xf.p = position; - - m_sweep.c = b2Mul(m_xf, m_sweep.localCenter); - m_sweep.a = angle; - - m_sweep.c0 = m_sweep.c; - m_sweep.a0 = angle; - - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - f->Synchronize(broadPhase, m_xf, m_xf); - } -} - -void b2Body::SynchronizeFixtures() -{ - b2Transform xf1; - xf1.q.Set(m_sweep.a0); - xf1.p = m_sweep.c0 - b2Mul(xf1.q, m_sweep.localCenter); - - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - f->Synchronize(broadPhase, xf1, m_xf); - } -} - -void b2Body::SetActive(bool flag) -{ - b2Assert(m_world->IsLocked() == false); - - if (flag == IsActive()) - { - return; - } - - if (flag) - { - m_flags |= e_activeFlag; - - // Create all proxies. - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - f->CreateProxies(broadPhase, m_xf); - } - - // Contacts are created the next time step. - } - else - { - m_flags &= ~e_activeFlag; - - // Destroy all proxies. - b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - f->DestroyProxies(broadPhase); - } - - // Destroy the attached contacts. - b2ContactEdge* ce = m_contactList; - while (ce) - { - b2ContactEdge* ce0 = ce; - ce = ce->next; - m_world->m_contactManager.Destroy(ce0->contact); - } - m_contactList = NULL; - } -} - -void b2Body::SetFixedRotation(bool flag) -{ - bool status = (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag; - if (status == flag) - { - return; - } - - if (flag) - { - m_flags |= e_fixedRotationFlag; - } - else - { - m_flags &= ~e_fixedRotationFlag; - } - - m_angularVelocity = 0.0f; - - ResetMassData(); -} - -void b2Body::Dump() -{ - int32 bodyIndex = m_islandIndex; - - b2Log("{\n"); - b2Log(" b2BodyDef bd;\n"); - b2Log(" bd.type = b2BodyType(%d);\n", m_type); - b2Log(" bd.position.Set(%.15lef, %.15lef);\n", m_xf.p.x, m_xf.p.y); - b2Log(" bd.angle = %.15lef;\n", m_sweep.a); - b2Log(" bd.linearVelocity.Set(%.15lef, %.15lef);\n", m_linearVelocity.x, m_linearVelocity.y); - b2Log(" bd.angularVelocity = %.15lef;\n", m_angularVelocity); - b2Log(" bd.linearDamping = %.15lef;\n", m_linearDamping); - b2Log(" bd.angularDamping = %.15lef;\n", m_angularDamping); - b2Log(" bd.allowSleep = bool(%d);\n", m_flags & e_autoSleepFlag); - b2Log(" bd.awake = bool(%d);\n", m_flags & e_awakeFlag); - b2Log(" bd.fixedRotation = bool(%d);\n", m_flags & e_fixedRotationFlag); - b2Log(" bd.bullet = bool(%d);\n", m_flags & e_bulletFlag); - b2Log(" bd.active = bool(%d);\n", m_flags & e_activeFlag); - b2Log(" bd.gravityScale = %.15lef;\n", m_gravityScale); - b2Log(" bodies[%d] = m_world->CreateBody(&bd);\n", m_islandIndex); - b2Log("\n"); - for (b2Fixture* f = m_fixtureList; f; f = f->m_next) - { - b2Log(" {\n"); - f->Dump(bodyIndex); - b2Log(" }\n"); - } - b2Log("}\n"); -} diff --git a/sources/Box2D/Dynamics/b2Body.h b/sources/Box2D/Dynamics/b2Body.h deleted file mode 100755 index 5c4d96a5..00000000 --- a/sources/Box2D/Dynamics/b2Body.h +++ /dev/null @@ -1,860 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_BODY_H -#define B2_BODY_H - -#include -#include -#include - -class b2Fixture; -class b2Joint; -class b2Contact; -class b2Controller; -class b2World; -struct b2FixtureDef; -struct b2JointEdge; -struct b2ContactEdge; - -/// The body type. -/// static: zero mass, zero velocity, may be manually moved -/// kinematic: zero mass, non-zero velocity set by user, moved by solver -/// dynamic: positive mass, non-zero velocity determined by forces, moved by solver -enum b2BodyType -{ - b2_staticBody = 0, - b2_kinematicBody, - b2_dynamicBody - - // TODO_ERIN - //b2_bulletBody, -}; - -/// A body definition holds all the data needed to construct a rigid body. -/// You can safely re-use body definitions. Shapes are added to a body after construction. -struct b2BodyDef -{ - /// This constructor sets the body definition default values. - b2BodyDef() - { - userData = NULL; - position.Set(0.0f, 0.0f); - angle = 0.0f; - linearVelocity.Set(0.0f, 0.0f); - angularVelocity = 0.0f; - linearDamping = 0.0f; - angularDamping = 0.0f; - allowSleep = true; - awake = true; - fixedRotation = false; - bullet = false; - type = b2_staticBody; - active = true; - gravityScale = 1.0f; - } - - /// The body type: static, kinematic, or dynamic. - /// Note: if a dynamic body would have zero mass, the mass is set to one. - b2BodyType type; - - /// The world position of the body. Avoid creating bodies at the origin - /// since this can lead to many overlapping shapes. - b2Vec2 position; - - /// The world angle of the body in radians. - float32 angle; - - /// The linear velocity of the body's origin in world co-ordinates. - b2Vec2 linearVelocity; - - /// The angular velocity of the body. - float32 angularVelocity; - - /// Linear damping is use to reduce the linear velocity. The damping parameter - /// can be larger than 1.0f but the damping effect becomes sensitive to the - /// time step when the damping parameter is large. - float32 linearDamping; - - /// Angular damping is use to reduce the angular velocity. The damping parameter - /// can be larger than 1.0f but the damping effect becomes sensitive to the - /// time step when the damping parameter is large. - float32 angularDamping; - - /// Set this flag to false if this body should never fall asleep. Note that - /// this increases CPU usage. - bool allowSleep; - - /// Is this body initially awake or sleeping? - bool awake; - - /// Should this body be prevented from rotating? Useful for characters. - bool fixedRotation; - - /// Is this a fast moving body that should be prevented from tunneling through - /// other moving bodies? Note that all bodies are prevented from tunneling through - /// kinematic and static bodies. This setting is only considered on dynamic bodies. - /// @warning You should use this flag sparingly since it increases processing time. - bool bullet; - - /// Does this body start out active? - bool active; - - /// Use this to store application specific body data. - void* userData; - - /// Scale the gravity applied to this body. - float32 gravityScale; -}; - -/// A rigid body. These are created via b2World::CreateBody. -class b2Body -{ -public: - /// Creates a fixture and attach it to this body. Use this function if you need - /// to set some fixture parameters, like friction. Otherwise you can create the - /// fixture directly from a shape. - /// If the density is non-zero, this function automatically updates the mass of the body. - /// Contacts are not created until the next time step. - /// @param def the fixture definition. - /// @warning This function is locked during callbacks. - b2Fixture* CreateFixture(const b2FixtureDef* def); - - /// Creates a fixture from a shape and attach it to this body. - /// This is a convenience function. Use b2FixtureDef if you need to set parameters - /// like friction, restitution, user data, or filtering. - /// If the density is non-zero, this function automatically updates the mass of the body. - /// @param shape the shape to be cloned. - /// @param density the shape density (set to zero for static bodies). - /// @warning This function is locked during callbacks. - b2Fixture* CreateFixture(const b2Shape* shape, float32 density); - - /// Destroy a fixture. This removes the fixture from the broad-phase and - /// destroys all contacts associated with this fixture. This will - /// automatically adjust the mass of the body if the body is dynamic and the - /// fixture has positive density. - /// All fixtures attached to a body are implicitly destroyed when the body is destroyed. - /// @param fixture the fixture to be removed. - /// @warning This function is locked during callbacks. - void DestroyFixture(b2Fixture* fixture); - - /// Set the position of the body's origin and rotation. - /// Manipulating a body's transform may cause non-physical behavior. - /// Note: contacts are updated on the next call to b2World::Step. - /// @param position the world position of the body's local origin. - /// @param angle the world rotation in radians. - void SetTransform(const b2Vec2& position, float32 angle); - - /// Get the body transform for the body's origin. - /// @return the world transform of the body's origin. - const b2Transform& GetTransform() const; - - /// Get the world body origin position. - /// @return the world position of the body's origin. - const b2Vec2& GetPosition() const; - - /// Get the angle in radians. - /// @return the current world rotation angle in radians. - float32 GetAngle() const; - - /// Get the world position of the center of mass. - const b2Vec2& GetWorldCenter() const; - - /// Get the local position of the center of mass. - const b2Vec2& GetLocalCenter() const; - - /// Set the linear velocity of the center of mass. - /// @param v the new linear velocity of the center of mass. - void SetLinearVelocity(const b2Vec2& v); - - /// Get the linear velocity of the center of mass. - /// @return the linear velocity of the center of mass. - const b2Vec2& GetLinearVelocity() const; - - /// Set the angular velocity. - /// @param omega the new angular velocity in radians/second. - void SetAngularVelocity(float32 omega); - - /// Get the angular velocity. - /// @return the angular velocity in radians/second. - float32 GetAngularVelocity() const; - - /// Apply a force at a world point. If the force is not - /// applied at the center of mass, it will generate a torque and - /// affect the angular velocity. This wakes up the body. - /// @param force the world force vector, usually in Newtons (N). - /// @param point the world position of the point of application. - /// @param wake also wake up the body - void ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake); - - /// Apply a force to the center of mass. This wakes up the body. - /// @param force the world force vector, usually in Newtons (N). - /// @param wake also wake up the body - void ApplyForceToCenter(const b2Vec2& force, bool wake); - - /// Apply a torque. This affects the angular velocity - /// without affecting the linear velocity of the center of mass. - /// This wakes up the body. - /// @param torque about the z-axis (out of the screen), usually in N-m. - /// @param wake also wake up the body - void ApplyTorque(float32 torque, bool wake); - - /// Apply an impulse at a point. This immediately modifies the velocity. - /// It also modifies the angular velocity if the point of application - /// is not at the center of mass. This wakes up the body. - /// @param impulse the world impulse vector, usually in N-seconds or kg-m/s. - /// @param point the world position of the point of application. - /// @param wake also wake up the body - void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake); - - /// Apply an angular impulse. - /// @param impulse the angular impulse in units of kg*m*m/s - /// @param wake also wake up the body - void ApplyAngularImpulse(float32 impulse, bool wake); - - /// Get the total mass of the body. - /// @return the mass, usually in kilograms (kg). - float32 GetMass() const; - - /// Get the rotational inertia of the body about the local origin. - /// @return the rotational inertia, usually in kg-m^2. - float32 GetInertia() const; - - /// Get the mass data of the body. - /// @return a struct containing the mass, inertia and center of the body. - void GetMassData(b2MassData* data) const; - - /// Set the mass properties to override the mass properties of the fixtures. - /// Note that this changes the center of mass position. - /// Note that creating or destroying fixtures can also alter the mass. - /// This function has no effect if the body isn't dynamic. - /// @param massData the mass properties. - void SetMassData(const b2MassData* data); - - /// This resets the mass properties to the sum of the mass properties of the fixtures. - /// This normally does not need to be called unless you called SetMassData to override - /// the mass and you later want to reset the mass. - void ResetMassData(); - - /// Get the world coordinates of a point given the local coordinates. - /// @param localPoint a point on the body measured relative the the body's origin. - /// @return the same point expressed in world coordinates. - b2Vec2 GetWorldPoint(const b2Vec2& localPoint) const; - - /// Get the world coordinates of a vector given the local coordinates. - /// @param localVector a vector fixed in the body. - /// @return the same vector expressed in world coordinates. - b2Vec2 GetWorldVector(const b2Vec2& localVector) const; - - /// Gets a local point relative to the body's origin given a world point. - /// @param a point in world coordinates. - /// @return the corresponding local point relative to the body's origin. - b2Vec2 GetLocalPoint(const b2Vec2& worldPoint) const; - - /// Gets a local vector given a world vector. - /// @param a vector in world coordinates. - /// @return the corresponding local vector. - b2Vec2 GetLocalVector(const b2Vec2& worldVector) const; - - /// Get the world linear velocity of a world point attached to this body. - /// @param a point in world coordinates. - /// @return the world velocity of a point. - b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const; - - /// Get the world velocity of a local point. - /// @param a point in local coordinates. - /// @return the world velocity of a point. - b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const; - - /// Get the linear damping of the body. - float32 GetLinearDamping() const; - - /// Set the linear damping of the body. - void SetLinearDamping(float32 linearDamping); - - /// Get the angular damping of the body. - float32 GetAngularDamping() const; - - /// Set the angular damping of the body. - void SetAngularDamping(float32 angularDamping); - - /// Get the gravity scale of the body. - float32 GetGravityScale() const; - - /// Set the gravity scale of the body. - void SetGravityScale(float32 scale); - - /// Set the type of this body. This may alter the mass and velocity. - void SetType(b2BodyType type); - - /// Get the type of this body. - b2BodyType GetType() const; - - /// Should this body be treated like a bullet for continuous collision detection? - void SetBullet(bool flag); - - /// Is this body treated like a bullet for continuous collision detection? - bool IsBullet() const; - - /// You can disable sleeping on this body. If you disable sleeping, the - /// body will be woken. - void SetSleepingAllowed(bool flag); - - /// Is this body allowed to sleep - bool IsSleepingAllowed() const; - - /// Set the sleep state of the body. A sleeping body has very - /// low CPU cost. - /// @param flag set to true to wake the body, false to put it to sleep. - void SetAwake(bool flag); - - /// Get the sleeping state of this body. - /// @return true if the body is awake. - bool IsAwake() const; - - /// Set the active state of the body. An inactive body is not - /// simulated and cannot be collided with or woken up. - /// If you pass a flag of true, all fixtures will be added to the - /// broad-phase. - /// If you pass a flag of false, all fixtures will be removed from - /// the broad-phase and all contacts will be destroyed. - /// Fixtures and joints are otherwise unaffected. You may continue - /// to create/destroy fixtures and joints on inactive bodies. - /// Fixtures on an inactive body are implicitly inactive and will - /// not participate in collisions, ray-casts, or queries. - /// Joints connected to an inactive body are implicitly inactive. - /// An inactive body is still owned by a b2World object and remains - /// in the body list. - void SetActive(bool flag); - - /// Get the active state of the body. - bool IsActive() const; - - /// Set this body to have fixed rotation. This causes the mass - /// to be reset. - void SetFixedRotation(bool flag); - - /// Does this body have fixed rotation? - bool IsFixedRotation() const; - - /// Get the list of all fixtures attached to this body. - b2Fixture* GetFixtureList(); - const b2Fixture* GetFixtureList() const; - - /// Get the list of all joints attached to this body. - b2JointEdge* GetJointList(); - const b2JointEdge* GetJointList() const; - - /// Get the list of all contacts attached to this body. - /// @warning this list changes during the time step and you may - /// miss some collisions if you don't use b2ContactListener. - b2ContactEdge* GetContactList(); - const b2ContactEdge* GetContactList() const; - - /// Get the next body in the world's body list. - b2Body* GetNext(); - const b2Body* GetNext() const; - - /// Get the user data pointer that was provided in the body definition. - void* GetUserData() const; - - /// Set the user data. Use this to store your application specific data. - void SetUserData(void* data); - - /// Get the parent world of this body. - b2World* GetWorld(); - const b2World* GetWorld() const; - - /// Dump this body to a log file - void Dump(); - -private: - - friend class b2World; - friend class b2Island; - friend class b2ContactManager; - friend class b2ContactSolver; - friend class b2Contact; - - friend class b2DistanceJoint; - friend class b2FrictionJoint; - friend class b2GearJoint; - friend class b2MotorJoint; - friend class b2MouseJoint; - friend class b2PrismaticJoint; - friend class b2PulleyJoint; - friend class b2RevoluteJoint; - friend class b2RopeJoint; - friend class b2WeldJoint; - friend class b2WheelJoint; - - // m_flags - enum - { - e_islandFlag = 0x0001, - e_awakeFlag = 0x0002, - e_autoSleepFlag = 0x0004, - e_bulletFlag = 0x0008, - e_fixedRotationFlag = 0x0010, - e_activeFlag = 0x0020, - e_toiFlag = 0x0040 - }; - - b2Body(const b2BodyDef* bd, b2World* world); - ~b2Body(); - - void SynchronizeFixtures(); - void SynchronizeTransform(); - - // This is used to prevent connected bodies from colliding. - // It may lie, depending on the collideConnected flag. - bool ShouldCollide(const b2Body* other) const; - - void Advance(float32 t); - - b2BodyType m_type; - - uint16 m_flags; - - int32 m_islandIndex; - - b2Transform m_xf; // the body origin transform - b2Sweep m_sweep; // the swept motion for CCD - - b2Vec2 m_linearVelocity; - float32 m_angularVelocity; - - b2Vec2 m_force; - float32 m_torque; - - b2World* m_world; - b2Body* m_prev; - b2Body* m_next; - - b2Fixture* m_fixtureList; - int32 m_fixtureCount; - - b2JointEdge* m_jointList; - b2ContactEdge* m_contactList; - - float32 m_mass, m_invMass; - - // Rotational inertia about the center of mass. - float32 m_I, m_invI; - - float32 m_linearDamping; - float32 m_angularDamping; - float32 m_gravityScale; - - float32 m_sleepTime; - - void* m_userData; -}; - -inline b2BodyType b2Body::GetType() const -{ - return m_type; -} - -inline const b2Transform& b2Body::GetTransform() const -{ - return m_xf; -} - -inline const b2Vec2& b2Body::GetPosition() const -{ - return m_xf.p; -} - -inline float32 b2Body::GetAngle() const -{ - return m_sweep.a; -} - -inline const b2Vec2& b2Body::GetWorldCenter() const -{ - return m_sweep.c; -} - -inline const b2Vec2& b2Body::GetLocalCenter() const -{ - return m_sweep.localCenter; -} - -inline void b2Body::SetLinearVelocity(const b2Vec2& v) -{ - if (m_type == b2_staticBody) - { - return; - } - - if (b2Dot(v,v) > 0.0f) - { - SetAwake(true); - } - - m_linearVelocity = v; -} - -inline const b2Vec2& b2Body::GetLinearVelocity() const -{ - return m_linearVelocity; -} - -inline void b2Body::SetAngularVelocity(float32 w) -{ - if (m_type == b2_staticBody) - { - return; - } - - if (w * w > 0.0f) - { - SetAwake(true); - } - - m_angularVelocity = w; -} - -inline float32 b2Body::GetAngularVelocity() const -{ - return m_angularVelocity; -} - -inline float32 b2Body::GetMass() const -{ - return m_mass; -} - -inline float32 b2Body::GetInertia() const -{ - return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter); -} - -inline void b2Body::GetMassData(b2MassData* data) const -{ - data->mass = m_mass; - data->I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter); - data->center = m_sweep.localCenter; -} - -inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const -{ - return b2Mul(m_xf, localPoint); -} - -inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const -{ - return b2Mul(m_xf.q, localVector); -} - -inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const -{ - return b2MulT(m_xf, worldPoint); -} - -inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const -{ - return b2MulT(m_xf.q, worldVector); -} - -inline b2Vec2 b2Body::GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const -{ - return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c); -} - -inline b2Vec2 b2Body::GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const -{ - return GetLinearVelocityFromWorldPoint(GetWorldPoint(localPoint)); -} - -inline float32 b2Body::GetLinearDamping() const -{ - return m_linearDamping; -} - -inline void b2Body::SetLinearDamping(float32 linearDamping) -{ - m_linearDamping = linearDamping; -} - -inline float32 b2Body::GetAngularDamping() const -{ - return m_angularDamping; -} - -inline void b2Body::SetAngularDamping(float32 angularDamping) -{ - m_angularDamping = angularDamping; -} - -inline float32 b2Body::GetGravityScale() const -{ - return m_gravityScale; -} - -inline void b2Body::SetGravityScale(float32 scale) -{ - m_gravityScale = scale; -} - -inline void b2Body::SetBullet(bool flag) -{ - if (flag) - { - m_flags |= e_bulletFlag; - } - else - { - m_flags &= ~e_bulletFlag; - } -} - -inline bool b2Body::IsBullet() const -{ - return (m_flags & e_bulletFlag) == e_bulletFlag; -} - -inline void b2Body::SetAwake(bool flag) -{ - if (flag) - { - if ((m_flags & e_awakeFlag) == 0) - { - m_flags |= e_awakeFlag; - m_sleepTime = 0.0f; - } - } - else - { - m_flags &= ~e_awakeFlag; - m_sleepTime = 0.0f; - m_linearVelocity.SetZero(); - m_angularVelocity = 0.0f; - m_force.SetZero(); - m_torque = 0.0f; - } -} - -inline bool b2Body::IsAwake() const -{ - return (m_flags & e_awakeFlag) == e_awakeFlag; -} - -inline bool b2Body::IsActive() const -{ - return (m_flags & e_activeFlag) == e_activeFlag; -} - -inline bool b2Body::IsFixedRotation() const -{ - return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag; -} - -inline void b2Body::SetSleepingAllowed(bool flag) -{ - if (flag) - { - m_flags |= e_autoSleepFlag; - } - else - { - m_flags &= ~e_autoSleepFlag; - SetAwake(true); - } -} - -inline bool b2Body::IsSleepingAllowed() const -{ - return (m_flags & e_autoSleepFlag) == e_autoSleepFlag; -} - -inline b2Fixture* b2Body::GetFixtureList() -{ - return m_fixtureList; -} - -inline const b2Fixture* b2Body::GetFixtureList() const -{ - return m_fixtureList; -} - -inline b2JointEdge* b2Body::GetJointList() -{ - return m_jointList; -} - -inline const b2JointEdge* b2Body::GetJointList() const -{ - return m_jointList; -} - -inline b2ContactEdge* b2Body::GetContactList() -{ - return m_contactList; -} - -inline const b2ContactEdge* b2Body::GetContactList() const -{ - return m_contactList; -} - -inline b2Body* b2Body::GetNext() -{ - return m_next; -} - -inline const b2Body* b2Body::GetNext() const -{ - return m_next; -} - -inline void b2Body::SetUserData(void* data) -{ - m_userData = data; -} - -inline void* b2Body::GetUserData() const -{ - return m_userData; -} - -inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point, bool wake) -{ - if (m_type != b2_dynamicBody) - { - return; - } - - if (wake && (m_flags & e_awakeFlag) == 0) - { - SetAwake(true); - } - - // Don't accumulate a force if the body is sleeping. - if (m_flags & e_awakeFlag) - { - m_force += force; - m_torque += b2Cross(point - m_sweep.c, force); - } -} - -inline void b2Body::ApplyForceToCenter(const b2Vec2& force, bool wake) -{ - if (m_type != b2_dynamicBody) - { - return; - } - - if (wake && (m_flags & e_awakeFlag) == 0) - { - SetAwake(true); - } - - // Don't accumulate a force if the body is sleeping - if (m_flags & e_awakeFlag) - { - m_force += force; - } -} - -inline void b2Body::ApplyTorque(float32 torque, bool wake) -{ - if (m_type != b2_dynamicBody) - { - return; - } - - if (wake && (m_flags & e_awakeFlag) == 0) - { - SetAwake(true); - } - - // Don't accumulate a force if the body is sleeping - if (m_flags & e_awakeFlag) - { - m_torque += torque; - } -} - -inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake) -{ - if (m_type != b2_dynamicBody) - { - return; - } - - if (wake && (m_flags & e_awakeFlag) == 0) - { - SetAwake(true); - } - - // Don't accumulate velocity if the body is sleeping - if (m_flags & e_awakeFlag) - { - m_linearVelocity += m_invMass * impulse; - m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse); - } -} - -inline void b2Body::ApplyAngularImpulse(float32 impulse, bool wake) -{ - if (m_type != b2_dynamicBody) - { - return; - } - - if (wake && (m_flags & e_awakeFlag) == 0) - { - SetAwake(true); - } - - // Don't accumulate velocity if the body is sleeping - if (m_flags & e_awakeFlag) - { - m_angularVelocity += m_invI * impulse; - } -} - -inline void b2Body::SynchronizeTransform() -{ - m_xf.q.Set(m_sweep.a); - m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter); -} - -inline void b2Body::Advance(float32 alpha) -{ - // Advance to the new safe time. This doesn't sync the broad-phase. - m_sweep.Advance(alpha); - m_sweep.c = m_sweep.c0; - m_sweep.a = m_sweep.a0; - m_xf.q.Set(m_sweep.a); - m_xf.p = m_sweep.c - b2Mul(m_xf.q, m_sweep.localCenter); -} - -inline b2World* b2Body::GetWorld() -{ - return m_world; -} - -inline const b2World* b2Body::GetWorld() const -{ - return m_world; -} - -#endif diff --git a/sources/Box2D/Dynamics/b2ContactManager.cpp b/sources/Box2D/Dynamics/b2ContactManager.cpp deleted file mode 100755 index d71439ce..00000000 --- a/sources/Box2D/Dynamics/b2ContactManager.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include - -b2ContactFilter b2_defaultFilter; -b2ContactListener b2_defaultListener; - -b2ContactManager::b2ContactManager() -{ - m_contactList = NULL; - m_contactCount = 0; - m_contactFilter = &b2_defaultFilter; - m_contactListener = &b2_defaultListener; - m_allocator = NULL; -} - -void b2ContactManager::Destroy(b2Contact* c) -{ - b2Fixture* fixtureA = c->GetFixtureA(); - b2Fixture* fixtureB = c->GetFixtureB(); - b2Body* bodyA = fixtureA->GetBody(); - b2Body* bodyB = fixtureB->GetBody(); - - if (m_contactListener && c->IsTouching()) - { - m_contactListener->EndContact(c); - } - - // Remove from the world. - if (c->m_prev) - { - c->m_prev->m_next = c->m_next; - } - - if (c->m_next) - { - c->m_next->m_prev = c->m_prev; - } - - if (c == m_contactList) - { - m_contactList = c->m_next; - } - - // Remove from body 1 - if (c->m_nodeA.prev) - { - c->m_nodeA.prev->next = c->m_nodeA.next; - } - - if (c->m_nodeA.next) - { - c->m_nodeA.next->prev = c->m_nodeA.prev; - } - - if (&c->m_nodeA == bodyA->m_contactList) - { - bodyA->m_contactList = c->m_nodeA.next; - } - - // Remove from body 2 - if (c->m_nodeB.prev) - { - c->m_nodeB.prev->next = c->m_nodeB.next; - } - - if (c->m_nodeB.next) - { - c->m_nodeB.next->prev = c->m_nodeB.prev; - } - - if (&c->m_nodeB == bodyB->m_contactList) - { - bodyB->m_contactList = c->m_nodeB.next; - } - - // Call the factory. - b2Contact::Destroy(c, m_allocator); - --m_contactCount; -} - -// This is the top level collision call for the time step. Here -// all the narrow phase collision is processed for the world -// contact list. -void b2ContactManager::Collide() -{ - // Update awake contacts. - b2Contact* c = m_contactList; - while (c) - { - b2Fixture* fixtureA = c->GetFixtureA(); - b2Fixture* fixtureB = c->GetFixtureB(); - int32 indexA = c->GetChildIndexA(); - int32 indexB = c->GetChildIndexB(); - b2Body* bodyA = fixtureA->GetBody(); - b2Body* bodyB = fixtureB->GetBody(); - - // Is this contact flagged for filtering? - if (c->m_flags & b2Contact::e_filterFlag) - { - // Should these bodies collide? - if (bodyB->ShouldCollide(bodyA) == false) - { - b2Contact* cNuke = c; - c = cNuke->GetNext(); - Destroy(cNuke); - continue; - } - - // Check user filtering. - if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false) - { - b2Contact* cNuke = c; - c = cNuke->GetNext(); - Destroy(cNuke); - continue; - } - - // Clear the filtering flag. - c->m_flags &= ~b2Contact::e_filterFlag; - } - - bool activeA = bodyA->IsAwake() && bodyA->m_type != b2_staticBody; - bool activeB = bodyB->IsAwake() && bodyB->m_type != b2_staticBody; - - // At least one body must be awake and it must be dynamic or kinematic. - if (activeA == false && activeB == false) - { - c = c->GetNext(); - continue; - } - - int32 proxyIdA = fixtureA->m_proxies[indexA].proxyId; - int32 proxyIdB = fixtureB->m_proxies[indexB].proxyId; - bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB); - - // Here we destroy contacts that cease to overlap in the broad-phase. - if (overlap == false) - { - b2Contact* cNuke = c; - c = cNuke->GetNext(); - Destroy(cNuke); - continue; - } - - // The contact persists. - c->Update(m_contactListener); - c = c->GetNext(); - } -} - -void b2ContactManager::FindNewContacts() -{ - m_broadPhase.UpdatePairs(this); -} - -void b2ContactManager::AddPair(void* proxyUserDataA, void* proxyUserDataB) -{ - b2FixtureProxy* proxyA = (b2FixtureProxy*)proxyUserDataA; - b2FixtureProxy* proxyB = (b2FixtureProxy*)proxyUserDataB; - - b2Fixture* fixtureA = proxyA->fixture; - b2Fixture* fixtureB = proxyB->fixture; - - int32 indexA = proxyA->childIndex; - int32 indexB = proxyB->childIndex; - - b2Body* bodyA = fixtureA->GetBody(); - b2Body* bodyB = fixtureB->GetBody(); - - // Are the fixtures on the same body? - if (bodyA == bodyB) - { - return; - } - - // TODO_ERIN use a hash table to remove a potential bottleneck when both - // bodies have a lot of contacts. - // Does a contact already exist? - b2ContactEdge* edge = bodyB->GetContactList(); - while (edge) - { - if (edge->other == bodyA) - { - b2Fixture* fA = edge->contact->GetFixtureA(); - b2Fixture* fB = edge->contact->GetFixtureB(); - int32 iA = edge->contact->GetChildIndexA(); - int32 iB = edge->contact->GetChildIndexB(); - - if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) - { - // A contact already exists. - return; - } - - if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) - { - // A contact already exists. - return; - } - } - - edge = edge->next; - } - - // Does a joint override collision? Is at least one body dynamic? - if (bodyB->ShouldCollide(bodyA) == false) - { - return; - } - - // Check user filtering. - if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false) - { - return; - } - - // Call the factory. - b2Contact* c = b2Contact::Create(fixtureA, indexA, fixtureB, indexB, m_allocator); - if (c == NULL) - { - return; - } - - // Contact creation may swap fixtures. - fixtureA = c->GetFixtureA(); - fixtureB = c->GetFixtureB(); - indexA = c->GetChildIndexA(); - indexB = c->GetChildIndexB(); - bodyA = fixtureA->GetBody(); - bodyB = fixtureB->GetBody(); - - // Insert into the world. - c->m_prev = NULL; - c->m_next = m_contactList; - if (m_contactList != NULL) - { - m_contactList->m_prev = c; - } - m_contactList = c; - - // Connect to island graph. - - // Connect to body A - c->m_nodeA.contact = c; - c->m_nodeA.other = bodyB; - - c->m_nodeA.prev = NULL; - c->m_nodeA.next = bodyA->m_contactList; - if (bodyA->m_contactList != NULL) - { - bodyA->m_contactList->prev = &c->m_nodeA; - } - bodyA->m_contactList = &c->m_nodeA; - - // Connect to body B - c->m_nodeB.contact = c; - c->m_nodeB.other = bodyA; - - c->m_nodeB.prev = NULL; - c->m_nodeB.next = bodyB->m_contactList; - if (bodyB->m_contactList != NULL) - { - bodyB->m_contactList->prev = &c->m_nodeB; - } - bodyB->m_contactList = &c->m_nodeB; - - // Wake up the bodies - if (fixtureA->IsSensor() == false && fixtureB->IsSensor() == false) - { - bodyA->SetAwake(true); - bodyB->SetAwake(true); - } - - ++m_contactCount; -} diff --git a/sources/Box2D/Dynamics/b2ContactManager.h b/sources/Box2D/Dynamics/b2ContactManager.h deleted file mode 100755 index dc1f77fe..00000000 --- a/sources/Box2D/Dynamics/b2ContactManager.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_CONTACT_MANAGER_H -#define B2_CONTACT_MANAGER_H - -#include - -class b2Contact; -class b2ContactFilter; -class b2ContactListener; -class b2BlockAllocator; - -// Delegate of b2World. -class b2ContactManager -{ -public: - b2ContactManager(); - - // Broad-phase callback. - void AddPair(void* proxyUserDataA, void* proxyUserDataB); - - void FindNewContacts(); - - void Destroy(b2Contact* c); - - void Collide(); - - b2BroadPhase m_broadPhase; - b2Contact* m_contactList; - int32 m_contactCount; - b2ContactFilter* m_contactFilter; - b2ContactListener* m_contactListener; - b2BlockAllocator* m_allocator; -}; - -#endif diff --git a/sources/Box2D/Dynamics/b2Fixture.cpp b/sources/Box2D/Dynamics/b2Fixture.cpp deleted file mode 100755 index cacc5f9a..00000000 --- a/sources/Box2D/Dynamics/b2Fixture.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -b2Fixture::b2Fixture() -{ - m_userData = NULL; - m_body = NULL; - m_next = NULL; - m_proxies = NULL; - m_proxyCount = 0; - m_shape = NULL; - m_density = 0.0f; -} - -void b2Fixture::Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def) -{ - m_userData = def->userData; - m_friction = def->friction; - m_restitution = def->restitution; - - m_body = body; - m_next = NULL; - - m_filter = def->filter; - - m_isSensor = def->isSensor; - - m_shape = def->shape->Clone(allocator); - - // Reserve proxy space - int32 childCount = m_shape->GetChildCount(); - m_proxies = (b2FixtureProxy*)allocator->Allocate(childCount * sizeof(b2FixtureProxy)); - for (int32 i = 0; i < childCount; ++i) - { - m_proxies[i].fixture = NULL; - m_proxies[i].proxyId = b2BroadPhase::e_nullProxy; - } - m_proxyCount = 0; - - m_density = def->density; -} - -void b2Fixture::Destroy(b2BlockAllocator* allocator) -{ - // The proxies must be destroyed before calling this. - b2Assert(m_proxyCount == 0); - - // Free the proxy array. - int32 childCount = m_shape->GetChildCount(); - allocator->Free(m_proxies, childCount * sizeof(b2FixtureProxy)); - m_proxies = NULL; - - // Free the child shape. - switch (m_shape->m_type) - { - case b2Shape::e_circle: - { - b2CircleShape* s = (b2CircleShape*)m_shape; - b2NotifyObjectDestroyed(s, b2ObjectType::CIRCLE_SHAPE, "b2CircleShape"); - s->~b2CircleShape(); - allocator->Free(s, sizeof(b2CircleShape)); - } - break; - - case b2Shape::e_edge: - { - b2EdgeShape* s = (b2EdgeShape*)m_shape; - b2NotifyObjectDestroyed(s, b2ObjectType::EDGE_SHAPE, "b2EdgeShape"); - s->~b2EdgeShape(); - allocator->Free(s, sizeof(b2EdgeShape)); - } - break; - - case b2Shape::e_polygon: - { - b2PolygonShape* s = (b2PolygonShape*)m_shape; - b2NotifyObjectDestroyed(s, b2ObjectType::POLYGON_SHAPE, "b2PolygonShape"); - s->~b2PolygonShape(); - allocator->Free(s, sizeof(b2PolygonShape)); - } - break; - - case b2Shape::e_chain: - { - b2ChainShape* s = (b2ChainShape*)m_shape; - b2NotifyObjectDestroyed(s, b2ObjectType::CHAIN_SHAPE, "b2ChainShape"); - s->~b2ChainShape(); - allocator->Free(s, sizeof(b2ChainShape)); - } - break; - - default: - b2Assert(false); - break; - } - - m_shape = NULL; - - b2NotifyObjectDestroyed(this, b2ObjectType::FIXTURE, "b2Fixture"); -} - -void b2Fixture::CreateProxies(b2BroadPhase* broadPhase, const b2Transform& xf) -{ - b2Assert(m_proxyCount == 0); - - // Create proxies in the broad-phase. - m_proxyCount = m_shape->GetChildCount(); - - for (int32 i = 0; i < m_proxyCount; ++i) - { - b2FixtureProxy* proxy = m_proxies + i; - m_shape->ComputeAABB(&proxy->aabb, xf, i); - proxy->proxyId = broadPhase->CreateProxy(proxy->aabb, proxy); - proxy->fixture = this; - proxy->childIndex = i; - } -} - -void b2Fixture::DestroyProxies(b2BroadPhase* broadPhase) -{ - // Destroy proxies in the broad-phase. - for (int32 i = 0; i < m_proxyCount; ++i) - { - b2FixtureProxy* proxy = m_proxies + i; - broadPhase->DestroyProxy(proxy->proxyId); - proxy->proxyId = b2BroadPhase::e_nullProxy; - } - - m_proxyCount = 0; -} - -void b2Fixture::Synchronize(b2BroadPhase* broadPhase, const b2Transform& transform1, const b2Transform& transform2) -{ - if (m_proxyCount == 0) - { - return; - } - - for (int32 i = 0; i < m_proxyCount; ++i) - { - b2FixtureProxy* proxy = m_proxies + i; - - // Compute an AABB that covers the swept shape (may miss some rotation effect). - b2AABB aabb1, aabb2; - m_shape->ComputeAABB(&aabb1, transform1, proxy->childIndex); - m_shape->ComputeAABB(&aabb2, transform2, proxy->childIndex); - - proxy->aabb.Combine(aabb1, aabb2); - - b2Vec2 displacement = transform2.p - transform1.p; - - broadPhase->MoveProxy(proxy->proxyId, proxy->aabb, displacement); - } -} - -void b2Fixture::SetFilterData(const b2Filter& filter) -{ - m_filter = filter; - - Refilter(); -} - -void b2Fixture::Refilter() -{ - if (m_body == NULL) - { - return; - } - - // Flag associated contacts for filtering. - b2ContactEdge* edge = m_body->GetContactList(); - while (edge) - { - b2Contact* contact = edge->contact; - b2Fixture* fixtureA = contact->GetFixtureA(); - b2Fixture* fixtureB = contact->GetFixtureB(); - if (fixtureA == this || fixtureB == this) - { - contact->FlagForFiltering(); - } - - edge = edge->next; - } - - b2World* world = m_body->GetWorld(); - - if (world == NULL) - { - return; - } - - // Touch each proxy so that new pairs may be created - b2BroadPhase* broadPhase = &world->m_contactManager.m_broadPhase; - for (int32 i = 0; i < m_proxyCount; ++i) - { - broadPhase->TouchProxy(m_proxies[i].proxyId); - } -} - -void b2Fixture::SetSensor(bool sensor) -{ - if (sensor != m_isSensor) - { - m_body->SetAwake(true); - m_isSensor = sensor; - } -} - -void b2Fixture::Dump(int32 bodyIndex) -{ - b2Log(" b2FixtureDef fd;\n"); - b2Log(" fd.friction = %.15lef;\n", m_friction); - b2Log(" fd.restitution = %.15lef;\n", m_restitution); - b2Log(" fd.density = %.15lef;\n", m_density); - b2Log(" fd.isSensor = bool(%d);\n", m_isSensor); - b2Log(" fd.filter.categoryBits = uint16(%d);\n", m_filter.categoryBits); - b2Log(" fd.filter.maskBits = uint16(%d);\n", m_filter.maskBits); - b2Log(" fd.filter.groupIndex = int16(%d);\n", m_filter.groupIndex); - - switch (m_shape->m_type) - { - case b2Shape::e_circle: - { - b2CircleShape* s = (b2CircleShape*)m_shape; - b2Log(" b2CircleShape shape;\n"); - b2Log(" shape.m_radius = %.15lef;\n", s->m_radius); - b2Log(" shape.m_p.Set(%.15lef, %.15lef);\n", s->m_p.x, s->m_p.y); - } - break; - - case b2Shape::e_edge: - { - b2EdgeShape* s = (b2EdgeShape*)m_shape; - b2Log(" b2EdgeShape shape;\n"); - b2Log(" shape.m_radius = %.15lef;\n", s->m_radius); - b2Log(" shape.m_vertex0.Set(%.15lef, %.15lef);\n", s->m_vertex0.x, s->m_vertex0.y); - b2Log(" shape.m_vertex1.Set(%.15lef, %.15lef);\n", s->m_vertex1.x, s->m_vertex1.y); - b2Log(" shape.m_vertex2.Set(%.15lef, %.15lef);\n", s->m_vertex2.x, s->m_vertex2.y); - b2Log(" shape.m_vertex3.Set(%.15lef, %.15lef);\n", s->m_vertex3.x, s->m_vertex3.y); - b2Log(" shape.m_hasVertex0 = bool(%d);\n", s->m_hasVertex0); - b2Log(" shape.m_hasVertex3 = bool(%d);\n", s->m_hasVertex3); - } - break; - - case b2Shape::e_polygon: - { - b2PolygonShape* s = (b2PolygonShape*)m_shape; - b2Log(" b2PolygonShape shape;\n"); - b2Log(" b2Vec2 vs[%d];\n", b2_maxPolygonVertices); - for (int32 i = 0; i < s->m_count; ++i) - { - b2Log(" vs[%d].Set(%.15lef, %.15lef);\n", i, s->m_vertices[i].x, s->m_vertices[i].y); - } - b2Log(" shape.Set(vs, %d);\n", s->m_count); - } - break; - - case b2Shape::e_chain: - { - b2ChainShape* s = (b2ChainShape*)m_shape; - b2Log(" b2ChainShape shape;\n"); - b2Log(" b2Vec2 vs[%d];\n", s->m_count); - for (int32 i = 0; i < s->m_count; ++i) - { - b2Log(" vs[%d].Set(%.15lef, %.15lef);\n", i, s->m_vertices[i].x, s->m_vertices[i].y); - } - b2Log(" shape.CreateChain(vs, %d);\n", s->m_count); - b2Log(" shape.m_prevVertex.Set(%.15lef, %.15lef);\n", s->m_prevVertex.x, s->m_prevVertex.y); - b2Log(" shape.m_nextVertex.Set(%.15lef, %.15lef);\n", s->m_nextVertex.x, s->m_nextVertex.y); - b2Log(" shape.m_hasPrevVertex = bool(%d);\n", s->m_hasPrevVertex); - b2Log(" shape.m_hasNextVertex = bool(%d);\n", s->m_hasNextVertex); - } - break; - - default: - return; - } - - b2Log("\n"); - b2Log(" fd.shape = &shape;\n"); - b2Log("\n"); - b2Log(" bodies[%d]->CreateFixture(&fd);\n", bodyIndex); -} diff --git a/sources/Box2D/Dynamics/b2Fixture.h b/sources/Box2D/Dynamics/b2Fixture.h deleted file mode 100755 index 5ebd0c3f..00000000 --- a/sources/Box2D/Dynamics/b2Fixture.h +++ /dev/null @@ -1,345 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_FIXTURE_H -#define B2_FIXTURE_H - -#include -#include -#include - -class b2BlockAllocator; -class b2Body; -class b2BroadPhase; -class b2Fixture; - -/// This holds contact filtering data. -struct b2Filter -{ - b2Filter() - { - categoryBits = 0x0001; - maskBits = 0xFFFF; - groupIndex = 0; - } - - /// The collision category bits. Normally you would just set one bit. - uint16 categoryBits; - - /// The collision mask bits. This states the categories that this - /// shape would accept for collision. - uint16 maskBits; - - /// Collision groups allow a certain group of objects to never collide (negative) - /// or always collide (positive). Zero means no collision group. Non-zero group - /// filtering always wins against the mask bits. - int16 groupIndex; -}; - -/// A fixture definition is used to create a fixture. This class defines an -/// abstract fixture definition. You can reuse fixture definitions safely. -struct b2FixtureDef -{ - /// The constructor sets the default fixture definition values. - b2FixtureDef() - { - shape = NULL; - userData = NULL; - friction = 0.2f; - restitution = 0.0f; - density = 0.0f; - isSensor = false; - } - - /// The shape, this must be set. The shape will be cloned, so you - /// can create the shape on the stack. - const b2Shape* shape; - - /// Use this to store application specific fixture data. - void* userData; - - /// The friction coefficient, usually in the range [0,1]. - float32 friction; - - /// The restitution (elasticity) usually in the range [0,1]. - float32 restitution; - - /// The density, usually in kg/m^2. - float32 density; - - /// A sensor shape collects contact information but never generates a collision - /// response. - bool isSensor; - - /// Contact filtering data. - b2Filter filter; -}; - -/// This proxy is used internally to connect fixtures to the broad-phase. -struct b2FixtureProxy -{ - b2AABB aabb; - b2Fixture* fixture; - int32 childIndex; - int32 proxyId; -}; - -/// A fixture is used to attach a shape to a body for collision detection. A fixture -/// inherits its transform from its parent. Fixtures hold additional non-geometric data -/// such as friction, collision filters, etc. -/// Fixtures are created via b2Body::CreateFixture. -/// @warning you cannot reuse fixtures. -class b2Fixture -{ -public: - /// Get the type of the child shape. You can use this to down cast to the concrete shape. - /// @return the shape type. - b2Shape::Type GetType() const; - - /// Get the child shape. You can modify the child shape, however you should not change the - /// number of vertices because this will crash some collision caching mechanisms. - /// Manipulating the shape may lead to non-physical behavior. - b2Shape* GetShape(); - const b2Shape* GetShape() const; - - /// Set if this fixture is a sensor. - void SetSensor(bool sensor); - - /// Is this fixture a sensor (non-solid)? - /// @return the true if the shape is a sensor. - bool IsSensor() const; - - /// Set the contact filtering data. This will not update contacts until the next time - /// step when either parent body is active and awake. - /// This automatically calls Refilter. - void SetFilterData(const b2Filter& filter); - - /// Get the contact filtering data. - const b2Filter& GetFilterData() const; - - /// Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide. - void Refilter(); - - /// Get the parent body of this fixture. This is NULL if the fixture is not attached. - /// @return the parent body. - b2Body* GetBody(); - const b2Body* GetBody() const; - - /// Get the next fixture in the parent body's fixture list. - /// @return the next shape. - b2Fixture* GetNext(); - const b2Fixture* GetNext() const; - - /// Get the user data that was assigned in the fixture definition. Use this to - /// store your application specific data. - void* GetUserData() const; - - /// Set the user data. Use this to store your application specific data. - void SetUserData(void* data); - - /// Test a point for containment in this fixture. - /// @param p a point in world coordinates. - bool TestPoint(const b2Vec2& p) const; - - /// Cast a ray against this shape. - /// @param output the ray-cast results. - /// @param input the ray-cast input parameters. - bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input, int32 childIndex) const; - - /// Get the mass data for this fixture. The mass data is based on the density and - /// the shape. The rotational inertia is about the shape's origin. This operation - /// may be expensive. - void GetMassData(b2MassData* massData) const; - - /// Set the density of this fixture. This will _not_ automatically adjust the mass - /// of the body. You must call b2Body::ResetMassData to update the body's mass. - void SetDensity(float32 density); - - /// Get the density of this fixture. - float32 GetDensity() const; - - /// Get the coefficient of friction. - float32 GetFriction() const; - - /// Set the coefficient of friction. This will _not_ change the friction of - /// existing contacts. - void SetFriction(float32 friction); - - /// Get the coefficient of restitution. - float32 GetRestitution() const; - - /// Set the coefficient of restitution. This will _not_ change the restitution of - /// existing contacts. - void SetRestitution(float32 restitution); - - /// Get the fixture's AABB. This AABB may be enlarge and/or stale. - /// If you need a more accurate AABB, compute it using the shape and - /// the body transform. - const b2AABB& GetAABB(int32 childIndex) const; - - /// Dump this fixture to the log file. - void Dump(int32 bodyIndex); - -protected: - - friend class b2Body; - friend class b2World; - friend class b2Contact; - friend class b2ContactManager; - - b2Fixture(); - - // We need separation create/destroy functions from the constructor/destructor because - // the destructor cannot access the allocator (no destructor arguments allowed by C++). - void Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def); - void Destroy(b2BlockAllocator* allocator); - - // These support body activation/deactivation. - void CreateProxies(b2BroadPhase* broadPhase, const b2Transform& xf); - void DestroyProxies(b2BroadPhase* broadPhase); - - void Synchronize(b2BroadPhase* broadPhase, const b2Transform& xf1, const b2Transform& xf2); - - float32 m_density; - - b2Fixture* m_next; - b2Body* m_body; - - b2Shape* m_shape; - - float32 m_friction; - float32 m_restitution; - - b2FixtureProxy* m_proxies; - int32 m_proxyCount; - - b2Filter m_filter; - - bool m_isSensor; - - void* m_userData; -}; - -inline b2Shape::Type b2Fixture::GetType() const -{ - return m_shape->GetType(); -} - -inline b2Shape* b2Fixture::GetShape() -{ - return m_shape; -} - -inline const b2Shape* b2Fixture::GetShape() const -{ - return m_shape; -} - -inline bool b2Fixture::IsSensor() const -{ - return m_isSensor; -} - -inline const b2Filter& b2Fixture::GetFilterData() const -{ - return m_filter; -} - -inline void* b2Fixture::GetUserData() const -{ - return m_userData; -} - -inline void b2Fixture::SetUserData(void* data) -{ - m_userData = data; -} - -inline b2Body* b2Fixture::GetBody() -{ - return m_body; -} - -inline const b2Body* b2Fixture::GetBody() const -{ - return m_body; -} - -inline b2Fixture* b2Fixture::GetNext() -{ - return m_next; -} - -inline const b2Fixture* b2Fixture::GetNext() const -{ - return m_next; -} - -inline void b2Fixture::SetDensity(float32 density) -{ - b2Assert(b2IsValid(density) && density >= 0.0f); - m_density = density; -} - -inline float32 b2Fixture::GetDensity() const -{ - return m_density; -} - -inline float32 b2Fixture::GetFriction() const -{ - return m_friction; -} - -inline void b2Fixture::SetFriction(float32 friction) -{ - m_friction = friction; -} - -inline float32 b2Fixture::GetRestitution() const -{ - return m_restitution; -} - -inline void b2Fixture::SetRestitution(float32 restitution) -{ - m_restitution = restitution; -} - -inline bool b2Fixture::TestPoint(const b2Vec2& p) const -{ - return m_shape->TestPoint(m_body->GetTransform(), p); -} - -inline bool b2Fixture::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, int32 childIndex) const -{ - return m_shape->RayCast(output, input, m_body->GetTransform(), childIndex); -} - -inline void b2Fixture::GetMassData(b2MassData* massData) const -{ - m_shape->ComputeMass(massData, m_density); -} - -inline const b2AABB& b2Fixture::GetAABB(int32 childIndex) const -{ - b2Assert(0 <= childIndex && childIndex < m_proxyCount); - return m_proxies[childIndex].aabb; -} - -#endif diff --git a/sources/Box2D/Dynamics/b2Island.cpp b/sources/Box2D/Dynamics/b2Island.cpp deleted file mode 100755 index b0cb19aa..00000000 --- a/sources/Box2D/Dynamics/b2Island.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* -Position Correction Notes -========================= -I tried the several algorithms for position correction of the 2D revolute joint. -I looked at these systems: -- simple pendulum (1m diameter sphere on massless 5m stick) with initial angular velocity of 100 rad/s. -- suspension bridge with 30 1m long planks of length 1m. -- multi-link chain with 30 1m long links. - -Here are the algorithms: - -Baumgarte - A fraction of the position error is added to the velocity error. There is no -separate position solver. - -Pseudo Velocities - After the velocity solver and position integration, -the position error, Jacobian, and effective mass are recomputed. Then -the velocity constraints are solved with pseudo velocities and a fraction -of the position error is added to the pseudo velocity error. The pseudo -velocities are initialized to zero and there is no warm-starting. After -the position solver, the pseudo velocities are added to the positions. -This is also called the First Order World method or the Position LCP method. - -Modified Nonlinear Gauss-Seidel (NGS) - Like Pseudo Velocities except the -position error is re-computed for each constraint and the positions are updated -after the constraint is solved. The radius vectors (aka Jacobians) are -re-computed too (otherwise the algorithm has horrible instability). The pseudo -velocity states are not needed because they are effectively zero at the beginning -of each iteration. Since we have the current position error, we allow the -iterations to terminate early if the error becomes smaller than b2_linearSlop. - -Full NGS or just NGS - Like Modified NGS except the effective mass are re-computed -each time a constraint is solved. - -Here are the results: -Baumgarte - this is the cheapest algorithm but it has some stability problems, -especially with the bridge. The chain links separate easily close to the root -and they jitter as they struggle to pull together. This is one of the most common -methods in the field. The big drawback is that the position correction artificially -affects the momentum, thus leading to instabilities and false bounce. I used a -bias factor of 0.2. A larger bias factor makes the bridge less stable, a smaller -factor makes joints and contacts more spongy. - -Pseudo Velocities - the is more stable than the Baumgarte method. The bridge is -stable. However, joints still separate with large angular velocities. Drag the -simple pendulum in a circle quickly and the joint will separate. The chain separates -easily and does not recover. I used a bias factor of 0.2. A larger value lead to -the bridge collapsing when a heavy cube drops on it. - -Modified NGS - this algorithm is better in some ways than Baumgarte and Pseudo -Velocities, but in other ways it is worse. The bridge and chain are much more -stable, but the simple pendulum goes unstable at high angular velocities. - -Full NGS - stable in all tests. The joints display good stiffness. The bridge -still sags, but this is better than infinite forces. - -Recommendations -Pseudo Velocities are not really worthwhile because the bridge and chain cannot -recover from joint separation. In other cases the benefit over Baumgarte is small. - -Modified NGS is not a robust method for the revolute joint due to the violent -instability seen in the simple pendulum. Perhaps it is viable with other constraint -types, especially scalar constraints where the effective mass is a scalar. - -This leaves Baumgarte and Full NGS. Baumgarte has small, but manageable instabilities -and is very fast. I don't think we can escape Baumgarte, especially in highly -demanding cases where high constraint fidelity is not needed. - -Full NGS is robust and easy on the eyes. I recommend this as an option for -higher fidelity simulation and certainly for suspension bridges and long chains. -Full NGS might be a good choice for ragdolls, especially motorized ragdolls where -joint separation can be problematic. The number of NGS iterations can be reduced -for better performance without harming robustness much. - -Each joint in a can be handled differently in the position solver. So I recommend -a system where the user can select the algorithm on a per joint basis. I would -probably default to the slower Full NGS and let the user select the faster -Baumgarte method in performance critical scenarios. -*/ - -/* -Cache Performance - -The Box2D solvers are dominated by cache misses. Data structures are designed -to increase the number of cache hits. Much of misses are due to random access -to body data. The constraint structures are iterated over linearly, which leads -to few cache misses. - -The bodies are not accessed during iteration. Instead read only data, such as -the mass values are stored with the constraints. The mutable data are the constraint -impulses and the bodies velocities/positions. The impulses are held inside the -constraint structures. The body velocities/positions are held in compact, temporary -arrays to increase the number of cache hits. Linear and angular velocity are -stored in a single array since multiple arrays lead to multiple misses. -*/ - -/* -2D Rotation - -R = [cos(theta) -sin(theta)] - [sin(theta) cos(theta) ] - -thetaDot = omega - -Let q1 = cos(theta), q2 = sin(theta). -R = [q1 -q2] - [q2 q1] - -q1Dot = -thetaDot * q2 -q2Dot = thetaDot * q1 - -q1_new = q1_old - dt * w * q2 -q2_new = q2_old + dt * w * q1 -then normalize. - -This might be faster than computing sin+cos. -However, we can compute sin+cos of the same angle fast. -*/ - -b2Island::b2Island( - int32 bodyCapacity, - int32 contactCapacity, - int32 jointCapacity, - b2StackAllocator* allocator, - b2ContactListener* listener) -{ - m_bodyCapacity = bodyCapacity; - m_contactCapacity = contactCapacity; - m_jointCapacity = jointCapacity; - m_bodyCount = 0; - m_contactCount = 0; - m_jointCount = 0; - - m_allocator = allocator; - m_listener = listener; - - m_bodies = (b2Body**)m_allocator->Allocate(bodyCapacity * sizeof(b2Body*)); - m_contacts = (b2Contact**)m_allocator->Allocate(contactCapacity * sizeof(b2Contact*)); - m_joints = (b2Joint**)m_allocator->Allocate(jointCapacity * sizeof(b2Joint*)); - - m_velocities = (b2Velocity*)m_allocator->Allocate(m_bodyCapacity * sizeof(b2Velocity)); - m_positions = (b2Position*)m_allocator->Allocate(m_bodyCapacity * sizeof(b2Position)); -} - -b2Island::~b2Island() -{ - // Warning: the order should reverse the constructor order. - m_allocator->Free(m_positions); - m_allocator->Free(m_velocities); - m_allocator->Free(m_joints); - m_allocator->Free(m_contacts); - m_allocator->Free(m_bodies); -} - -void b2Island::Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep) -{ - b2Timer timer; - - float32 h = step.dt; - - // Integrate velocities and apply damping. Initialize the body state. - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Body* b = m_bodies[i]; - - b2Vec2 c = b->m_sweep.c; - float32 a = b->m_sweep.a; - b2Vec2 v = b->m_linearVelocity; - float32 w = b->m_angularVelocity; - - // Store positions for continuous collision. - b->m_sweep.c0 = b->m_sweep.c; - b->m_sweep.a0 = b->m_sweep.a; - - if (b->m_type == b2_dynamicBody) - { - // Integrate velocities. - v += h * (b->m_gravityScale * gravity + b->m_invMass * b->m_force); - w += h * b->m_invI * b->m_torque; - - // Apply damping. - // ODE: dv/dt + c * v = 0 - // Solution: v(t) = v0 * exp(-c * t) - // Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt) - // v2 = exp(-c * dt) * v1 - // Pade approximation: - // v2 = v1 * 1 / (1 + c * dt) - v *= 1.0f / (1.0f + h * b->m_linearDamping); - w *= 1.0f / (1.0f + h * b->m_angularDamping); - } - - m_positions[i].c = c; - m_positions[i].a = a; - m_velocities[i].v = v; - m_velocities[i].w = w; - } - - timer.Reset(); - - // Solver data - b2SolverData solverData; - solverData.step = step; - solverData.positions = m_positions; - solverData.velocities = m_velocities; - - // Initialize velocity constraints. - b2ContactSolverDef contactSolverDef; - contactSolverDef.step = step; - contactSolverDef.contacts = m_contacts; - contactSolverDef.count = m_contactCount; - contactSolverDef.positions = m_positions; - contactSolverDef.velocities = m_velocities; - contactSolverDef.allocator = m_allocator; - - b2ContactSolver contactSolver(&contactSolverDef); - contactSolver.InitializeVelocityConstraints(); - - if (step.warmStarting) - { - contactSolver.WarmStart(); - } - - for (int32 i = 0; i < m_jointCount; ++i) - { - m_joints[i]->InitVelocityConstraints(solverData); - } - - profile->solveInit = timer.GetMilliseconds(); - - // Solve velocity constraints - timer.Reset(); - for (int32 i = 0; i < step.velocityIterations; ++i) - { - for (int32 j = 0; j < m_jointCount; ++j) - { - m_joints[j]->SolveVelocityConstraints(solverData); - } - - contactSolver.SolveVelocityConstraints(); - } - - // Store impulses for warm starting - contactSolver.StoreImpulses(); - profile->solveVelocity = timer.GetMilliseconds(); - - // Integrate positions - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Vec2 c = m_positions[i].c; - float32 a = m_positions[i].a; - b2Vec2 v = m_velocities[i].v; - float32 w = m_velocities[i].w; - - // Check for large velocities - b2Vec2 translation = h * v; - if (b2Dot(translation, translation) > b2_maxTranslationSquared) - { - float32 ratio = b2_maxTranslation / translation.Length(); - v *= ratio; - } - - float32 rotation = h * w; - if (rotation * rotation > b2_maxRotationSquared) - { - float32 ratio = b2_maxRotation / b2Abs(rotation); - w *= ratio; - } - - // Integrate - c += h * v; - a += h * w; - - m_positions[i].c = c; - m_positions[i].a = a; - m_velocities[i].v = v; - m_velocities[i].w = w; - } - - // Solve position constraints - timer.Reset(); - bool positionSolved = false; - for (int32 i = 0; i < step.positionIterations; ++i) - { - bool contactsOkay = contactSolver.SolvePositionConstraints(); - - bool jointsOkay = true; - for (int32 i = 0; i < m_jointCount; ++i) - { - bool jointOkay = m_joints[i]->SolvePositionConstraints(solverData); - jointsOkay = jointsOkay && jointOkay; - } - - if (contactsOkay && jointsOkay) - { - // Exit early if the position errors are small. - positionSolved = true; - break; - } - } - - // Copy state buffers back to the bodies - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Body* body = m_bodies[i]; - body->m_sweep.c = m_positions[i].c; - body->m_sweep.a = m_positions[i].a; - body->m_linearVelocity = m_velocities[i].v; - body->m_angularVelocity = m_velocities[i].w; - body->SynchronizeTransform(); - } - - profile->solvePosition = timer.GetMilliseconds(); - - Report(contactSolver.m_velocityConstraints); - - if (allowSleep) - { - float32 minSleepTime = b2_maxFloat; - - const float32 linTolSqr = b2_linearSleepTolerance * b2_linearSleepTolerance; - const float32 angTolSqr = b2_angularSleepTolerance * b2_angularSleepTolerance; - - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Body* b = m_bodies[i]; - if (b->GetType() == b2_staticBody) - { - continue; - } - - if ((b->m_flags & b2Body::e_autoSleepFlag) == 0 || - b->m_angularVelocity * b->m_angularVelocity > angTolSqr || - b2Dot(b->m_linearVelocity, b->m_linearVelocity) > linTolSqr) - { - b->m_sleepTime = 0.0f; - minSleepTime = 0.0f; - } - else - { - b->m_sleepTime += h; - minSleepTime = b2Min(minSleepTime, b->m_sleepTime); - } - } - - if (minSleepTime >= b2_timeToSleep && positionSolved) - { - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Body* b = m_bodies[i]; - b->SetAwake(false); - } - } - } -} - -void b2Island::SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB) -{ - b2Assert(toiIndexA < m_bodyCount); - b2Assert(toiIndexB < m_bodyCount); - - // Initialize the body state. - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Body* b = m_bodies[i]; - m_positions[i].c = b->m_sweep.c; - m_positions[i].a = b->m_sweep.a; - m_velocities[i].v = b->m_linearVelocity; - m_velocities[i].w = b->m_angularVelocity; - } - - b2ContactSolverDef contactSolverDef; - contactSolverDef.contacts = m_contacts; - contactSolverDef.count = m_contactCount; - contactSolverDef.allocator = m_allocator; - contactSolverDef.step = subStep; - contactSolverDef.positions = m_positions; - contactSolverDef.velocities = m_velocities; - b2ContactSolver contactSolver(&contactSolverDef); - - // Solve position constraints. - for (int32 i = 0; i < subStep.positionIterations; ++i) - { - bool contactsOkay = contactSolver.SolveTOIPositionConstraints(toiIndexA, toiIndexB); - if (contactsOkay) - { - break; - } - } - -#if 0 - // Is the new position really safe? - for (int32 i = 0; i < m_contactCount; ++i) - { - b2Contact* c = m_contacts[i]; - b2Fixture* fA = c->GetFixtureA(); - b2Fixture* fB = c->GetFixtureB(); - - b2Body* bA = fA->GetBody(); - b2Body* bB = fB->GetBody(); - - int32 indexA = c->GetChildIndexA(); - int32 indexB = c->GetChildIndexB(); - - b2DistanceInput input; - input.proxyA.Set(fA->GetShape(), indexA); - input.proxyB.Set(fB->GetShape(), indexB); - input.transformA = bA->GetTransform(); - input.transformB = bB->GetTransform(); - input.useRadii = false; - - b2DistanceOutput output; - b2SimplexCache cache; - cache.count = 0; - b2Distance(&output, &cache, &input); - - if (output.distance == 0 || cache.count == 3) - { - cache.count += 0; - } - } -#endif - - // Leap of faith to new safe state. - m_bodies[toiIndexA]->m_sweep.c0 = m_positions[toiIndexA].c; - m_bodies[toiIndexA]->m_sweep.a0 = m_positions[toiIndexA].a; - m_bodies[toiIndexB]->m_sweep.c0 = m_positions[toiIndexB].c; - m_bodies[toiIndexB]->m_sweep.a0 = m_positions[toiIndexB].a; - - // No warm starting is needed for TOI events because warm - // starting impulses were applied in the discrete solver. - contactSolver.InitializeVelocityConstraints(); - - // Solve velocity constraints. - for (int32 i = 0; i < subStep.velocityIterations; ++i) - { - contactSolver.SolveVelocityConstraints(); - } - - // Don't store the TOI contact forces for warm starting - // because they can be quite large. - - float32 h = subStep.dt; - - // Integrate positions - for (int32 i = 0; i < m_bodyCount; ++i) - { - b2Vec2 c = m_positions[i].c; - float32 a = m_positions[i].a; - b2Vec2 v = m_velocities[i].v; - float32 w = m_velocities[i].w; - - // Check for large velocities - b2Vec2 translation = h * v; - if (b2Dot(translation, translation) > b2_maxTranslationSquared) - { - float32 ratio = b2_maxTranslation / translation.Length(); - v *= ratio; - } - - float32 rotation = h * w; - if (rotation * rotation > b2_maxRotationSquared) - { - float32 ratio = b2_maxRotation / b2Abs(rotation); - w *= ratio; - } - - // Integrate - c += h * v; - a += h * w; - - m_positions[i].c = c; - m_positions[i].a = a; - m_velocities[i].v = v; - m_velocities[i].w = w; - - // Sync bodies - b2Body* body = m_bodies[i]; - body->m_sweep.c = c; - body->m_sweep.a = a; - body->m_linearVelocity = v; - body->m_angularVelocity = w; - body->SynchronizeTransform(); - } - - Report(contactSolver.m_velocityConstraints); -} - -void b2Island::Report(const b2ContactVelocityConstraint* constraints) -{ - if (m_listener == NULL) - { - return; - } - - for (int32 i = 0; i < m_contactCount; ++i) - { - b2Contact* c = m_contacts[i]; - - const b2ContactVelocityConstraint* vc = constraints + i; - - b2ContactImpulse impulse; - impulse.count = vc->pointCount; - for (int32 j = 0; j < vc->pointCount; ++j) - { - impulse.normalImpulses[j] = vc->points[j].normalImpulse; - impulse.tangentImpulses[j] = vc->points[j].tangentImpulse; - } - - m_listener->PostSolve(c, &impulse); - } -} diff --git a/sources/Box2D/Dynamics/b2Island.h b/sources/Box2D/Dynamics/b2Island.h deleted file mode 100755 index ef3d9b1d..00000000 --- a/sources/Box2D/Dynamics/b2Island.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_ISLAND_H -#define B2_ISLAND_H - -#include -#include -#include - -class b2Contact; -class b2Joint; -class b2StackAllocator; -class b2ContactListener; -struct b2ContactVelocityConstraint; -struct b2Profile; - -/// This is an internal class. -class b2Island -{ -public: - b2Island(int32 bodyCapacity, int32 contactCapacity, int32 jointCapacity, - b2StackAllocator* allocator, b2ContactListener* listener); - ~b2Island(); - - void Clear() - { - m_bodyCount = 0; - m_contactCount = 0; - m_jointCount = 0; - } - - void Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep); - - void SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB); - - void Add(b2Body* body) - { - b2Assert(m_bodyCount < m_bodyCapacity); - body->m_islandIndex = m_bodyCount; - m_bodies[m_bodyCount] = body; - ++m_bodyCount; - } - - void Add(b2Contact* contact) - { - b2Assert(m_contactCount < m_contactCapacity); - m_contacts[m_contactCount++] = contact; - } - - void Add(b2Joint* joint) - { - b2Assert(m_jointCount < m_jointCapacity); - m_joints[m_jointCount++] = joint; - } - - void Report(const b2ContactVelocityConstraint* constraints); - - b2StackAllocator* m_allocator; - b2ContactListener* m_listener; - - b2Body** m_bodies; - b2Contact** m_contacts; - b2Joint** m_joints; - - b2Position* m_positions; - b2Velocity* m_velocities; - - int32 m_bodyCount; - int32 m_jointCount; - int32 m_contactCount; - - int32 m_bodyCapacity; - int32 m_contactCapacity; - int32 m_jointCapacity; -}; - -#endif diff --git a/sources/Box2D/Dynamics/b2TimeStep.h b/sources/Box2D/Dynamics/b2TimeStep.h deleted file mode 100755 index abe6fb6e..00000000 --- a/sources/Box2D/Dynamics/b2TimeStep.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_TIME_STEP_H -#define B2_TIME_STEP_H - -#include - -/// Profiling data. Times are in milliseconds. -struct b2Profile -{ - float32 step; - float32 collide; - float32 solve; - float32 solveInit; - float32 solveVelocity; - float32 solvePosition; - float32 broadphase; - float32 solveTOI; -}; - -/// This is an internal structure. -struct b2TimeStep -{ - float32 dt; // time step - float32 inv_dt; // inverse time step (0 if dt == 0). - float32 dtRatio; // dt * inv_dt0 - int32 velocityIterations; - int32 positionIterations; - bool warmStarting; -}; - -/// This is an internal structure. -struct b2Position -{ - b2Vec2 c; - float32 a; -}; - -/// This is an internal structure. -struct b2Velocity -{ - b2Vec2 v; - float32 w; -}; - -/// Solver Data -struct b2SolverData -{ - b2TimeStep step; - b2Position* positions; - b2Velocity* velocities; -}; - -#endif diff --git a/sources/Box2D/Dynamics/b2World.cpp b/sources/Box2D/Dynamics/b2World.cpp deleted file mode 100755 index 2b75d9d2..00000000 --- a/sources/Box2D/Dynamics/b2World.cpp +++ /dev/null @@ -1,1343 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -b2World::b2World(const b2Vec2& gravity) -{ - m_destructionListener = NULL; - g_debugDraw = NULL; - - m_bodyList = NULL; - m_jointList = NULL; - - m_bodyCount = 0; - m_jointCount = 0; - - m_warmStarting = true; - m_continuousPhysics = true; - m_subStepping = false; - - m_stepComplete = true; - - m_allowSleep = true; - m_gravity = gravity; - - m_flags = e_clearForces; - - m_inv_dt0 = 0.0f; - - m_contactManager.m_allocator = &m_blockAllocator; - - memset(&m_profile, 0, sizeof(b2Profile)); -} - -b2World::~b2World() -{ - // Some shapes allocate using b2Alloc. - b2Body* b = m_bodyList; - while (b) - { - b2Body* bNext = b->m_next; - - b2Fixture* f = b->m_fixtureList; - while (f) - { - b2Fixture* fNext = f->m_next; - f->m_proxyCount = 0; - f->Destroy(&m_blockAllocator); - f = fNext; - } - - b = bNext; - } -} - -void b2World::SetDestructionListener(b2DestructionListener* listener) -{ - m_destructionListener = listener; -} - -void b2World::SetContactFilter(b2ContactFilter* filter) -{ - m_contactManager.m_contactFilter = filter; -} - -void b2World::SetContactListener(b2ContactListener* listener) -{ - m_contactManager.m_contactListener = listener; -} - -void b2World::SetDebugDraw(b2Draw* debugDraw) -{ - g_debugDraw = debugDraw; -} - -b2Body* b2World::CreateBody(const b2BodyDef* def) -{ - b2Assert(IsLocked() == false); - if (IsLocked()) - { - return NULL; - } - - void* mem = m_blockAllocator.Allocate(sizeof(b2Body)); - b2Body* b = new (mem) b2Body(def, this); - - // Add to world doubly linked list. - b->m_prev = NULL; - b->m_next = m_bodyList; - if (m_bodyList) - { - m_bodyList->m_prev = b; - } - m_bodyList = b; - ++m_bodyCount; - - return b; -} - -void b2World::DestroyBody(b2Body* b) -{ - b2Assert(m_bodyCount > 0); - b2Assert(IsLocked() == false); - if (IsLocked()) - { - return; - } - - // Delete the attached joints. - b2JointEdge* je = b->m_jointList; - while (je) - { - b2JointEdge* je0 = je; - je = je->next; - - if (m_destructionListener) - { - m_destructionListener->SayGoodbye(je0->joint); - } - - DestroyJoint(je0->joint); - - b->m_jointList = je; - } - b->m_jointList = NULL; - - // Delete the attached contacts. - b2ContactEdge* ce = b->m_contactList; - while (ce) - { - b2ContactEdge* ce0 = ce; - ce = ce->next; - m_contactManager.Destroy(ce0->contact); - } - b->m_contactList = NULL; - - // Delete the attached fixtures. This destroys broad-phase proxies. - b2Fixture* f = b->m_fixtureList; - while (f) - { - b2Fixture* f0 = f; - f = f->m_next; - - if (m_destructionListener) - { - m_destructionListener->SayGoodbye(f0); - } - - f0->DestroyProxies(&m_contactManager.m_broadPhase); - f0->Destroy(&m_blockAllocator); - f0->~b2Fixture(); - m_blockAllocator.Free(f0, sizeof(b2Fixture)); - - b->m_fixtureList = f; - b->m_fixtureCount -= 1; - } - b->m_fixtureList = NULL; - b->m_fixtureCount = 0; - - // Remove world body list. - if (b->m_prev) - { - b->m_prev->m_next = b->m_next; - } - - if (b->m_next) - { - b->m_next->m_prev = b->m_prev; - } - - if (b == m_bodyList) - { - m_bodyList = b->m_next; - } - - --m_bodyCount; - b2NotifyObjectDestroyed(b, b2ObjectType::BODY, "b2Body"); - b->~b2Body(); - m_blockAllocator.Free(b, sizeof(b2Body)); -} - -b2Joint* b2World::CreateJoint(const b2JointDef* def) -{ - b2Assert(IsLocked() == false); - if (IsLocked()) - { - return NULL; - } - - b2Joint* j = b2Joint::Create(def, &m_blockAllocator); - - // Connect to the world list. - j->m_prev = NULL; - j->m_next = m_jointList; - if (m_jointList) - { - m_jointList->m_prev = j; - } - m_jointList = j; - ++m_jointCount; - - // Connect to the bodies' doubly linked lists. - j->m_edgeA.joint = j; - j->m_edgeA.other = j->m_bodyB; - j->m_edgeA.prev = NULL; - j->m_edgeA.next = j->m_bodyA->m_jointList; - if (j->m_bodyA->m_jointList) j->m_bodyA->m_jointList->prev = &j->m_edgeA; - j->m_bodyA->m_jointList = &j->m_edgeA; - - j->m_edgeB.joint = j; - j->m_edgeB.other = j->m_bodyA; - j->m_edgeB.prev = NULL; - j->m_edgeB.next = j->m_bodyB->m_jointList; - if (j->m_bodyB->m_jointList) j->m_bodyB->m_jointList->prev = &j->m_edgeB; - j->m_bodyB->m_jointList = &j->m_edgeB; - - b2Body* bodyA = def->bodyA; - b2Body* bodyB = def->bodyB; - - // If the joint prevents collisions, then flag any contacts for filtering. - if (def->collideConnected == false) - { - b2ContactEdge* edge = bodyB->GetContactList(); - while (edge) - { - if (edge->other == bodyA) - { - // Flag the contact for filtering at the next time step (where either - // body is awake). - edge->contact->FlagForFiltering(); - } - - edge = edge->next; - } - } - - // Note: creating a joint doesn't wake the bodies. - - return j; -} - -void b2World::DestroyJoint(b2Joint* j) -{ - b2Assert(IsLocked() == false); - if (IsLocked()) - { - return; - } - - bool collideConnected = j->m_collideConnected; - - // Remove from the doubly linked list. - if (j->m_prev) - { - j->m_prev->m_next = j->m_next; - } - - if (j->m_next) - { - j->m_next->m_prev = j->m_prev; - } - - if (j == m_jointList) - { - m_jointList = j->m_next; - } - - // Disconnect from island graph. - b2Body* bodyA = j->m_bodyA; - b2Body* bodyB = j->m_bodyB; - - // Wake up connected bodies. - bodyA->SetAwake(true); - bodyB->SetAwake(true); - - // Remove from body 1. - if (j->m_edgeA.prev) - { - j->m_edgeA.prev->next = j->m_edgeA.next; - } - - if (j->m_edgeA.next) - { - j->m_edgeA.next->prev = j->m_edgeA.prev; - } - - if (&j->m_edgeA == bodyA->m_jointList) - { - bodyA->m_jointList = j->m_edgeA.next; - } - - j->m_edgeA.prev = NULL; - j->m_edgeA.next = NULL; - - // Remove from body 2 - if (j->m_edgeB.prev) - { - j->m_edgeB.prev->next = j->m_edgeB.next; - } - - if (j->m_edgeB.next) - { - j->m_edgeB.next->prev = j->m_edgeB.prev; - } - - if (&j->m_edgeB == bodyB->m_jointList) - { - bodyB->m_jointList = j->m_edgeB.next; - } - - j->m_edgeB.prev = NULL; - j->m_edgeB.next = NULL; - - b2Joint::Destroy(j, &m_blockAllocator); - - b2Assert(m_jointCount > 0); - --m_jointCount; - - // If the joint prevents collisions, then flag any contacts for filtering. - if (collideConnected == false) - { - b2ContactEdge* edge = bodyB->GetContactList(); - while (edge) - { - if (edge->other == bodyA) - { - // Flag the contact for filtering at the next time step (where either - // body is awake). - edge->contact->FlagForFiltering(); - } - - edge = edge->next; - } - } -} - -// -void b2World::SetAllowSleeping(bool flag) -{ - if (flag == m_allowSleep) - { - return; - } - - m_allowSleep = flag; - if (m_allowSleep == false) - { - for (b2Body* b = m_bodyList; b; b = b->m_next) - { - b->SetAwake(true); - } - } -} - -// Find islands, integrate and solve constraints, solve position constraints -void b2World::Solve(const b2TimeStep& step) -{ - m_profile.solveInit = 0.0f; - m_profile.solveVelocity = 0.0f; - m_profile.solvePosition = 0.0f; - - // Size the island for the worst case. - b2Island island(m_bodyCount, - m_contactManager.m_contactCount, - m_jointCount, - &m_stackAllocator, - m_contactManager.m_contactListener); - - // Clear all the island flags. - for (b2Body* b = m_bodyList; b; b = b->m_next) - { - b->m_flags &= ~b2Body::e_islandFlag; - } - for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next) - { - c->m_flags &= ~b2Contact::e_islandFlag; - } - for (b2Joint* j = m_jointList; j; j = j->m_next) - { - j->m_islandFlag = false; - } - - // Build and simulate all awake islands. - int32 stackSize = m_bodyCount; - b2Body** stack = (b2Body**)m_stackAllocator.Allocate(stackSize * sizeof(b2Body*)); - for (b2Body* seed = m_bodyList; seed; seed = seed->m_next) - { - if (seed->m_flags & b2Body::e_islandFlag) - { - continue; - } - - if (seed->IsAwake() == false || seed->IsActive() == false) - { - continue; - } - - // The seed can be dynamic or kinematic. - if (seed->GetType() == b2_staticBody) - { - continue; - } - - // Reset island and stack. - island.Clear(); - int32 stackCount = 0; - stack[stackCount++] = seed; - seed->m_flags |= b2Body::e_islandFlag; - - // Perform a depth first search (DFS) on the constraint graph. - while (stackCount > 0) - { - // Grab the next body off the stack and add it to the island. - b2Body* b = stack[--stackCount]; - b2Assert(b->IsActive() == true); - island.Add(b); - - // Make sure the body is awake. - b->SetAwake(true); - - // To keep islands as small as possible, we don't - // propagate islands across static bodies. - if (b->GetType() == b2_staticBody) - { - continue; - } - - // Search all contacts connected to this body. - for (b2ContactEdge* ce = b->m_contactList; ce; ce = ce->next) - { - b2Contact* contact = ce->contact; - - // Has this contact already been added to an island? - if (contact->m_flags & b2Contact::e_islandFlag) - { - continue; - } - - // Is this contact solid and touching? - if (contact->IsEnabled() == false || - contact->IsTouching() == false) - { - continue; - } - - // Skip sensors. - bool sensorA = contact->m_fixtureA->m_isSensor; - bool sensorB = contact->m_fixtureB->m_isSensor; - if (sensorA || sensorB) - { - continue; - } - - island.Add(contact); - contact->m_flags |= b2Contact::e_islandFlag; - - b2Body* other = ce->other; - - // Was the other body already added to this island? - if (other->m_flags & b2Body::e_islandFlag) - { - continue; - } - - b2Assert(stackCount < stackSize); - stack[stackCount++] = other; - other->m_flags |= b2Body::e_islandFlag; - } - - // Search all joints connect to this body. - for (b2JointEdge* je = b->m_jointList; je; je = je->next) - { - if (je->joint->m_islandFlag == true) - { - continue; - } - - b2Body* other = je->other; - - // Don't simulate joints connected to inactive bodies. - if (other->IsActive() == false) - { - continue; - } - - island.Add(je->joint); - je->joint->m_islandFlag = true; - - if (other->m_flags & b2Body::e_islandFlag) - { - continue; - } - - b2Assert(stackCount < stackSize); - stack[stackCount++] = other; - other->m_flags |= b2Body::e_islandFlag; - } - } - - b2Profile profile; - island.Solve(&profile, step, m_gravity, m_allowSleep); - m_profile.solveInit += profile.solveInit; - m_profile.solveVelocity += profile.solveVelocity; - m_profile.solvePosition += profile.solvePosition; - - // Post solve cleanup. - for (int32 i = 0; i < island.m_bodyCount; ++i) - { - // Allow static bodies to participate in other islands. - b2Body* b = island.m_bodies[i]; - if (b->GetType() == b2_staticBody) - { - b->m_flags &= ~b2Body::e_islandFlag; - } - } - } - - m_stackAllocator.Free(stack); - - { - b2Timer timer; - // Synchronize fixtures, check for out of range bodies. - for (b2Body* b = m_bodyList; b; b = b->GetNext()) - { - // If a body was not in an island then it did not move. - if ((b->m_flags & b2Body::e_islandFlag) == 0) - { - continue; - } - - if (b->GetType() == b2_staticBody) - { - continue; - } - - // Update fixtures (for broad-phase). - b->SynchronizeFixtures(); - } - - // Look for new contacts. - m_contactManager.FindNewContacts(); - m_profile.broadphase = timer.GetMilliseconds(); - } -} - -// Find TOI contacts and solve them. -void b2World::SolveTOI(const b2TimeStep& step) -{ - b2Island island(2 * b2_maxTOIContacts, b2_maxTOIContacts, 0, &m_stackAllocator, m_contactManager.m_contactListener); - - if (m_stepComplete) - { - for (b2Body* b = m_bodyList; b; b = b->m_next) - { - b->m_flags &= ~b2Body::e_islandFlag; - b->m_sweep.alpha0 = 0.0f; - } - - for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next) - { - // Invalidate TOI - c->m_flags &= ~(b2Contact::e_toiFlag | b2Contact::e_islandFlag); - c->m_toiCount = 0; - c->m_toi = 1.0f; - } - } - - // Find TOI events and solve them. - for (;;) - { - // Find the first TOI. - b2Contact* minContact = NULL; - float32 minAlpha = 1.0f; - - for (b2Contact* c = m_contactManager.m_contactList; c; c = c->m_next) - { - // Is this contact disabled? - if (c->IsEnabled() == false) - { - continue; - } - - // Prevent excessive sub-stepping. - if (c->m_toiCount > b2_maxSubSteps) - { - continue; - } - - float32 alpha = 1.0f; - if (c->m_flags & b2Contact::e_toiFlag) - { - // This contact has a valid cached TOI. - alpha = c->m_toi; - } - else - { - b2Fixture* fA = c->GetFixtureA(); - b2Fixture* fB = c->GetFixtureB(); - - // Is there a sensor? - if (fA->IsSensor() || fB->IsSensor()) - { - continue; - } - - b2Body* bA = fA->GetBody(); - b2Body* bB = fB->GetBody(); - - b2BodyType typeA = bA->m_type; - b2BodyType typeB = bB->m_type; - b2Assert(typeA == b2_dynamicBody || typeB == b2_dynamicBody); - - bool activeA = bA->IsAwake() && typeA != b2_staticBody; - bool activeB = bB->IsAwake() && typeB != b2_staticBody; - - // Is at least one body active (awake and dynamic or kinematic)? - if (activeA == false && activeB == false) - { - continue; - } - - bool collideA = bA->IsBullet() || typeA != b2_dynamicBody; - bool collideB = bB->IsBullet() || typeB != b2_dynamicBody; - - // Are these two non-bullet dynamic bodies? - if (collideA == false && collideB == false) - { - continue; - } - - // Compute the TOI for this contact. - // Put the sweeps onto the same time interval. - float32 alpha0 = bA->m_sweep.alpha0; - - if (bA->m_sweep.alpha0 < bB->m_sweep.alpha0) - { - alpha0 = bB->m_sweep.alpha0; - bA->m_sweep.Advance(alpha0); - } - else if (bB->m_sweep.alpha0 < bA->m_sweep.alpha0) - { - alpha0 = bA->m_sweep.alpha0; - bB->m_sweep.Advance(alpha0); - } - - b2Assert(alpha0 < 1.0f); - - int32 indexA = c->GetChildIndexA(); - int32 indexB = c->GetChildIndexB(); - - // Compute the time of impact in interval [0, minTOI] - b2TOIInput input; - input.proxyA.Set(fA->GetShape(), indexA); - input.proxyB.Set(fB->GetShape(), indexB); - input.sweepA = bA->m_sweep; - input.sweepB = bB->m_sweep; - input.tMax = 1.0f; - - b2TOIOutput output; - b2TimeOfImpact(&output, &input); - - // Beta is the fraction of the remaining portion of the . - float32 beta = output.t; - if (output.state == b2TOIOutput::e_touching) - { - alpha = b2Min(alpha0 + (1.0f - alpha0) * beta, 1.0f); - } - else - { - alpha = 1.0f; - } - - c->m_toi = alpha; - c->m_flags |= b2Contact::e_toiFlag; - } - - if (alpha < minAlpha) - { - // This is the minimum TOI found so far. - minContact = c; - minAlpha = alpha; - } - } - - if (minContact == NULL || 1.0f - 10.0f * b2_epsilon < minAlpha) - { - // No more TOI events. Done! - m_stepComplete = true; - break; - } - - // Advance the bodies to the TOI. - b2Fixture* fA = minContact->GetFixtureA(); - b2Fixture* fB = minContact->GetFixtureB(); - b2Body* bA = fA->GetBody(); - b2Body* bB = fB->GetBody(); - - b2Sweep backup1 = bA->m_sweep; - b2Sweep backup2 = bB->m_sweep; - - bA->Advance(minAlpha); - bB->Advance(minAlpha); - - // The TOI contact likely has some new contact points. - minContact->Update(m_contactManager.m_contactListener); - minContact->m_flags &= ~b2Contact::e_toiFlag; - ++minContact->m_toiCount; - - // Is the contact solid? - if (minContact->IsEnabled() == false || minContact->IsTouching() == false) - { - // Restore the sweeps. - minContact->SetEnabled(false); - bA->m_sweep = backup1; - bB->m_sweep = backup2; - bA->SynchronizeTransform(); - bB->SynchronizeTransform(); - continue; - } - - bA->SetAwake(true); - bB->SetAwake(true); - - // Build the island - island.Clear(); - island.Add(bA); - island.Add(bB); - island.Add(minContact); - - bA->m_flags |= b2Body::e_islandFlag; - bB->m_flags |= b2Body::e_islandFlag; - minContact->m_flags |= b2Contact::e_islandFlag; - - // Get contacts on bodyA and bodyB. - b2Body* bodies[2] = {bA, bB}; - for (int32 i = 0; i < 2; ++i) - { - b2Body* body = bodies[i]; - if (body->m_type == b2_dynamicBody) - { - for (b2ContactEdge* ce = body->m_contactList; ce; ce = ce->next) - { - if (island.m_bodyCount == island.m_bodyCapacity) - { - break; - } - - if (island.m_contactCount == island.m_contactCapacity) - { - break; - } - - b2Contact* contact = ce->contact; - - // Has this contact already been added to the island? - if (contact->m_flags & b2Contact::e_islandFlag) - { - continue; - } - - // Only add static, kinematic, or bullet bodies. - b2Body* other = ce->other; - if (other->m_type == b2_dynamicBody && - body->IsBullet() == false && other->IsBullet() == false) - { - continue; - } - - // Skip sensors. - bool sensorA = contact->m_fixtureA->m_isSensor; - bool sensorB = contact->m_fixtureB->m_isSensor; - if (sensorA || sensorB) - { - continue; - } - - // Tentatively advance the body to the TOI. - b2Sweep backup = other->m_sweep; - if ((other->m_flags & b2Body::e_islandFlag) == 0) - { - other->Advance(minAlpha); - } - - // Update the contact points - contact->Update(m_contactManager.m_contactListener); - - // Was the contact disabled by the user? - if (contact->IsEnabled() == false) - { - other->m_sweep = backup; - other->SynchronizeTransform(); - continue; - } - - // Are there contact points? - if (contact->IsTouching() == false) - { - other->m_sweep = backup; - other->SynchronizeTransform(); - continue; - } - - // Add the contact to the island - contact->m_flags |= b2Contact::e_islandFlag; - island.Add(contact); - - // Has the other body already been added to the island? - if (other->m_flags & b2Body::e_islandFlag) - { - continue; - } - - // Add the other body to the island. - other->m_flags |= b2Body::e_islandFlag; - - if (other->m_type != b2_staticBody) - { - other->SetAwake(true); - } - - island.Add(other); - } - } - } - - b2TimeStep subStep; - subStep.dt = (1.0f - minAlpha) * step.dt; - subStep.inv_dt = 1.0f / subStep.dt; - subStep.dtRatio = 1.0f; - subStep.positionIterations = 20; - subStep.velocityIterations = step.velocityIterations; - subStep.warmStarting = false; - island.SolveTOI(subStep, bA->m_islandIndex, bB->m_islandIndex); - - // Reset island flags and synchronize broad-phase proxies. - for (int32 i = 0; i < island.m_bodyCount; ++i) - { - b2Body* body = island.m_bodies[i]; - body->m_flags &= ~b2Body::e_islandFlag; - - if (body->m_type != b2_dynamicBody) - { - continue; - } - - body->SynchronizeFixtures(); - - // Invalidate all contact TOIs on this displaced body. - for (b2ContactEdge* ce = body->m_contactList; ce; ce = ce->next) - { - ce->contact->m_flags &= ~(b2Contact::e_toiFlag | b2Contact::e_islandFlag); - } - } - - // Commit fixture proxy movements to the broad-phase so that new contacts are created. - // Also, some contacts can be destroyed. - m_contactManager.FindNewContacts(); - - if (m_subStepping) - { - m_stepComplete = false; - break; - } - } -} - -void b2World::Step(float32 dt, int32 velocityIterations, int32 positionIterations) -{ - b2Timer stepTimer; - - // If new fixtures were added, we need to find the new contacts. - if (m_flags & e_newFixture) - { - m_contactManager.FindNewContacts(); - m_flags &= ~e_newFixture; - } - - m_flags |= e_locked; - - b2TimeStep step; - step.dt = dt; - step.velocityIterations = velocityIterations; - step.positionIterations = positionIterations; - if (dt > 0.0f) - { - step.inv_dt = 1.0f / dt; - } - else - { - step.inv_dt = 0.0f; - } - - step.dtRatio = m_inv_dt0 * dt; - - step.warmStarting = m_warmStarting; - - // Update contacts. This is where some contacts are destroyed. - { - b2Timer timer; - m_contactManager.Collide(); - m_profile.collide = timer.GetMilliseconds(); - } - - // Integrate velocities, solve velocity constraints, and integrate positions. - if (m_stepComplete && step.dt > 0.0f) - { - b2Timer timer; - Solve(step); - m_profile.solve = timer.GetMilliseconds(); - } - - // Handle TOI events. - if (m_continuousPhysics && step.dt > 0.0f) - { - b2Timer timer; - SolveTOI(step); - m_profile.solveTOI = timer.GetMilliseconds(); - } - - if (step.dt > 0.0f) - { - m_inv_dt0 = step.inv_dt; - } - - if (m_flags & e_clearForces) - { - ClearForces(); - } - - m_flags &= ~e_locked; - - m_profile.step = stepTimer.GetMilliseconds(); -} - -void b2World::ClearForces() -{ - for (b2Body* body = m_bodyList; body; body = body->GetNext()) - { - body->m_force.SetZero(); - body->m_torque = 0.0f; - } -} - -struct b2WorldQueryWrapper -{ - bool QueryCallback(int32 proxyId) - { - b2FixtureProxy* proxy = (b2FixtureProxy*)broadPhase->GetUserData(proxyId); - return callback->ReportFixture(proxy->fixture); - } - - const b2BroadPhase* broadPhase; - b2QueryCallback* callback; -}; - -void b2World::QueryAABB(b2QueryCallback* callback, const b2AABB& aabb) const -{ - b2WorldQueryWrapper wrapper; - wrapper.broadPhase = &m_contactManager.m_broadPhase; - wrapper.callback = callback; - m_contactManager.m_broadPhase.Query(&wrapper, aabb); -} - -struct b2WorldRayCastWrapper -{ - float32 RayCastCallback(const b2RayCastInput& input, int32 proxyId) - { - void* userData = broadPhase->GetUserData(proxyId); - b2FixtureProxy* proxy = (b2FixtureProxy*)userData; - b2Fixture* fixture = proxy->fixture; - int32 index = proxy->childIndex; - b2RayCastOutput output; - bool hit = fixture->RayCast(&output, input, index); - - if (hit) - { - float32 fraction = output.fraction; - b2Vec2 point = (1.0f - fraction) * input.p1 + fraction * input.p2; - return callback->ReportFixture(fixture, point, output.normal, fraction); - } - - return input.maxFraction; - } - - const b2BroadPhase* broadPhase; - b2RayCastCallback* callback; -}; - -void b2World::RayCast(b2RayCastCallback* callback, const b2Vec2& point1, const b2Vec2& point2) const -{ - b2WorldRayCastWrapper wrapper; - wrapper.broadPhase = &m_contactManager.m_broadPhase; - wrapper.callback = callback; - b2RayCastInput input; - input.maxFraction = 1.0f; - input.p1 = point1; - input.p2 = point2; - m_contactManager.m_broadPhase.RayCast(&wrapper, input); -} - -void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color& color) -{ - switch (fixture->GetType()) - { - case b2Shape::e_circle: - { - b2CircleShape* circle = (b2CircleShape*)fixture->GetShape(); - - b2Vec2 center = b2Mul(xf, circle->m_p); - float32 radius = circle->m_radius; - b2Vec2 axis = b2Mul(xf.q, b2Vec2(1.0f, 0.0f)); - - g_debugDraw->DrawSolidCircle(center, radius, axis, color); - } - break; - - case b2Shape::e_edge: - { - b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape(); - b2Vec2 v1 = b2Mul(xf, edge->m_vertex1); - b2Vec2 v2 = b2Mul(xf, edge->m_vertex2); - g_debugDraw->DrawSegment(v1, v2, color); - } - break; - - case b2Shape::e_chain: - { - b2ChainShape* chain = (b2ChainShape*)fixture->GetShape(); - int32 count = chain->m_count; - const b2Vec2* vertices = chain->m_vertices; - - b2Vec2 v1 = b2Mul(xf, vertices[0]); - for (int32 i = 1; i < count; ++i) - { - b2Vec2 v2 = b2Mul(xf, vertices[i]); - g_debugDraw->DrawSegment(v1, v2, color); - g_debugDraw->DrawCircle(v1, 0.05f, color); - v1 = v2; - } - } - break; - - case b2Shape::e_polygon: - { - b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape(); - int32 vertexCount = poly->m_count; - b2Assert(vertexCount <= b2_maxPolygonVertices); - b2Vec2 vertices[b2_maxPolygonVertices]; - - for (int32 i = 0; i < vertexCount; ++i) - { - vertices[i] = b2Mul(xf, poly->m_vertices[i]); - } - - g_debugDraw->DrawSolidPolygon(vertices, vertexCount, color); - } - break; - - default: - break; - } -} - -void b2World::DrawJoint(b2Joint* joint) -{ - b2Body* bodyA = joint->GetBodyA(); - b2Body* bodyB = joint->GetBodyB(); - const b2Transform& xf1 = bodyA->GetTransform(); - const b2Transform& xf2 = bodyB->GetTransform(); - b2Vec2 x1 = xf1.p; - b2Vec2 x2 = xf2.p; - b2Vec2 p1 = joint->GetAnchorA(); - b2Vec2 p2 = joint->GetAnchorB(); - - b2Color color(0.5f, 0.8f, 0.8f); - - switch (joint->GetType()) - { - case e_distanceJoint: - g_debugDraw->DrawSegment(p1, p2, color); - break; - - case e_pulleyJoint: - { - b2PulleyJoint* pulley = (b2PulleyJoint*)joint; - b2Vec2 s1 = pulley->GetGroundAnchorA(); - b2Vec2 s2 = pulley->GetGroundAnchorB(); - g_debugDraw->DrawSegment(s1, p1, color); - g_debugDraw->DrawSegment(s2, p2, color); - g_debugDraw->DrawSegment(s1, s2, color); - } - break; - - case e_mouseJoint: - // don't draw this - break; - - default: - g_debugDraw->DrawSegment(x1, p1, color); - g_debugDraw->DrawSegment(p1, p2, color); - g_debugDraw->DrawSegment(x2, p2, color); - } -} - -void b2World::DrawDebugData() -{ - if (g_debugDraw == NULL) - { - return; - } - - g_debugDraw->ClearDraw(); - - uint32 flags = g_debugDraw->GetFlags(); - - if (flags & b2Draw::e_shapeBit) - { - for (b2Body* b = m_bodyList; b; b = b->GetNext()) - { - const b2Transform& xf = b->GetTransform(); - for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) - { - if (b->IsActive() == false) - { - DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.3f)); - } - else if (b->GetType() == b2_staticBody) - { - DrawShape(f, xf, b2Color(0.5f, 0.9f, 0.5f)); - } - else if (b->GetType() == b2_kinematicBody) - { - DrawShape(f, xf, b2Color(0.5f, 0.5f, 0.9f)); - } - else if (b->IsAwake() == false) - { - DrawShape(f, xf, b2Color(0.6f, 0.6f, 0.6f)); - } - else - { - DrawShape(f, xf, b2Color(0.9f, 0.7f, 0.7f)); - } - } - } - } - - if (flags & b2Draw::e_jointBit) - { - for (b2Joint* j = m_jointList; j; j = j->GetNext()) - { - DrawJoint(j); - } - } - - if (flags & b2Draw::e_pairBit) - { - b2Color color(0.3f, 0.9f, 0.9f); - for (b2Contact* c = m_contactManager.m_contactList; c; c = c->GetNext()) - { - //b2Fixture* fixtureA = c->GetFixtureA(); - //b2Fixture* fixtureB = c->GetFixtureB(); - - //b2Vec2 cA = fixtureA->GetAABB().GetCenter(); - //b2Vec2 cB = fixtureB->GetAABB().GetCenter(); - - //g_debugDraw->DrawSegment(cA, cB, color); - } - } - - if (flags & b2Draw::e_aabbBit) - { - b2Color color(0.9f, 0.3f, 0.9f); - b2BroadPhase* bp = &m_contactManager.m_broadPhase; - - for (b2Body* b = m_bodyList; b; b = b->GetNext()) - { - if (b->IsActive() == false) - { - continue; - } - - for (b2Fixture* f = b->GetFixtureList(); f; f = f->GetNext()) - { - for (int32 i = 0; i < f->m_proxyCount; ++i) - { - b2FixtureProxy* proxy = f->m_proxies + i; - b2AABB aabb = bp->GetFatAABB(proxy->proxyId); - b2Vec2 vs[4]; - vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y); - vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y); - vs[2].Set(aabb.upperBound.x, aabb.upperBound.y); - vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y); - - g_debugDraw->DrawPolygon(vs, 4, color); - } - } - } - } - - if (flags & b2Draw::e_centerOfMassBit) - { - for (b2Body* b = m_bodyList; b; b = b->GetNext()) - { - b2Transform xf = b->GetTransform(); - xf.p = b->GetWorldCenter(); - g_debugDraw->DrawTransform(xf); - } - } -} - -int32 b2World::GetProxyCount() const -{ - return m_contactManager.m_broadPhase.GetProxyCount(); -} - -int32 b2World::GetTreeHeight() const -{ - return m_contactManager.m_broadPhase.GetTreeHeight(); -} - -int32 b2World::GetTreeBalance() const -{ - return m_contactManager.m_broadPhase.GetTreeBalance(); -} - -float32 b2World::GetTreeQuality() const -{ - return m_contactManager.m_broadPhase.GetTreeQuality(); -} - -void b2World::ShiftOrigin(const b2Vec2& newOrigin) -{ - b2Assert((m_flags & e_locked) == 0); - if ((m_flags & e_locked) == e_locked) - { - return; - } - - for (b2Body* b = m_bodyList; b; b = b->m_next) - { - b->m_xf.p -= newOrigin; - b->m_sweep.c0 -= newOrigin; - b->m_sweep.c -= newOrigin; - } - - for (b2Joint* j = m_jointList; j; j = j->m_next) - { - j->ShiftOrigin(newOrigin); - } - - m_contactManager.m_broadPhase.ShiftOrigin(newOrigin); -} - -void b2World::Dump() -{ - if ((m_flags & e_locked) == e_locked) - { - return; - } - - b2Log("b2Vec2 g(%.15lef, %.15lef);\n", m_gravity.x, m_gravity.y); - b2Log("m_world->SetGravity(g);\n"); - - b2Log("b2Body** bodies = (b2Body**)b2Alloc(%d * sizeof(b2Body*));\n", m_bodyCount); - b2Log("b2Joint** joints = (b2Joint**)b2Alloc(%d * sizeof(b2Joint*));\n", m_jointCount); - int32 i = 0; - for (b2Body* b = m_bodyList; b; b = b->m_next) - { - b->m_islandIndex = i; - b->Dump(); - ++i; - } - - i = 0; - for (b2Joint* j = m_jointList; j; j = j->m_next) - { - j->m_index = i; - ++i; - } - - // First pass on joints, skip gear joints. - for (b2Joint* j = m_jointList; j; j = j->m_next) - { - if (j->m_type == e_gearJoint) - { - continue; - } - - b2Log("{\n"); - j->Dump(); - b2Log("}\n"); - } - - // Second pass on joints, only gear joints. - for (b2Joint* j = m_jointList; j; j = j->m_next) - { - if (j->m_type != e_gearJoint) - { - continue; - } - - b2Log("{\n"); - j->Dump(); - b2Log("}\n"); - } - - b2Log("b2Free(joints);\n"); - b2Log("b2Free(bodies);\n"); - b2Log("joints = NULL;\n"); - b2Log("bodies = NULL;\n"); -} diff --git a/sources/Box2D/Dynamics/b2World.h b/sources/Box2D/Dynamics/b2World.h deleted file mode 100755 index 3968cc78..00000000 --- a/sources/Box2D/Dynamics/b2World.h +++ /dev/null @@ -1,354 +0,0 @@ -/* -* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_WORLD_H -#define B2_WORLD_H - -#include -#include -#include -#include -#include -#include - -struct b2AABB; -struct b2BodyDef; -struct b2Color; -struct b2JointDef; -class b2Body; -class b2Draw; -class b2Fixture; -class b2Joint; - -/// The world class manages all physics entities, dynamic simulation, -/// and asynchronous queries. The world also contains efficient memory -/// management facilities. -class b2World -{ -public: - /// Construct a world object. - /// @param gravity the world gravity vector. - b2World(const b2Vec2& gravity); - - /// Destruct the world. All physics entities are destroyed and all heap memory is released. - ~b2World(); - - /// Register a destruction listener. The listener is owned by you and must - /// remain in scope. - void SetDestructionListener(b2DestructionListener* listener); - - /// Register a contact filter to provide specific control over collision. - /// Otherwise the default filter is used (b2_defaultFilter). The listener is - /// owned by you and must remain in scope. - void SetContactFilter(b2ContactFilter* filter); - - /// Register a contact event listener. The listener is owned by you and must - /// remain in scope. - void SetContactListener(b2ContactListener* listener); - - /// Register a routine for debug drawing. The debug draw functions are called - /// inside with b2World::DrawDebugData method. The debug draw object is owned - /// by you and must remain in scope. - void SetDebugDraw(b2Draw* debugDraw); - - /// Create a rigid body given a definition. No reference to the definition - /// is retained. - /// @warning This function is locked during callbacks. - b2Body* CreateBody(const b2BodyDef* def); - - /// Destroy a rigid body given a definition. No reference to the definition - /// is retained. This function is locked during callbacks. - /// @warning This automatically deletes all associated shapes and joints. - /// @warning This function is locked during callbacks. - void DestroyBody(b2Body* body); - - /// Create a joint to constrain bodies together. No reference to the definition - /// is retained. This may cause the connected bodies to cease colliding. - /// @warning This function is locked during callbacks. - b2Joint* CreateJoint(const b2JointDef* def); - - /// Destroy a joint. This may cause the connected bodies to begin colliding. - /// @warning This function is locked during callbacks. - void DestroyJoint(b2Joint* joint); - - /// Take a time step. This performs collision detection, integration, - /// and constraint solution. - /// @param timeStep the amount of time to simulate, this should not vary. - /// @param velocityIterations for the velocity constraint solver. - /// @param positionIterations for the position constraint solver. - void Step( float32 timeStep, - int32 velocityIterations, - int32 positionIterations); - - /// Manually clear the force buffer on all bodies. By default, forces are cleared automatically - /// after each call to Step. The default behavior is modified by calling SetAutoClearForces. - /// The purpose of this function is to support sub-stepping. Sub-stepping is often used to maintain - /// a fixed sized time step under a variable frame-rate. - /// When you perform sub-stepping you will disable auto clearing of forces and instead call - /// ClearForces after all sub-steps are complete in one pass of your game loop. - /// @see SetAutoClearForces - void ClearForces(); - - /// Call this to draw shapes and other debug draw data. This is intentionally non-const. - void DrawDebugData(); - - /// Query the world for all fixtures that potentially overlap the - /// provided AABB. - /// @param callback a user implemented callback class. - /// @param aabb the query box. - void QueryAABB(b2QueryCallback* callback, const b2AABB& aabb) const; - - /// Ray-cast the world for all fixtures in the path of the ray. Your callback - /// controls whether you get the closest point, any point, or n-points. - /// The ray-cast ignores shapes that contain the starting point. - /// @param callback a user implemented callback class. - /// @param point1 the ray starting point - /// @param point2 the ray ending point - void RayCast(b2RayCastCallback* callback, const b2Vec2& point1, const b2Vec2& point2) const; - - /// Get the world body list. With the returned body, use b2Body::GetNext to get - /// the next body in the world list. A NULL body indicates the end of the list. - /// @return the head of the world body list. - b2Body* GetBodyList(); - const b2Body* GetBodyList() const; - - /// Get the world joint list. With the returned joint, use b2Joint::GetNext to get - /// the next joint in the world list. A NULL joint indicates the end of the list. - /// @return the head of the world joint list. - b2Joint* GetJointList(); - const b2Joint* GetJointList() const; - - /// Get the world contact list. With the returned contact, use b2Contact::GetNext to get - /// the next contact in the world list. A NULL contact indicates the end of the list. - /// @return the head of the world contact list. - /// @warning contacts are created and destroyed in the middle of a time step. - /// Use b2ContactListener to avoid missing contacts. - b2Contact* GetContactList(); - const b2Contact* GetContactList() const; - - /// Enable/disable sleep. - void SetAllowSleeping(bool flag); - bool GetAllowSleeping() const { return m_allowSleep; } - - /// Enable/disable warm starting. For testing. - void SetWarmStarting(bool flag) { m_warmStarting = flag; } - bool GetWarmStarting() const { return m_warmStarting; } - - /// Enable/disable continuous physics. For testing. - void SetContinuousPhysics(bool flag) { m_continuousPhysics = flag; } - bool GetContinuousPhysics() const { return m_continuousPhysics; } - - /// Enable/disable single stepped continuous physics. For testing. - void SetSubStepping(bool flag) { m_subStepping = flag; } - bool GetSubStepping() const { return m_subStepping; } - - /// Get the number of broad-phase proxies. - int32 GetProxyCount() const; - - /// Get the number of bodies. - int32 GetBodyCount() const; - - /// Get the number of joints. - int32 GetJointCount() const; - - /// Get the number of contacts (each may have 0 or more contact points). - int32 GetContactCount() const; - - /// Get the height of the dynamic tree. - int32 GetTreeHeight() const; - - /// Get the balance of the dynamic tree. - int32 GetTreeBalance() const; - - /// Get the quality metric of the dynamic tree. The smaller the better. - /// The minimum is 1. - float32 GetTreeQuality() const; - - /// Change the global gravity vector. - void SetGravity(const b2Vec2& gravity); - - /// Get the global gravity vector. - b2Vec2 GetGravity() const; - - /// Is the world locked (in the middle of a time step). - bool IsLocked() const; - - /// Set flag to control automatic clearing of forces after each time step. - void SetAutoClearForces(bool flag); - - /// Get the flag that controls automatic clearing of forces after each time step. - bool GetAutoClearForces() const; - - /// Shift the world origin. Useful for large worlds. - /// The body shift formula is: position -= newOrigin - /// @param newOrigin the new origin with respect to the old origin - void ShiftOrigin(const b2Vec2& newOrigin); - - /// Get the contact manager for testing. - const b2ContactManager& GetContactManager() const; - - /// Get the current profile. - const b2Profile& GetProfile() const; - - /// Dump the world into the log file. - /// @warning this should be called outside of a time step. - void Dump(); - -private: - - // m_flags - enum - { - e_newFixture = 0x0001, - e_locked = 0x0002, - e_clearForces = 0x0004 - }; - - friend class b2Body; - friend class b2Fixture; - friend class b2ContactManager; - friend class b2Controller; - - void Solve(const b2TimeStep& step); - void SolveTOI(const b2TimeStep& step); - - void DrawJoint(b2Joint* joint); - void DrawShape(b2Fixture* shape, const b2Transform& xf, const b2Color& color); - - b2BlockAllocator m_blockAllocator; - b2StackAllocator m_stackAllocator; - - int32 m_flags; - - b2ContactManager m_contactManager; - - b2Body* m_bodyList; - b2Joint* m_jointList; - - int32 m_bodyCount; - int32 m_jointCount; - - b2Vec2 m_gravity; - bool m_allowSleep; - - b2DestructionListener* m_destructionListener; - b2Draw* g_debugDraw; - - // This is used to compute the time step ratio to - // support a variable time step. - float32 m_inv_dt0; - - // These are for debugging the solver. - bool m_warmStarting; - bool m_continuousPhysics; - bool m_subStepping; - - bool m_stepComplete; - - b2Profile m_profile; -}; - -inline b2Body* b2World::GetBodyList() -{ - return m_bodyList; -} - -inline const b2Body* b2World::GetBodyList() const -{ - return m_bodyList; -} - -inline b2Joint* b2World::GetJointList() -{ - return m_jointList; -} - -inline const b2Joint* b2World::GetJointList() const -{ - return m_jointList; -} - -inline b2Contact* b2World::GetContactList() -{ - return m_contactManager.m_contactList; -} - -inline const b2Contact* b2World::GetContactList() const -{ - return m_contactManager.m_contactList; -} - -inline int32 b2World::GetBodyCount() const -{ - return m_bodyCount; -} - -inline int32 b2World::GetJointCount() const -{ - return m_jointCount; -} - -inline int32 b2World::GetContactCount() const -{ - return m_contactManager.m_contactCount; -} - -inline void b2World::SetGravity(const b2Vec2& gravity) -{ - m_gravity = gravity; -} - -inline b2Vec2 b2World::GetGravity() const -{ - return m_gravity; -} - -inline bool b2World::IsLocked() const -{ - return (m_flags & e_locked) == e_locked; -} - -inline void b2World::SetAutoClearForces(bool flag) -{ - if (flag) - { - m_flags |= e_clearForces; - } - else - { - m_flags &= ~e_clearForces; - } -} - -/// Get the flag that controls automatic clearing of forces after each time step. -inline bool b2World::GetAutoClearForces() const -{ - return (m_flags & e_clearForces) == e_clearForces; -} - -inline const b2ContactManager& b2World::GetContactManager() const -{ - return m_contactManager; -} - -inline const b2Profile& b2World::GetProfile() const -{ - return m_profile; -} - -#endif diff --git a/sources/Box2D/Dynamics/b2WorldCallbacks.cpp b/sources/Box2D/Dynamics/b2WorldCallbacks.cpp deleted file mode 100755 index 82b28cc0..00000000 --- a/sources/Box2D/Dynamics/b2WorldCallbacks.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -// Return true if contact calculations should be performed between these two shapes. -// If you implement your own collision filter you may want to build from this implementation. -bool b2ContactFilter::ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB) -{ - const b2Filter& filterA = fixtureA->GetFilterData(); - const b2Filter& filterB = fixtureB->GetFilterData(); - - if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) - { - return filterA.groupIndex > 0; - } - - bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0; - return collide; -} diff --git a/sources/Box2D/Dynamics/b2WorldCallbacks.h b/sources/Box2D/Dynamics/b2WorldCallbacks.h deleted file mode 100755 index 9b937e81..00000000 --- a/sources/Box2D/Dynamics/b2WorldCallbacks.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_WORLD_CALLBACKS_H -#define B2_WORLD_CALLBACKS_H - -#include - -struct b2Vec2; -struct b2Transform; -class b2Fixture; -class b2Body; -class b2Joint; -class b2Contact; -struct b2ContactResult; -struct b2Manifold; - -/// Joints and fixtures are destroyed when their associated -/// body is destroyed. Implement this listener so that you -/// may nullify references to these joints and shapes. -class b2DestructionListener -{ -public: - virtual ~b2DestructionListener() {} - - /// Called when any joint is about to be destroyed due - /// to the destruction of one of its attached bodies. - virtual void SayGoodbye(b2Joint* joint) = 0; - - /// Called when any fixture is about to be destroyed due - /// to the destruction of its parent body. - virtual void SayGoodbye(b2Fixture* fixture) = 0; -}; - -/// Implement this class to provide collision filtering. In other words, you can implement -/// this class if you want finer control over contact creation. -class b2ContactFilter -{ -public: - virtual ~b2ContactFilter() {} - - /// Return true if contact calculations should be performed between these two shapes. - /// @warning for performance reasons this is only called when the AABBs begin to overlap. - virtual bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB); -}; - -/// Contact impulses for reporting. Impulses are used instead of forces because -/// sub-step forces may approach infinity for rigid body collisions. These -/// match up one-to-one with the contact points in b2Manifold. -struct b2ContactImpulse -{ - float32 normalImpulses[b2_maxManifoldPoints]; - float32 tangentImpulses[b2_maxManifoldPoints]; - int32 count; -}; - -/// Implement this class to get contact information. You can use these results for -/// things like sounds and game logic. You can also get contact results by -/// traversing the contact lists after the time step. However, you might miss -/// some contacts because continuous physics leads to sub-stepping. -/// Additionally you may receive multiple callbacks for the same contact in a -/// single time step. -/// You should strive to make your callbacks efficient because there may be -/// many callbacks per time step. -/// @warning You cannot create/destroy Box2D entities inside these callbacks. -class b2ContactListener -{ -public: - virtual ~b2ContactListener() {} - - /// Called when two fixtures begin to touch. - virtual void BeginContact(b2Contact* contact) { B2_NOT_USED(contact); } - - /// Called when two fixtures cease to touch. - virtual void EndContact(b2Contact* contact) { B2_NOT_USED(contact); } - - /// This is called after a contact is updated. This allows you to inspect a - /// contact before it goes to the solver. If you are careful, you can modify the - /// contact manifold (e.g. disable contact). - /// A copy of the old manifold is provided so that you can detect changes. - /// Note: this is called only for awake bodies. - /// Note: this is called even when the number of contact points is zero. - /// Note: this is not called for sensors. - /// Note: if you set the number of contact points to zero, you will not - /// get an EndContact callback. However, you may get a BeginContact callback - /// the next step. - virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) - { - B2_NOT_USED(contact); - B2_NOT_USED(oldManifold); - } - - /// This lets you inspect a contact after the solver is finished. This is useful - /// for inspecting impulses. - /// Note: the contact manifold does not include time of impact impulses, which can be - /// arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly - /// in a separate data structure. - /// Note: this is only called for contacts that are touching, solid, and awake. - virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) - { - B2_NOT_USED(contact); - B2_NOT_USED(impulse); - } -}; - -/// Callback class for AABB queries. -/// See b2World::Query -class b2QueryCallback -{ -public: - virtual ~b2QueryCallback() {} - - /// Called for each fixture found in the query AABB. - /// @return false to terminate the query. - virtual bool ReportFixture(b2Fixture* fixture) = 0; -}; - -/// Callback class for ray casts. -/// See b2World::RayCast -class b2RayCastCallback -{ -public: - virtual ~b2RayCastCallback() {} - - /// Called for each fixture found in the query. You control how the ray cast - /// proceeds by returning a float: - /// return -1: ignore this fixture and continue - /// return 0: terminate the ray cast - /// return fraction: clip the ray to this point - /// return 1: don't clip the ray and continue - /// @param fixture the fixture hit by the ray - /// @param point the point of initial intersection - /// @param normal the normal vector at the point of intersection - /// @return -1 to filter, 0 to terminate, fraction to clip the ray for - /// closest hit, 1 to continue - virtual float32 ReportFixture( b2Fixture* fixture, const b2Vec2& point, - const b2Vec2& normal, float32 fraction) = 0; -}; - -#endif diff --git a/sources/Box2D/Rope/b2Rope.cpp b/sources/Box2D/Rope/b2Rope.cpp deleted file mode 100755 index 97578b26..00000000 --- a/sources/Box2D/Rope/b2Rope.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 -#include - -b2Rope::b2Rope() -{ - m_count = 0; - m_ps = NULL; - m_p0s = NULL; - m_vs = NULL; - m_ims = NULL; - m_Ls = NULL; - m_as = NULL; - m_gravity.SetZero(); - m_k2 = 1.0f; - m_k3 = 0.1f; -} - -b2Rope::~b2Rope() -{ - b2Free(m_ps); - b2Free(m_p0s); - b2Free(m_vs); - b2Free(m_ims); - b2Free(m_Ls); - b2Free(m_as); -} - -void b2Rope::Initialize(const b2RopeDef* def) -{ - b2Assert(def->count >= 3); - m_count = def->count; - m_ps = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2)); - m_p0s = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2)); - m_vs = (b2Vec2*)b2Alloc(m_count * sizeof(b2Vec2)); - m_ims = (float32*)b2Alloc(m_count * sizeof(float32)); - - for (int32 i = 0; i < m_count; ++i) - { - m_ps[i] = def->vertices[i]; - m_p0s[i] = def->vertices[i]; - m_vs[i].SetZero(); - - float32 m = def->masses[i]; - if (m > 0.0f) - { - m_ims[i] = 1.0f / m; - } - else - { - m_ims[i] = 0.0f; - } - } - - int32 count2 = m_count - 1; - int32 count3 = m_count - 2; - m_Ls = (float32*)b2Alloc(count2 * sizeof(float32)); - m_as = (float32*)b2Alloc(count3 * sizeof(float32)); - - for (int32 i = 0; i < count2; ++i) - { - b2Vec2 p1 = m_ps[i]; - b2Vec2 p2 = m_ps[i+1]; - m_Ls[i] = b2Distance(p1, p2); - } - - for (int32 i = 0; i < count3; ++i) - { - b2Vec2 p1 = m_ps[i]; - b2Vec2 p2 = m_ps[i + 1]; - b2Vec2 p3 = m_ps[i + 2]; - - b2Vec2 d1 = p2 - p1; - b2Vec2 d2 = p3 - p2; - - float32 a = b2Cross(d1, d2); - float32 b = b2Dot(d1, d2); - - m_as[i] = b2Atan2(a, b); - } - - m_gravity = def->gravity; - m_damping = def->damping; - m_k2 = def->k2; - m_k3 = def->k3; -} - -void b2Rope::Step(float32 h, int32 iterations) -{ - if (h == 0.0) - { - return; - } - - float32 d = expf(- h * m_damping); - - for (int32 i = 0; i < m_count; ++i) - { - m_p0s[i] = m_ps[i]; - if (m_ims[i] > 0.0f) - { - m_vs[i] += h * m_gravity; - } - m_vs[i] *= d; - m_ps[i] += h * m_vs[i]; - - } - - for (int32 i = 0; i < iterations; ++i) - { - SolveC2(); - SolveC3(); - SolveC2(); - } - - float32 inv_h = 1.0f / h; - for (int32 i = 0; i < m_count; ++i) - { - m_vs[i] = inv_h * (m_ps[i] - m_p0s[i]); - } -} - -void b2Rope::SolveC2() -{ - int32 count2 = m_count - 1; - - for (int32 i = 0; i < count2; ++i) - { - b2Vec2 p1 = m_ps[i]; - b2Vec2 p2 = m_ps[i + 1]; - - b2Vec2 d = p2 - p1; - float32 L = d.Normalize(); - - float32 im1 = m_ims[i]; - float32 im2 = m_ims[i + 1]; - - if (im1 + im2 == 0.0f) - { - continue; - } - - float32 s1 = im1 / (im1 + im2); - float32 s2 = im2 / (im1 + im2); - - p1 -= m_k2 * s1 * (m_Ls[i] - L) * d; - p2 += m_k2 * s2 * (m_Ls[i] - L) * d; - - m_ps[i] = p1; - m_ps[i + 1] = p2; - } -} - -void b2Rope::SetAngle(float32 angle) -{ - int32 count3 = m_count - 2; - for (int32 i = 0; i < count3; ++i) - { - m_as[i] = angle; - } -} - -void b2Rope::SolveC3() -{ - int32 count3 = m_count - 2; - - for (int32 i = 0; i < count3; ++i) - { - b2Vec2 p1 = m_ps[i]; - b2Vec2 p2 = m_ps[i + 1]; - b2Vec2 p3 = m_ps[i + 2]; - - float32 m1 = m_ims[i]; - float32 m2 = m_ims[i + 1]; - float32 m3 = m_ims[i + 2]; - - b2Vec2 d1 = p2 - p1; - b2Vec2 d2 = p3 - p2; - - float32 L1sqr = d1.LengthSquared(); - float32 L2sqr = d2.LengthSquared(); - - if (L1sqr * L2sqr == 0.0f) - { - continue; - } - - float32 a = b2Cross(d1, d2); - float32 b = b2Dot(d1, d2); - - float32 angle = b2Atan2(a, b); - - b2Vec2 Jd1 = (-1.0f / L1sqr) * d1.Skew(); - b2Vec2 Jd2 = (1.0f / L2sqr) * d2.Skew(); - - b2Vec2 J1 = -Jd1; - b2Vec2 J2 = Jd1 - Jd2; - b2Vec2 J3 = Jd2; - - float32 mass = m1 * b2Dot(J1, J1) + m2 * b2Dot(J2, J2) + m3 * b2Dot(J3, J3); - if (mass == 0.0f) - { - continue; - } - - mass = 1.0f / mass; - - float32 C = angle - m_as[i]; - - while (C > b2_pi) - { - angle -= 2 * b2_pi; - C = angle - m_as[i]; - } - - while (C < -b2_pi) - { - angle += 2.0f * b2_pi; - C = angle - m_as[i]; - } - - float32 impulse = - m_k3 * mass * C; - - p1 += (m1 * impulse) * J1; - p2 += (m2 * impulse) * J2; - p3 += (m3 * impulse) * J3; - - m_ps[i] = p1; - m_ps[i + 1] = p2; - m_ps[i + 2] = p3; - } -} - -void b2Rope::Draw(b2Draw* draw) const -{ - b2Color c(0.4f, 0.5f, 0.7f); - - for (int32 i = 0; i < m_count - 1; ++i) - { - draw->DrawSegment(m_ps[i], m_ps[i+1], c); - } -} diff --git a/sources/Box2D/Rope/b2Rope.h b/sources/Box2D/Rope/b2Rope.h deleted file mode 100755 index bc5375dd..00000000 --- a/sources/Box2D/Rope/b2Rope.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -* Copyright (c) 2011 Erin Catto http://www.box2d.org -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as 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 B2_ROPE_H -#define B2_ROPE_H - -#include - -class b2Draw; - -/// -struct b2RopeDef -{ - b2RopeDef() - { - vertices = NULL; - count = 0; - masses = NULL; - gravity.SetZero(); - damping = 0.1f; - k2 = 0.9f; - k3 = 0.1f; - } - - /// - b2Vec2* vertices; - - /// - int32 count; - - /// - float32* masses; - - /// - b2Vec2 gravity; - - /// - float32 damping; - - /// Stretching stiffness - float32 k2; - - /// Bending stiffness. Values above 0.5 can make the simulation blow up. - float32 k3; -}; - -/// -class b2Rope -{ -public: - b2Rope(); - ~b2Rope(); - - /// - void Initialize(const b2RopeDef* def); - - /// - void Step(float32 timeStep, int32 iterations); - - /// - int32 GetVertexCount() const - { - return m_count; - } - - /// - const b2Vec2* GetVertices() const - { - return m_ps; - } - - /// - void Draw(b2Draw* draw) const; - - /// - void SetAngle(float32 angle); - -private: - - void SolveC2(); - void SolveC3(); - - int32 m_count; - b2Vec2* m_ps; - b2Vec2* m_p0s; - b2Vec2* m_vs; - - float32* m_ims; - - float32* m_Ls; - float32* m_as; - - b2Vec2 m_gravity; - float32 m_damping; - - float32 m_k2; - float32 m_k3; -}; - -#endif diff --git a/sources/Box2D/UseBox2D.cmake b/sources/Box2D/UseBox2D.cmake deleted file mode 100755 index cb9dc8c0..00000000 --- a/sources/Box2D/UseBox2D.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# -*- cmake -*- -# -# UseBox2d.cmake -# - -add_definitions ( ${BOX2D_DEFINITIONS} ) -include_directories ( ${BOX2D_INCLUDE_DIRS} ) -link_directories ( ${BOX2D_LIBRARY_DIRS} ) - diff --git a/sources/Box2D/b2ObjectDestroyNotifier.cpp b/sources/Box2D/b2ObjectDestroyNotifier.cpp deleted file mode 100644 index 2255c27a..00000000 --- a/sources/Box2D/b2ObjectDestroyNotifier.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "b2ObjectDestroyNotifier.h" - -static b2ObjectDestroyNotifer __objectDestroyNotifier = nullptr; - -void b2SetObjectDestroyNotifier(b2ObjectDestroyNotifer notifier) -{ - __objectDestroyNotifier = notifier; -} - -void b2NotifyObjectDestroyed(void* obj, b2ObjectType type, const char* typeName) -{ - if (__objectDestroyNotifier != nullptr) - { - __objectDestroyNotifier(obj, type, typeName); - } -} diff --git a/sources/Box2D/b2ObjectDestroyNotifier.h b/sources/Box2D/b2ObjectDestroyNotifier.h deleted file mode 100644 index 481d368c..00000000 --- a/sources/Box2D/b2ObjectDestroyNotifier.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -enum class b2ObjectType -{ - CONTACT, - CIRCLE_SHAPE, - EDGE_SHAPE, - POLYGON_SHAPE, - CHAIN_SHAPE, - FIXTURE, - JOIN, - BODY -}; - -typedef void (*b2ObjectDestroyNotifer)(void*, b2ObjectType, const char*); - -void b2SetObjectDestroyNotifier(b2ObjectDestroyNotifer notifier); -void b2NotifyObjectDestroyed(void* obj, b2ObjectType type, const char* typeName); diff --git a/sources/Box2D/proj.win32/libBox2D.vcxproj b/sources/Box2D/proj.win32/libBox2D.vcxproj deleted file mode 100644 index 013c3afa..00000000 --- a/sources/Box2D/proj.win32/libBox2D.vcxproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {EB7E5610-C178-49C9-8B4C-1C283E616ED9} - libSpine - - - - StaticLibrary - true - v120 - v120_xp - v140 - v140_xp - v140 - v140_xp - Unicode - - - StaticLibrary - false - v120 - v120_xp - v140 - v140_xp - v140 - v140_xp - true - Unicode - - - - - - - - - - - - - - - $(SolutionDir)$(Configuration).win32\ - $(Configuration).win32\ - - - $(SolutionDir)$(Configuration).win32\ - $(Configuration).win32\ - - - - Level3 - Disabled - - - $(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - 4267;4251;4244;%(DisableSpecificWarnings) - false - - - true - - - - - Level3 - MinSpace - true - true - - - WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) - None - false - - - true - true - true - - - - - - \ No newline at end of file diff --git a/sources/Box2D/proj.win32/libBox2D.vcxproj.filters b/sources/Box2D/proj.win32/libBox2D.vcxproj.filters deleted file mode 100644 index 220afa11..00000000 --- a/sources/Box2D/proj.win32/libBox2D.vcxproj.filters +++ /dev/null @@ -1,326 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {136563bc-86f2-4cd4-b1c6-d7f8ca5c0a88} - - - {a06ca75b-ee01-4a0f-8e99-b65f849d564d} - - - {c81c912d-3cc5-4aa6-9d35-f7567ebae435} - - - {cf9bbcf8-a281-44f0-b4e4-ef2f8e2dbeab} - - - {730bd813-a1c1-43be-ae77-339401ffb322} - - - {8cf3fe1a-6bea-40f9-8053-51e52425338b} - - - {e092e87e-130a-4cc2-a7be-49476a843338} - - - {8b68009d-92ea-4ab1-be49-fb58a6bcdf36} - - - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Rope - - - Source Files\Box2D - - - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision\Shapes - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Collision - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Common - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Joints - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics\Contacts - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Dynamics - - - Source Files\Box2D\Rope - - - Source Files\Box2D - - - Source Files\Box2D - - - \ No newline at end of file diff --git a/sources/cjson/CMakeLists.txt b/sources/cjson/CMakeLists.txt deleted file mode 100644 index 0b11f6f7..00000000 --- a/sources/cjson/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ - - -add_library(cjson - ${CMAKE_CURRENT_LIST_DIR}/fpconv.h - ${CMAKE_CURRENT_LIST_DIR}/lua_cjson.h - ${CMAKE_CURRENT_LIST_DIR}/strbuf.h - ${CMAKE_CURRENT_LIST_DIR}/lua_cjson.c - ${CMAKE_CURRENT_LIST_DIR}/fpconv.c - ${CMAKE_CURRENT_LIST_DIR}/strbuf.c -) - -target_include_directories(cjson PUBLIC ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/sources/cjson/fpconv.c b/sources/cjson/fpconv.c deleted file mode 100644 index 49b83aed..00000000 --- a/sources/cjson/fpconv.c +++ /dev/null @@ -1,205 +0,0 @@ -/* fpconv - Floating point conversion routines - * - * Copyright (c) 2011-2012 Mark Pulford - * - * 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. - */ - -/* JSON uses a '.' decimal separator. strtod() / sprintf() under C libraries - * with locale support will break when the decimal separator is a comma. - * - * fpconv_* will around these issues with a translation buffer if required. - */ - -#include -#include -#include -#include - -#include "fpconv.h" - -/* Lua CJSON assumes the locale is the same for all threads within a - * process and doesn't change after initialisation. - * - * This avoids the need for per thread storage or expensive checks - * for call. */ -static char locale_decimal_point = '.'; - -/* In theory multibyte decimal_points are possible, but - * Lua CJSON only supports UTF-8 and known locales only have - * single byte decimal points ([.,]). - * - * localconv() may not be thread safe (=>crash), and nl_langinfo() is - * not supported on some platforms. Use sprintf() instead - if the - * locale does change, at least Lua CJSON won't crash. */ -static void fpconv_update_locale() -{ - char buf[8]; - - snprintf(buf, sizeof(buf), "%g", 0.5); - - /* Failing this test might imply the platform has a buggy dtoa - * implementation or wide characters */ - if (buf[0] != '0' || buf[2] != '5' || buf[3] != 0) { - fprintf(stderr, "Error: wide characters found or printf() bug."); - abort(); - } - - locale_decimal_point = buf[1]; -} - -/* Check for a valid number character: [-+0-9a-yA-Y.] - * Eg: -0.6e+5, infinity, 0xF0.F0pF0 - * - * Used to find the probable end of a number. It doesn't matter if - * invalid characters are counted - strtod() will find the valid - * number if it exists. The risk is that slightly more memory might - * be allocated before a parse error occurs. */ -static inline int valid_number_character(char ch) -{ - char lower_ch; - - if ('0' <= ch && ch <= '9') - return 1; - if (ch == '-' || ch == '+' || ch == '.') - return 1; - - /* Hex digits, exponent (e), base (p), "infinity",.. */ - lower_ch = ch | 0x20; - if ('a' <= lower_ch && lower_ch <= 'y') - return 1; - - return 0; -} - -/* Calculate the size of the buffer required for a strtod locale - * conversion. */ -static int strtod_buffer_size(const char *s) -{ - const char *p = s; - - while (valid_number_character(*p)) - p++; - - return (int)(p - s); -} - -/* Similar to strtod(), but must be passed the current locale's decimal point - * character. Guaranteed to be called at the start of any valid number in a string */ -double fpconv_strtod(const char *nptr, char **endptr) -{ - char localbuf[FPCONV_G_FMT_BUFSIZE]; - char *buf, *endbuf, *dp; - int buflen; - double value; - - /* System strtod() is fine when decimal point is '.' */ - if (locale_decimal_point == '.') - return strtod(nptr, endptr); - - buflen = strtod_buffer_size(nptr); - if (!buflen) { - /* No valid characters found, standard strtod() return */ - *endptr = (char *)nptr; - return 0; - } - - /* Duplicate number into buffer */ - if (buflen >= FPCONV_G_FMT_BUFSIZE) { - /* Handle unusually large numbers */ - buf = malloc(buflen + 1); - if (!buf) { - fprintf(stderr, "Out of memory"); - abort(); - } - } else { - /* This is the common case.. */ - buf = localbuf; - } - memcpy(buf, nptr, buflen); - buf[buflen] = 0; - - /* Update decimal point character if found */ - dp = strchr(buf, '.'); - if (dp) - *dp = locale_decimal_point; - - value = strtod(buf, &endbuf); - *endptr = (char *)&nptr[endbuf - buf]; - if (buflen >= FPCONV_G_FMT_BUFSIZE) - free(buf); - - return value; -} - -/* "fmt" must point to a buffer of at least 6 characters */ -static void set_number_format(char *fmt, int precision) -{ - int d1, d2, i; - - assert(1 <= precision && precision <= 14); - - /* Create printf format (%.14g) from precision */ - d1 = precision / 10; - d2 = precision % 10; - fmt[0] = '%'; - fmt[1] = '.'; - i = 2; - if (d1) { - fmt[i++] = '0' + d1; - } - fmt[i++] = '0' + d2; - fmt[i++] = 'g'; - fmt[i] = 0; -} - -/* Assumes there is always at least 32 characters available in the target buffer */ -int fpconv_g_fmt(char *str, double num, int precision) -{ - char buf[FPCONV_G_FMT_BUFSIZE]; - char fmt[6]; - int len; - char *b; - - set_number_format(fmt, precision); - - /* Pass through when decimal point character is dot. */ - if (locale_decimal_point == '.') - return snprintf(str, FPCONV_G_FMT_BUFSIZE, fmt, num); - - /* snprintf() to a buffer then translate for other decimal point characters */ - len = snprintf(buf, FPCONV_G_FMT_BUFSIZE, fmt, num); - - /* Copy into target location. Translate decimal point if required */ - b = buf; - do { - *str++ = (*b == locale_decimal_point ? '.' : *b); - } while(*b++); - - return len; -} - -void fpconv_init() -{ - fpconv_update_locale(); -} - -/* vi:ai et sw=4 ts=4: - */ diff --git a/sources/cjson/fpconv.h b/sources/cjson/fpconv.h deleted file mode 100644 index 02017be1..00000000 --- a/sources/cjson/fpconv.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Lua CJSON floating point conversion routines */ - -/* Buffer required to store the largest string representation of a double. - * - * Longest double printed with %.14g is 21 characters long: - * -1.7976931348623e+308 */ -# define FPCONV_G_FMT_BUFSIZE 32 - -#ifdef _MSC_VER -#define snprintf _snprintf -#undef inline -#define inline __inline -#endif - -#ifdef USE_INTERNAL_FPCONV -static void fpconv_init() -{ - /* Do nothing - not required */ -} -#else -extern void fpconv_init(); -#endif - -extern int fpconv_g_fmt(char*, double, int); -extern double fpconv_strtod(const char*, char**); - -/* vi:ai et sw=4 ts=4: - */ diff --git a/sources/cjson/lua_cjson.c b/sources/cjson/lua_cjson.c deleted file mode 100644 index e7633be6..00000000 --- a/sources/cjson/lua_cjson.c +++ /dev/null @@ -1,1456 +0,0 @@ -/* Lua CJSON - JSON support for Lua - * - * Copyright (c) 2010-2012 Mark Pulford - * - * 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. - */ - -/* Caveats: - * - JSON "null" values are represented as lightuserdata since Lua - * tables cannot contain "nil". Compare with cjson.null. - * - Invalid UTF-8 characters are not detected and will be passed - * untouched. If required, UTF-8 error checking should be done - * outside this library. - * - Javascript comments are not part of the JSON spec, and are not - * currently supported. - * - * Note: Decoding is slower than encoding. Lua spends significant - * time (30%) managing tables when parsing JSON since it is - * difficult to know object/array sizes ahead of time. - */ - -#include -#include -#include -#include - -#include "lua.h" -#include "lauxlib.h" -#include "strbuf.h" -#include "fpconv.h" - -#ifndef CJSON_MODNAME -#define CJSON_MODNAME "cjson" -#endif - -#ifndef CJSON_VERSION -#define CJSON_VERSION "2.1devel" -#endif - -#ifdef _WIN32 -#define __strncasecmp strnicmp -#define isnan(x) ((x) != (x)) -#define isinf(x) (!isnan(x) && isnan(x - x)) -#else -#define __strncasecmp strncasecmp -#endif - -#define DEFAULT_SPARSE_CONVERT 0 -#define DEFAULT_SPARSE_RATIO 2 -#define DEFAULT_SPARSE_SAFE 10 -#define DEFAULT_ENCODE_MAX_DEPTH 1000 -#define DEFAULT_DECODE_MAX_DEPTH 1000 -#define DEFAULT_ENCODE_INVALID_NUMBERS 0 -#define DEFAULT_DECODE_INVALID_NUMBERS 1 -#define DEFAULT_ENCODE_KEEP_BUFFER 1 -#define DEFAULT_ENCODE_NUMBER_PRECISION 14 -#define DEFAULT_DECODE_LUA_NIL 1 - -#ifdef DISABLE_INVALID_NUMBERS -#undef DEFAULT_DECODE_INVALID_NUMBERS -#define DEFAULT_DECODE_INVALID_NUMBERS 0 -#endif - -typedef enum { - T_OBJ_BEGIN, - T_OBJ_END, - T_ARR_BEGIN, - T_ARR_END, - T_STRING, - T_NUMBER, - T_BOOLEAN, - T_NULL, - T_COLON, - T_COMMA, - T_END, - T_WHITESPACE, - T_ERROR, - T_UNKNOWN -} json_token_type_t; - -static const char *json_token_type_name[] = { - "T_OBJ_BEGIN", - "T_OBJ_END", - "T_ARR_BEGIN", - "T_ARR_END", - "T_STRING", - "T_NUMBER", - "T_BOOLEAN", - "T_NULL", - "T_COLON", - "T_COMMA", - "T_END", - "T_WHITESPACE", - "T_ERROR", - "T_UNKNOWN", - NULL -}; - -typedef struct { - json_token_type_t ch2token[256]; - char escape2char[256]; /* Decoding */ - - /* encode_buf is only allocated and used when - * encode_keep_buffer is set */ - strbuf_t encode_buf; - - int encode_sparse_convert; - int encode_sparse_ratio; - int encode_sparse_safe; - int encode_max_depth; - int encode_invalid_numbers; /* 2 => Encode as "null" */ - int encode_number_precision; - int encode_keep_buffer; - - int decode_invalid_numbers; - int decode_max_depth; - int decode_lua_nil; /* 1 => use Lua nil for NULL */ -} json_config_t; - -typedef struct { - const char *data; - const char *ptr; - strbuf_t *tmp; /* Temporary storage for strings */ - json_config_t *cfg; - int current_depth; -} json_parse_t; - -typedef struct { - json_token_type_t type; - int index; - union { - const char *string; - double number; - int boolean; - } value; - int string_len; -} json_token_t; - -static const char *char2escape[256] = { - "\\u0000", "\\u0001", "\\u0002", "\\u0003", - "\\u0004", "\\u0005", "\\u0006", "\\u0007", - "\\b", "\\t", "\\n", "\\u000b", - "\\f", "\\r", "\\u000e", "\\u000f", - "\\u0010", "\\u0011", "\\u0012", "\\u0013", - "\\u0014", "\\u0015", "\\u0016", "\\u0017", - "\\u0018", "\\u0019", "\\u001a", "\\u001b", - "\\u001c", "\\u001d", "\\u001e", "\\u001f", - NULL, NULL, "\\\"", NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, "\\/", - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, "\\\\", NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, "\\u007f", - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -}; - -/* ===== CONFIGURATION ===== */ - -static json_config_t *json_fetch_config(lua_State *l) -{ - json_config_t *cfg; - - cfg = lua_touserdata(l, lua_upvalueindex(1)); - if (!cfg) - luaL_error(l, "BUG: Unable to fetch CJSON configuration"); - - return cfg; -} - -/* Ensure the correct number of arguments have been provided. - * Pad with nil to allow other functions to simply check arg[i] - * to find whether an argument was provided */ -static json_config_t *json_arg_init(lua_State *l, int args) -{ - luaL_argcheck(l, lua_gettop(l) <= args, args + 1, - "found too many arguments"); - - while (lua_gettop(l) < args) - lua_pushnil(l); - - return json_fetch_config(l); -} - -/* Process integer options for configuration functions */ -static int json_integer_option(lua_State *l, int optindex, int *setting, - int min, int max) -{ - char errmsg[64]; - int value; - - if (!lua_isnil(l, optindex)) { - value = (int)luaL_checkinteger(l, optindex); - snprintf(errmsg, sizeof(errmsg), "expected integer between %d and %d", min, max); - luaL_argcheck(l, min <= value && value <= max, 1, errmsg); - *setting = value; - } - - lua_pushinteger(l, *setting); - - return 1; -} - -/* Process enumerated arguments for a configuration function */ -static int json_enum_option(lua_State *l, int optindex, int *setting, - const char **options, int bool_true) -{ - static const char *bool_options[] = { "off", "on", NULL }; - - if (!options) { - options = bool_options; - bool_true = 1; - } - - if (!lua_isnil(l, optindex)) { - if (bool_true && lua_isboolean(l, optindex)) - *setting = lua_toboolean(l, optindex) * bool_true; - else - *setting = luaL_checkoption(l, optindex, NULL, options); - } - - if (bool_true && (*setting == 0 || *setting == bool_true)) - lua_pushboolean(l, *setting); - else - lua_pushstring(l, options[*setting]); - - return 1; -} - -/* Configures handling of extremely sparse arrays: - * convert: Convert extremely sparse arrays into objects? Otherwise error. - * ratio: 0: always allow sparse; 1: never allow sparse; >1: use ratio - * safe: Always use an array when the max index <= safe */ -static int json_cfg_encode_sparse_array(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 3); - - json_enum_option(l, 1, &cfg->encode_sparse_convert, NULL, 1); - json_integer_option(l, 2, &cfg->encode_sparse_ratio, 0, INT_MAX); - json_integer_option(l, 3, &cfg->encode_sparse_safe, 0, INT_MAX); - - return 3; -} - -/* Configures the maximum number of nested arrays/objects allowed when - * encoding */ -static int json_cfg_encode_max_depth(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 1); - - return json_integer_option(l, 1, &cfg->encode_max_depth, 1, INT_MAX); -} - -/* Configures the maximum number of nested arrays/objects allowed when - * encoding */ -static int json_cfg_decode_max_depth(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 1); - - return json_integer_option(l, 1, &cfg->decode_max_depth, 1, INT_MAX); -} - -/* Configures number precision when converting doubles to text */ -static int json_cfg_encode_number_precision(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 1); - - return json_integer_option(l, 1, &cfg->encode_number_precision, 1, 14); -} - -/* Configures JSON encoding buffer persistence */ -static int json_cfg_encode_keep_buffer(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 1); - int old_value; - - old_value = cfg->encode_keep_buffer; - - json_enum_option(l, 1, &cfg->encode_keep_buffer, NULL, 1); - - /* Init / free the buffer if the setting has changed */ - if (old_value ^ cfg->encode_keep_buffer) { - if (cfg->encode_keep_buffer) - strbuf_init(&cfg->encode_buf, 0); - else - strbuf_free(&cfg->encode_buf); - } - - return 1; -} - -#if defined(DISABLE_INVALID_NUMBERS) && !defined(USE_INTERNAL_FPCONV) -void json_verify_invalid_number_setting(lua_State *l, int *setting) -{ - if (*setting == 1) { - *setting = 0; - luaL_error(l, "Infinity, NaN, and/or hexadecimal numbers are not supported."); - } -} -#else -#define json_verify_invalid_number_setting(l, s) do { } while(0) -#endif - -static int json_cfg_encode_invalid_numbers(lua_State *l) -{ - static const char *options[] = { "off", "on", "null", NULL }; - json_config_t *cfg = json_arg_init(l, 1); - - json_enum_option(l, 1, &cfg->encode_invalid_numbers, options, 1); - - json_verify_invalid_number_setting(l, &cfg->encode_invalid_numbers); - - return 1; -} - -static int json_cfg_decode_invalid_numbers(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 1); - - json_enum_option(l, 1, &cfg->decode_invalid_numbers, NULL, 1); - - json_verify_invalid_number_setting(l, &cfg->encode_invalid_numbers); - - return 1; -} - -static int json_cfg_decode_lua_nil(lua_State *l) -{ - json_config_t *cfg = json_arg_init(l, 1); - - json_enum_option(l, 1, &cfg->decode_lua_nil, NULL, 1); - - return 1; -} - -static int json_destroy_config(lua_State *l) -{ - json_config_t *cfg; - - cfg = lua_touserdata(l, 1); - if (cfg) - strbuf_free(&cfg->encode_buf); - cfg = NULL; - - return 0; -} - -static void json_create_config(lua_State *l) -{ - json_config_t *cfg; - int i; - - cfg = lua_newuserdata(l, sizeof(*cfg)); - - /* Create GC method to clean up strbuf */ - lua_newtable(l); - lua_pushcfunction(l, json_destroy_config); - lua_setfield(l, -2, "__gc"); - lua_setmetatable(l, -2); - - cfg->encode_sparse_convert = DEFAULT_SPARSE_CONVERT; - cfg->encode_sparse_ratio = DEFAULT_SPARSE_RATIO; - cfg->encode_sparse_safe = DEFAULT_SPARSE_SAFE; - cfg->encode_max_depth = DEFAULT_ENCODE_MAX_DEPTH; - cfg->decode_max_depth = DEFAULT_DECODE_MAX_DEPTH; - cfg->encode_invalid_numbers = DEFAULT_ENCODE_INVALID_NUMBERS; - cfg->decode_invalid_numbers = DEFAULT_DECODE_INVALID_NUMBERS; - cfg->encode_keep_buffer = DEFAULT_ENCODE_KEEP_BUFFER; - cfg->encode_number_precision = DEFAULT_ENCODE_NUMBER_PRECISION; - cfg->decode_lua_nil = DEFAULT_DECODE_LUA_NIL; - -#if DEFAULT_ENCODE_KEEP_BUFFER > 0 - strbuf_init(&cfg->encode_buf, 0); -#endif - - /* Decoding init */ - - /* Tag all characters as an error */ - for (i = 0; i < 256; i++) - cfg->ch2token[i] = T_ERROR; - - /* Set tokens that require no further processing */ - cfg->ch2token['{'] = T_OBJ_BEGIN; - cfg->ch2token['}'] = T_OBJ_END; - cfg->ch2token['['] = T_ARR_BEGIN; - cfg->ch2token[']'] = T_ARR_END; - cfg->ch2token[','] = T_COMMA; - cfg->ch2token[':'] = T_COLON; - cfg->ch2token['\0'] = T_END; - cfg->ch2token[' '] = T_WHITESPACE; - cfg->ch2token['\t'] = T_WHITESPACE; - cfg->ch2token['\n'] = T_WHITESPACE; - cfg->ch2token['\r'] = T_WHITESPACE; - - /* Update characters that require further processing */ - cfg->ch2token['f'] = T_UNKNOWN; /* false? */ - cfg->ch2token['i'] = T_UNKNOWN; /* inf, ininity? */ - cfg->ch2token['I'] = T_UNKNOWN; - cfg->ch2token['n'] = T_UNKNOWN; /* null, nan? */ - cfg->ch2token['N'] = T_UNKNOWN; - cfg->ch2token['t'] = T_UNKNOWN; /* true? */ - cfg->ch2token['"'] = T_UNKNOWN; /* string? */ - cfg->ch2token['+'] = T_UNKNOWN; /* number? */ - cfg->ch2token['-'] = T_UNKNOWN; - for (i = 0; i < 10; i++) - cfg->ch2token['0' + i] = T_UNKNOWN; - - /* Lookup table for parsing escape characters */ - for (i = 0; i < 256; i++) - cfg->escape2char[i] = 0; /* String error */ - cfg->escape2char['"'] = '"'; - cfg->escape2char['\\'] = '\\'; - cfg->escape2char['/'] = '/'; - cfg->escape2char['b'] = '\b'; - cfg->escape2char['t'] = '\t'; - cfg->escape2char['n'] = '\n'; - cfg->escape2char['f'] = '\f'; - cfg->escape2char['r'] = '\r'; - cfg->escape2char['u'] = 'u'; /* Unicode parsing required */ -} - -/* ===== ENCODING ===== */ - -static void json_encode_exception(lua_State *l, json_config_t *cfg, strbuf_t *json, int lindex, - const char *reason) -{ - if (!cfg->encode_keep_buffer) - strbuf_free(json); - luaL_error(l, "Cannot serialise %s: %s", - lua_typename(l, lua_type(l, lindex)), reason); -} - -/* json_append_string args: - * - lua_State - * - JSON strbuf - * - String (Lua stack index) - * - * Returns nothing. Doesn't remove string from Lua stack */ -static void json_append_string(lua_State *l, strbuf_t *json, int lindex) -{ - const char *escstr; - int i; - const char *str; - size_t len; - - str = lua_tolstring(l, lindex, &len); - - /* Worst case is len * 6 (all unicode escapes). - * This buffer is reused constantly for small strings - * If there are any excess pages, they won't be hit anyway. - * This gains ~5% speedup. */ - strbuf_ensure_empty_length(json, (int)len * 6 + 2); - - strbuf_append_char_unsafe(json, '\"'); - for (i = 0; i < len; i++) { - escstr = char2escape[(unsigned char)str[i]]; - if (escstr) - strbuf_append_string(json, escstr); - else - strbuf_append_char_unsafe(json, str[i]); - } - strbuf_append_char_unsafe(json, '\"'); -} - -/* Find the size of the array on the top of the Lua stack - * -1 object (not a pure array) - * >=0 elements in array - */ -static int lua_array_length(lua_State *l, json_config_t *cfg, strbuf_t *json) -{ - double k; - int max; - int items; - - max = 0; - items = 0; - - lua_pushnil(l); - /* table, startkey */ - while (lua_next(l, -2) != 0) { - /* table, key, value */ - if (lua_type(l, -2) == LUA_TNUMBER && - (k = lua_tonumber(l, -2))) { - /* Integer >= 1 ? */ - if (floor(k) == k && k >= 1) { - if (k > max) - max = k; - items++; - lua_pop(l, 1); - continue; - } - } - - /* Must not be an array (non integer key) */ - lua_pop(l, 2); - return -1; - } - - /* Encode excessively sparse arrays as objects (if enabled) */ - if (cfg->encode_sparse_ratio > 0 && - max > items * cfg->encode_sparse_ratio && - max > cfg->encode_sparse_safe) { - if (!cfg->encode_sparse_convert) - json_encode_exception(l, cfg, json, -1, "excessively sparse array"); - - return -1; - } - - return max; -} - -static void json_check_encode_depth(lua_State *l, json_config_t *cfg, - int current_depth, strbuf_t *json) -{ - /* Ensure there are enough slots free to traverse a table (key, - * value) and push a string for a potential error message. - * - * Unlike "decode", the key and value are still on the stack when - * lua_checkstack() is called. Hence an extra slot for luaL_error() - * below is required just in case the next check to lua_checkstack() - * fails. - * - * While this won't cause a crash due to the EXTRA_STACK reserve - * slots, it would still be an improper use of the API. */ - if (current_depth <= cfg->encode_max_depth && lua_checkstack(l, 3)) - return; - - if (!cfg->encode_keep_buffer) - strbuf_free(json); - - luaL_error(l, "Cannot serialise, excessive nesting (%d)", - current_depth); -} - -static void json_append_data(lua_State *l, json_config_t *cfg, - int current_depth, strbuf_t *json); - -/* json_append_array args: - * - lua_State - * - JSON strbuf - * - Size of passwd Lua array (top of stack) */ -static void json_append_array(lua_State *l, json_config_t *cfg, int current_depth, - strbuf_t *json, int array_length) -{ - int comma, i; - - strbuf_append_char(json, '['); - - comma = 0; - for (i = 1; i <= array_length; i++) { - if (comma) - strbuf_append_char(json, ','); - else - comma = 1; - - lua_rawgeti(l, -1, i); - json_append_data(l, cfg, current_depth, json); - lua_pop(l, 1); - } - - strbuf_append_char(json, ']'); -} - -static void json_append_number(lua_State *l, json_config_t *cfg, - strbuf_t *json, int lindex) -{ - double num = lua_tonumber(l, lindex); - int len; - - if (cfg->encode_invalid_numbers == 0) { - /* Prevent encoding invalid numbers */ - if (isinf(num) || isnan(num)) - json_encode_exception(l, cfg, json, lindex, - "must not be NaN or Infinity"); - } else if (cfg->encode_invalid_numbers == 1) { - /* Encode NaN/Infinity separately to ensure Javascript compatible - * values are used. */ - if (isnan(num)) { - strbuf_append_mem(json, "NaN", 3); - return; - } - if (isinf(num)) { - if (num < 0) - strbuf_append_mem(json, "-Infinity", 9); - else - strbuf_append_mem(json, "Infinity", 8); - return; - } - } else { - /* Encode invalid numbers as "null" */ - if (isinf(num) || isnan(num)) { - strbuf_append_mem(json, "null", 4); - return; - } - } - - strbuf_ensure_empty_length(json, FPCONV_G_FMT_BUFSIZE); - len = fpconv_g_fmt(strbuf_empty_ptr(json), num, cfg->encode_number_precision); - strbuf_extend_length(json, len); -} - -static void json_append_object(lua_State *l, json_config_t *cfg, - int current_depth, strbuf_t *json) -{ - int comma, keytype; - - /* Object */ - strbuf_append_char(json, '{'); - - lua_pushnil(l); - /* table, startkey */ - comma = 0; - while (lua_next(l, -2) != 0) { - if (comma) - strbuf_append_char(json, ','); - else - comma = 1; - - /* table, key, value */ - keytype = lua_type(l, -2); - if (keytype == LUA_TNUMBER) { - strbuf_append_char(json, '"'); - json_append_number(l, cfg, json, -2); - strbuf_append_mem(json, "\":", 2); - } else if (keytype == LUA_TSTRING) { - json_append_string(l, json, -2); - strbuf_append_char(json, ':'); - } else { - json_encode_exception(l, cfg, json, -2, - "table key must be a number or string"); - /* never returns */ - } - - /* table, key, value */ - json_append_data(l, cfg, current_depth, json); - lua_pop(l, 1); - /* table, key */ - } - - strbuf_append_char(json, '}'); -} - -/* Serialise Lua data into JSON string. */ -static void json_append_data(lua_State *l, json_config_t *cfg, - int current_depth, strbuf_t *json) -{ - int len; - - switch (lua_type(l, -1)) { - case LUA_TSTRING: - json_append_string(l, json, -1); - break; - case LUA_TNUMBER: - json_append_number(l, cfg, json, -1); - break; - case LUA_TBOOLEAN: - if (lua_toboolean(l, -1)) - strbuf_append_mem(json, "true", 4); - else - strbuf_append_mem(json, "false", 5); - break; - case LUA_TTABLE: - current_depth++; - json_check_encode_depth(l, cfg, current_depth, json); - len = lua_array_length(l, cfg, json); - if (len > 0) - json_append_array(l, cfg, current_depth, json, len); - else - json_append_object(l, cfg, current_depth, json); - break; - case LUA_TNIL: - strbuf_append_mem(json, "null", 4); - break; - case LUA_TLIGHTUSERDATA: - if (lua_touserdata(l, -1) == NULL) { - strbuf_append_mem(json, "null", 4); - break; - } - default: - /* Remaining types (LUA_TFUNCTION, LUA_TUSERDATA, LUA_TTHREAD, - * and LUA_TLIGHTUSERDATA) cannot be serialised */ - json_encode_exception(l, cfg, json, -1, "type not supported"); - /* never returns */ - } -} - -static int json_encode(lua_State *l) -{ - json_config_t *cfg = json_fetch_config(l); - strbuf_t local_encode_buf; - strbuf_t *encode_buf; - char *json; - int len; - - luaL_argcheck(l, lua_gettop(l) == 1, 1, "expected 1 argument"); - - if (!cfg->encode_keep_buffer) { - /* Use private buffer */ - encode_buf = &local_encode_buf; - strbuf_init(encode_buf, 0); - } else { - /* Reuse existing buffer */ - encode_buf = &cfg->encode_buf; - strbuf_reset(encode_buf); - } - - json_append_data(l, cfg, 0, encode_buf); - json = strbuf_string(encode_buf, &len); - - lua_pushlstring(l, json, len); - - if (!cfg->encode_keep_buffer) - strbuf_free(encode_buf); - - return 1; -} - -/* ===== DECODING ===== */ - -static void json_process_value(lua_State *l, json_parse_t *json, - json_token_t *token); - -static int hexdigit2int(char hex) -{ - if ('0' <= hex && hex <= '9') - return hex - '0'; - - /* Force lowercase */ - hex |= 0x20; - if ('a' <= hex && hex <= 'f') - return 10 + hex - 'a'; - - return -1; -} - -static int decode_hex4(const char *hex) -{ - int digit[4]; - int i; - - /* Convert ASCII hex digit to numeric digit - * Note: this returns an error for invalid hex digits, including - * NULL */ - for (i = 0; i < 4; i++) { - digit[i] = hexdigit2int(hex[i]); - if (digit[i] < 0) { - return -1; - } - } - - return (digit[0] << 12) + - (digit[1] << 8) + - (digit[2] << 4) + - digit[3]; -} - -/* Converts a Unicode codepoint to UTF-8. - * Returns UTF-8 string length, and up to 4 bytes in *utf8 */ -static int codepoint_to_utf8(char *utf8, int codepoint) -{ - /* 0xxxxxxx */ - if (codepoint <= 0x7F) { - utf8[0] = codepoint; - return 1; - } - - /* 110xxxxx 10xxxxxx */ - if (codepoint <= 0x7FF) { - utf8[0] = (codepoint >> 6) | 0xC0; - utf8[1] = (codepoint & 0x3F) | 0x80; - return 2; - } - - /* 1110xxxx 10xxxxxx 10xxxxxx */ - if (codepoint <= 0xFFFF) { - utf8[0] = (codepoint >> 12) | 0xE0; - utf8[1] = ((codepoint >> 6) & 0x3F) | 0x80; - utf8[2] = (codepoint & 0x3F) | 0x80; - return 3; - } - - /* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */ - if (codepoint <= 0x1FFFFF) { - utf8[0] = (codepoint >> 18) | 0xF0; - utf8[1] = ((codepoint >> 12) & 0x3F) | 0x80; - utf8[2] = ((codepoint >> 6) & 0x3F) | 0x80; - utf8[3] = (codepoint & 0x3F) | 0x80; - return 4; - } - - return 0; -} - - -/* Called when index pointing to beginning of UTF-16 code escape: \uXXXX - * \u is guaranteed to exist, but the remaining hex characters may be - * missing. - * Translate to UTF-8 and append to temporary token string. - * Must advance index to the next character to be processed. - * Returns: 0 success - * -1 error - */ -static int json_append_unicode_escape(json_parse_t *json) -{ - char utf8[4]; /* Surrogate pairs require 4 UTF-8 bytes */ - int codepoint; - int surrogate_low; - int len; - int escape_len = 6; - - /* Fetch UTF-16 code unit */ - codepoint = decode_hex4(json->ptr + 2); - if (codepoint < 0) - return -1; - - /* UTF-16 surrogate pairs take the following 2 byte form: - * 11011 x yyyyyyyyyy - * When x = 0: y is the high 10 bits of the codepoint - * x = 1: y is the low 10 bits of the codepoint - * - * Check for a surrogate pair (high or low) */ - if ((codepoint & 0xF800) == 0xD800) { - /* Error if the 1st surrogate is not high */ - if (codepoint & 0x400) - return -1; - - /* Ensure the next code is a unicode escape */ - if (*(json->ptr + escape_len) != '\\' || - *(json->ptr + escape_len + 1) != 'u') { - return -1; - } - - /* Fetch the next codepoint */ - surrogate_low = decode_hex4(json->ptr + 2 + escape_len); - if (surrogate_low < 0) - return -1; - - /* Error if the 2nd code is not a low surrogate */ - if ((surrogate_low & 0xFC00) != 0xDC00) - return -1; - - /* Calculate Unicode codepoint */ - codepoint = (codepoint & 0x3FF) << 10; - surrogate_low &= 0x3FF; - codepoint = (codepoint | surrogate_low) + 0x10000; - escape_len = 12; - } - - /* Convert codepoint to UTF-8 */ - len = codepoint_to_utf8(utf8, codepoint); - if (!len) - return -1; - - /* Append bytes and advance parse index */ - strbuf_append_mem_unsafe(json->tmp, utf8, len); - json->ptr += escape_len; - - return 0; -} - -static void json_set_token_error(json_token_t *token, json_parse_t *json, - const char *errtype) -{ - token->type = T_ERROR; - token->index = (int)(json->ptr - json->data); - token->value.string = errtype; -} - -static void json_next_string_token(json_parse_t *json, json_token_t *token) -{ - char *escape2char = json->cfg->escape2char; - char ch; - - /* Caller must ensure a string is next */ - assert(*json->ptr == '"'); - - /* Skip " */ - json->ptr++; - - /* json->tmp is the temporary strbuf used to accumulate the - * decoded string value. - * json->tmp is sized to handle JSON containing only a string value. - */ - strbuf_reset(json->tmp); - - while ((ch = *json->ptr) != '"') { - if (!ch) { - /* Premature end of the string */ - json_set_token_error(token, json, "unexpected end of string"); - return; - } - - /* Handle escapes */ - if (ch == '\\') { - /* Fetch escape character */ - ch = *(json->ptr + 1); - - /* Translate escape code and append to tmp string */ - ch = escape2char[(unsigned char)ch]; - if (ch == 'u') { - if (json_append_unicode_escape(json) == 0) - continue; - - json_set_token_error(token, json, - "invalid unicode escape code"); - return; - } - if (!ch) { - json_set_token_error(token, json, "invalid escape code"); - return; - } - - /* Skip '\' */ - json->ptr++; - } - /* Append normal character or translated single character - * Unicode escapes are handled above */ - strbuf_append_char_unsafe(json->tmp, ch); - json->ptr++; - } - json->ptr++; /* Eat final quote (") */ - - strbuf_ensure_null(json->tmp); - - token->type = T_STRING; - token->value.string = strbuf_string(json->tmp, &token->string_len); -} - -/* JSON numbers should take the following form: - * -?(0|[1-9]|[1-9][0-9]+)(.[0-9]+)?([eE][-+]?[0-9]+)? - * - * json_next_number_token() uses strtod() which allows other forms: - * - numbers starting with '+' - * - NaN, -NaN, infinity, -infinity - * - hexadecimal numbers - * - numbers with leading zeros - * - * json_is_invalid_number() detects "numbers" which may pass strtod()'s - * error checking, but should not be allowed with strict JSON. - * - * json_is_invalid_number() may pass numbers which cause strtod() - * to generate an error. - */ -static int json_is_invalid_number(json_parse_t *json) -{ - const char *p = json->ptr; - - /* Reject numbers starting with + */ - if (*p == '+') - return 1; - - /* Skip minus sign if it exists */ - if (*p == '-') - p++; - - /* Reject numbers starting with 0x, or leading zeros */ - if (*p == '0') { - int ch2 = *(p + 1); - - if ((ch2 | 0x20) == 'x' || /* Hex */ - ('0' <= ch2 && ch2 <= '9')) /* Leading zero */ - return 1; - - return 0; - } else if (*p <= '9') { - return 0; /* Ordinary number */ - } - - /* Reject inf/nan */ - if (!__strncasecmp(p, "inf", 3)) - return 1; - if (!__strncasecmp(p, "nan", 3)) - return 1; - - /* Pass all other numbers which may still be invalid, but - * strtod() will catch them. */ - return 0; -} - -static void json_next_number_token(json_parse_t *json, json_token_t *token) -{ - char *endptr; - - token->type = T_NUMBER; - token->value.number = fpconv_strtod(json->ptr, &endptr); - if (json->ptr == endptr) - json_set_token_error(token, json, "invalid number"); - else - json->ptr = endptr; /* Skip the processed number */ - - return; -} - -/* Fills in the token struct. - * T_STRING will return a pointer to the json_parse_t temporary string - * T_ERROR will leave the json->ptr pointer at the error. - */ -static void json_next_token(json_parse_t *json, json_token_t *token) -{ - const json_token_type_t *ch2token = json->cfg->ch2token; - int ch; - - /* Eat whitespace. */ - while (1) { - ch = (unsigned char)*(json->ptr); - token->type = ch2token[ch]; - if (token->type != T_WHITESPACE) - break; - json->ptr++; - } - - /* Store location of new token. Required when throwing errors - * for unexpected tokens (syntax errors). */ - token->index = (int)(json->ptr - json->data); - - /* Don't advance the pointer for an error or the end */ - if (token->type == T_ERROR) { - json_set_token_error(token, json, "invalid token"); - return; - } - - if (token->type == T_END) { - return; - } - - /* Found a known single character token, advance index and return */ - if (token->type != T_UNKNOWN) { - json->ptr++; - return; - } - - /* Process characters which triggered T_UNKNOWN - * - * Must use strncmp() to match the front of the JSON string. - * JSON identifier must be lowercase. - * When strict_numbers if disabled, either case is allowed for - * Infinity/NaN (since we are no longer following the spec..) */ - if (ch == '"') { - json_next_string_token(json, token); - return; - } else if (ch == '-' || ('0' <= ch && ch <= '9')) { - if (!json->cfg->decode_invalid_numbers && json_is_invalid_number(json)) { - json_set_token_error(token, json, "invalid number"); - return; - } - json_next_number_token(json, token); - return; - } else if (!strncmp(json->ptr, "true", 4)) { - token->type = T_BOOLEAN; - token->value.boolean = 1; - json->ptr += 4; - return; - } else if (!strncmp(json->ptr, "false", 5)) { - token->type = T_BOOLEAN; - token->value.boolean = 0; - json->ptr += 5; - return; - } else if (!strncmp(json->ptr, "null", 4)) { - token->type = T_NULL; - json->ptr += 4; - return; - } else if (json->cfg->decode_invalid_numbers && - json_is_invalid_number(json)) { - /* When decode_invalid_numbers is enabled, only attempt to process - * numbers we know are invalid JSON (Inf, NaN, hex) - * This is required to generate an appropriate token error, - * otherwise all bad tokens will register as "invalid number" - */ - json_next_number_token(json, token); - return; - } - - /* Token starts with t/f/n but isn't recognised above. */ - json_set_token_error(token, json, "invalid token"); -} - -/* This function does not return. - * DO NOT CALL WITH DYNAMIC MEMORY ALLOCATED. - * The only supported exception is the temporary parser string - * json->tmp struct. - * json and token should exist on the stack somewhere. - * luaL_error() will long_jmp and release the stack */ -static void json_throw_parse_error(lua_State *l, json_parse_t *json, - const char *exp, json_token_t *token) -{ - const char *found; - - strbuf_free(json->tmp); - - if (token->type == T_ERROR) - found = token->value.string; - else - found = json_token_type_name[token->type]; - - /* Note: token->index is 0 based, display starting from 1 */ - luaL_error(l, "Expected %s but found %s at character %d", - exp, found, token->index + 1); -} - -static inline void json_decode_ascend(json_parse_t *json) -{ - json->current_depth--; -} - -static void json_decode_descend(lua_State *l, json_parse_t *json, int slots) -{ - json->current_depth++; - - if (json->current_depth <= json->cfg->decode_max_depth && - lua_checkstack(l, slots)) { - return; - } - - strbuf_free(json->tmp); - luaL_error(l, "Found too many nested data structures (%d) at character %d", - json->current_depth, json->ptr - json->data); -} - -static void json_parse_object_context(lua_State *l, json_parse_t *json) -{ - json_token_t token; - - /* 3 slots required: - * .., table, key, value */ - json_decode_descend(l, json, 3); - - lua_newtable(l); - - json_next_token(json, &token); - - /* Handle empty objects */ - if (token.type == T_OBJ_END) { - json_decode_ascend(json); - return; - } - - while (1) { - if (token.type != T_STRING) - json_throw_parse_error(l, json, "object key string", &token); - - /* Push key */ - lua_pushlstring(l, token.value.string, token.string_len); - - json_next_token(json, &token); - if (token.type != T_COLON) - json_throw_parse_error(l, json, "colon", &token); - - /* Fetch value */ - json_next_token(json, &token); - json_process_value(l, json, &token); - - /* Set key = value */ - lua_rawset(l, -3); - - json_next_token(json, &token); - - if (token.type == T_OBJ_END) { - json_decode_ascend(json); - return; - } - - if (token.type != T_COMMA) - json_throw_parse_error(l, json, "comma or object end", &token); - - json_next_token(json, &token); - } -} - -/* Handle the array context */ -static void json_parse_array_context(lua_State *l, json_parse_t *json) -{ - json_token_t token; - int i; - - /* 2 slots required: - * .., table, value */ - json_decode_descend(l, json, 2); - - lua_newtable(l); - - json_next_token(json, &token); - - /* Handle empty arrays */ - if (token.type == T_ARR_END) { - json_decode_ascend(json); - return; - } - - for (i = 1; ; i++) { - json_process_value(l, json, &token); - lua_rawseti(l, -2, i); /* arr[i] = value */ - - json_next_token(json, &token); - - if (token.type == T_ARR_END) { - json_decode_ascend(json); - return; - } - - if (token.type != T_COMMA) - json_throw_parse_error(l, json, "comma or array end", &token); - - json_next_token(json, &token); - } -} - -/* Handle the "value" context */ -static void json_process_value(lua_State *l, json_parse_t *json, - json_token_t *token) -{ - switch (token->type) { - case T_STRING: - lua_pushlstring(l, token->value.string, token->string_len); - break;; - case T_NUMBER: - lua_pushnumber(l, token->value.number); - break;; - case T_BOOLEAN: - lua_pushboolean(l, token->value.boolean); - break;; - case T_OBJ_BEGIN: - json_parse_object_context(l, json); - break;; - case T_ARR_BEGIN: - json_parse_array_context(l, json); - break;; - case T_NULL: - if (json->cfg->decode_lua_nil) - { - lua_pushnil(l); - } - else - { - /* In Lua, setting "t[k] = nil" will delete k from the table. - * Hence a NULL pointer lightuserdata object is used instead */ - lua_pushlightuserdata(l, NULL); - } - break;; - default: - json_throw_parse_error(l, json, "value", token); - } -} - -static int json_decode(lua_State *l) -{ - json_parse_t json; - json_token_t token; - size_t json_len; - - luaL_argcheck(l, lua_gettop(l) == 1, 1, "expected 1 argument"); - - json.cfg = json_fetch_config(l); - json.data = luaL_checklstring(l, 1, &json_len); - json.current_depth = 0; - json.ptr = json.data; - - /* Detect Unicode other than UTF-8 (see RFC 4627, Sec 3) - * - * CJSON can support any simple data type, hence only the first - * character is guaranteed to be ASCII (at worst: '"'). This is - * still enough to detect whether the wrong encoding is in use. */ - if (json_len >= 2 && (!json.data[0] || !json.data[1])) - luaL_error(l, "JSON parser does not support UTF-16 or UTF-32"); - - /* Ensure the temporary buffer can hold the entire string. - * This means we no longer need to do length checks since the decoded - * string must be smaller than the entire json string */ - json.tmp = strbuf_new((int)json_len); - - json_next_token(&json, &token); - json_process_value(l, &json, &token); - - /* Ensure there is no more input left */ - json_next_token(&json, &token); - - if (token.type != T_END) - json_throw_parse_error(l, &json, "the end", &token); - - strbuf_free(json.tmp); - - return 1; -} - -/* ===== INITIALISATION ===== */ - -#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 -/* Compatibility for Lua 5.1. - * - * luaL_setfuncs() is used to create a module table where the functions have - * json_config_t as their first upvalue. Code borrowed from Lua 5.2 source. */ -static void luaL_setfuncs (lua_State *l, const luaL_Reg *reg, int nup) -{ - int i; - - luaL_checkstack(l, nup, "too many upvalues"); - for (; reg->name != NULL; reg++) { /* fill the table with given functions */ - for (i = 0; i < nup; i++) /* copy upvalues to the top */ - lua_pushvalue(l, -nup); - lua_pushcclosure(l, reg->func, nup); /* closure with those upvalues */ - lua_setfield(l, -(nup + 2), reg->name); - } - lua_pop(l, nup); /* remove upvalues */ -} -#endif - -/* Call target function in protected mode with all supplied args. - * Assumes target function only returns a single non-nil value. - * Convert and return thrown errors as: nil, "error message" */ -static int json_protect_conversion(lua_State *l) -{ - int err; - - /* Deliberately throw an error for invalid arguments */ - luaL_argcheck(l, lua_gettop(l) == 1, 1, "expected 1 argument"); - - /* pcall() the function stored as upvalue(1) */ - lua_pushvalue(l, lua_upvalueindex(1)); - lua_insert(l, 1); - err = lua_pcall(l, 1, 1, 0); - if (!err) - return 1; - - if (err == LUA_ERRRUN) { - lua_pushnil(l); - lua_insert(l, -2); - return 2; - } - - /* Since we are not using a custom error handler, the only remaining - * errors are memory related */ - return luaL_error(l, "Memory allocation error in CJSON protected call"); -} - -/* Return cjson module table */ -static int lua_cjson_new(lua_State *l) -{ - luaL_Reg reg[] = { - { "encode", json_encode }, - { "decode", json_decode }, - { "encode_sparse_array", json_cfg_encode_sparse_array }, - { "encode_max_depth", json_cfg_encode_max_depth }, - { "decode_max_depth", json_cfg_decode_max_depth }, - { "encode_number_precision", json_cfg_encode_number_precision }, - { "encode_keep_buffer", json_cfg_encode_keep_buffer }, - { "encode_invalid_numbers", json_cfg_encode_invalid_numbers }, - { "decode_invalid_numbers", json_cfg_decode_invalid_numbers }, - { "decode_lua_nil", json_cfg_decode_lua_nil }, - { "new", lua_cjson_new }, - { NULL, NULL } - }; - - /* Initialise number conversions */ - fpconv_init(); - - /* cjson module table */ - lua_newtable(l); - - /* Register functions with config data as upvalue */ - json_create_config(l); - luaL_setfuncs(l, reg, 1); - - /* Set cjson.null */ - lua_pushlightuserdata(l, NULL); - lua_setfield(l, -2, "null"); - - /* Set module name / version fields */ - lua_pushliteral(l, CJSON_MODNAME); - lua_setfield(l, -2, "_NAME"); - lua_pushliteral(l, CJSON_VERSION); - lua_setfield(l, -2, "_VERSION"); - - return 1; -} - -/* Return cjson.safe module table */ -static int lua_cjson_safe_new(lua_State *l) -{ - const char *func[] = { "decode", "encode", NULL }; - int i; - - lua_cjson_new(l); - - /* Fix new() method */ - lua_pushcfunction(l, lua_cjson_safe_new); - lua_setfield(l, -2, "new"); - - for (i = 0; func[i]; i++) { - lua_getfield(l, -1, func[i]); - lua_pushcclosure(l, json_protect_conversion, 1); - lua_setfield(l, -2, func[i]); - } - - return 1; -} - -int luaopen_cjson(lua_State *l) -{ - lua_cjson_new(l); - -#ifdef ENABLE_CJSON_GLOBAL - /* Register a global "cjson" table. */ - lua_pushvalue(l, -1); - lua_setglobal(l, CJSON_MODNAME); -#endif - - /* Return cjson table */ - return 1; -} - -int luaopen_cjson_safe(lua_State *l) -{ - lua_cjson_safe_new(l); - - /* Return cjson.safe table */ - return 1; -} - -/* vi:ai et sw=4 ts=4: - */ diff --git a/sources/cjson/lua_cjson.h b/sources/cjson/lua_cjson.h deleted file mode 100644 index 4d3b1e76..00000000 --- a/sources/cjson/lua_cjson.h +++ /dev/null @@ -1,12 +0,0 @@ - -#ifndef __LUA_CJSON_H_ -#define __LUA_CJSON_H_ - -#include "lua.h" - -#define USE_INTERNAL_FPCONV - -int luaopen_cjson(lua_State *l); -int luaopen_cjson_safe(lua_State *l); - -#endif // __LUA_CJSON_H_ diff --git a/sources/cjson/strbuf.c b/sources/cjson/strbuf.c deleted file mode 100644 index f0f7f4b9..00000000 --- a/sources/cjson/strbuf.c +++ /dev/null @@ -1,251 +0,0 @@ -/* strbuf - String buffer routines - * - * Copyright (c) 2010-2012 Mark Pulford - * - * 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 -#include -#include -#include - -#include "strbuf.h" - -static void die(const char *fmt, ...) -{ - va_list arg; - - va_start(arg, fmt); - vfprintf(stderr, fmt, arg); - va_end(arg); - fprintf(stderr, "\n"); - - exit(-1); -} - -void strbuf_init(strbuf_t *s, int len) -{ - int size; - - if (len <= 0) - size = STRBUF_DEFAULT_SIZE; - else - size = len + 1; /* \0 terminator */ - - s->buf = NULL; - s->size = size; - s->length = 0; - s->increment = STRBUF_DEFAULT_INCREMENT; - s->dynamic = 0; - s->reallocs = 0; - s->debug = 0; - - s->buf = malloc(size); - if (!s->buf) - die("Out of memory"); - - strbuf_ensure_null(s); -} - -strbuf_t *strbuf_new(int len) -{ - strbuf_t *s; - - s = malloc(sizeof(strbuf_t)); - if (!s) - die("Out of memory"); - - strbuf_init(s, len); - - /* Dynamic strbuf allocation / deallocation */ - s->dynamic = 1; - - return s; -} - -void strbuf_set_increment(strbuf_t *s, int increment) -{ - /* Increment > 0: Linear buffer growth rate - * Increment < -1: Exponential buffer growth rate */ - if (increment == 0 || increment == -1) - die("BUG: Invalid string increment"); - - s->increment = increment; -} - -static inline void debug_stats(strbuf_t *s) -{ - if (s->debug) { - fprintf(stderr, "strbuf(%lx) reallocs: %d, length: %d, size: %d\n", - (long)s, s->reallocs, s->length, s->size); - } -} - -/* If strbuf_t has not been dynamically allocated, strbuf_free() can - * be called any number of times strbuf_init() */ -void strbuf_free(strbuf_t *s) -{ - debug_stats(s); - - if (s->buf) { - free(s->buf); - s->buf = NULL; - } - if (s->dynamic) - free(s); -} - -char *strbuf_free_to_string(strbuf_t *s, int *len) -{ - char *buf; - - debug_stats(s); - - strbuf_ensure_null(s); - - buf = s->buf; - if (len) - *len = s->length; - - if (s->dynamic) - free(s); - - return buf; -} - -static int calculate_new_size(strbuf_t *s, int len) -{ - int reqsize, newsize; - - if (len <= 0) - die("BUG: Invalid strbuf length requested"); - - /* Ensure there is room for optional NULL termination */ - reqsize = len + 1; - - /* If the user has requested to shrink the buffer, do it exactly */ - if (s->size > reqsize) - return reqsize; - - newsize = s->size; - if (s->increment < 0) { - /* Exponential sizing */ - while (newsize < reqsize) - newsize *= -s->increment; - } else { - /* Linear sizing */ - newsize = ((newsize + s->increment - 1) / s->increment) * s->increment; - } - - return newsize; -} - - -/* Ensure strbuf can handle a string length bytes long (ignoring NULL - * optional termination). */ -void strbuf_resize(strbuf_t *s, int len) -{ - int newsize; - - newsize = calculate_new_size(s, len); - - if (s->debug > 1) { - fprintf(stderr, "strbuf(%lx) resize: %d => %d\n", - (long)s, s->size, newsize); - } - - s->size = newsize; - s->buf = realloc(s->buf, s->size); - if (!s->buf) - die("Out of memory"); - s->reallocs++; -} - -void strbuf_append_string(strbuf_t *s, const char *str) -{ - int space, i; - - space = strbuf_empty_length(s); - - for (i = 0; str[i]; i++) { - if (space < 1) { - strbuf_resize(s, s->length + 1); - space = strbuf_empty_length(s); - } - - s->buf[s->length] = str[i]; - s->length++; - space--; - } -} - -/* strbuf_append_fmt() should only be used when an upper bound - * is known for the output string. */ -void strbuf_append_fmt(strbuf_t *s, int len, const char *fmt, ...) -{ - va_list arg; - int fmt_len; - - strbuf_ensure_empty_length(s, len); - - va_start(arg, fmt); - fmt_len = vsnprintf(s->buf + s->length, len, fmt, arg); - va_end(arg); - - if (fmt_len < 0) - die("BUG: Unable to convert number"); /* This should never happen.. */ - - s->length += fmt_len; -} - -/* strbuf_append_fmt_retry() can be used when the there is no known - * upper bound for the output string. */ -void strbuf_append_fmt_retry(strbuf_t *s, const char *fmt, ...) -{ - va_list arg; - int fmt_len, try; - int empty_len; - - /* If the first attempt to append fails, resize the buffer appropriately - * and try again */ - for (try = 0; ; try++) { - va_start(arg, fmt); - /* Append the new formatted string */ - /* fmt_len is the length of the string required, excluding the - * trailing NULL */ - empty_len = strbuf_empty_length(s); - /* Add 1 since there is also space to store the terminating NULL. */ - fmt_len = vsnprintf(s->buf + s->length, empty_len + 1, fmt, arg); - va_end(arg); - - if (fmt_len <= empty_len) - break; /* SUCCESS */ - if (try > 0) - die("BUG: length of formatted string changed"); - - strbuf_resize(s, s->length + fmt_len); - } - - s->length += fmt_len; -} - -/* vi:ai et sw=4 ts=4: - */ diff --git a/sources/cjson/strbuf.h b/sources/cjson/strbuf.h deleted file mode 100644 index eb09da9f..00000000 --- a/sources/cjson/strbuf.h +++ /dev/null @@ -1,160 +0,0 @@ -/* strbuf - String buffer routines - * - * Copyright (c) 2010-2012 Mark Pulford - * - * 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 -#include - -/* Size: Total bytes allocated to *buf - * Length: String length, excluding optional NULL terminator. - * Increment: Allocation increments when resizing the string buffer. - * Dynamic: True if created via strbuf_new() - */ - -typedef struct { - char *buf; - int size; - int length; - int increment; - int dynamic; - int reallocs; - int debug; -} strbuf_t; - -#ifndef STRBUF_DEFAULT_SIZE -#define STRBUF_DEFAULT_SIZE 1023 -#endif -#ifndef STRBUF_DEFAULT_INCREMENT -#define STRBUF_DEFAULT_INCREMENT -2 -#endif - -/* Initialise */ -extern strbuf_t *strbuf_new(int len); -extern void strbuf_init(strbuf_t *s, int len); -extern void strbuf_set_increment(strbuf_t *s, int increment); - -/* Release */ -extern void strbuf_free(strbuf_t *s); -extern char *strbuf_free_to_string(strbuf_t *s, int *len); - -/* Management */ -extern void strbuf_resize(strbuf_t *s, int len); -static int strbuf_empty_length(strbuf_t *s); -static int strbuf_length(strbuf_t *s); -static char *strbuf_string(strbuf_t *s, int *len); -static void strbuf_ensure_empty_length(strbuf_t *s, int len); -static char *strbuf_empty_ptr(strbuf_t *s); -static void strbuf_extend_length(strbuf_t *s, int len); - -/* Update */ -extern void strbuf_append_fmt(strbuf_t *s, int len, const char *fmt, ...); -extern void strbuf_append_fmt_retry(strbuf_t *s, const char *format, ...); -static void strbuf_append_mem(strbuf_t *s, const char *c, int len); -extern void strbuf_append_string(strbuf_t *s, const char *str); -static void strbuf_append_char(strbuf_t *s, const char c); -static void strbuf_ensure_null(strbuf_t *s); - -#ifdef _MSC_VER -#define snprintf _snprintf -#undef inline -#define inline __inline -#endif - -/* Reset string for before use */ -static inline void strbuf_reset(strbuf_t *s) -{ - s->length = 0; -} - -static inline int strbuf_allocated(strbuf_t *s) -{ - return s->buf != NULL; -} - -/* Return bytes remaining in the string buffer - * Ensure there is space for a NULL terminator. */ -static inline int strbuf_empty_length(strbuf_t *s) -{ - return s->size - s->length - 1; -} - -static inline void strbuf_ensure_empty_length(strbuf_t *s, int len) -{ - if (len > strbuf_empty_length(s)) - strbuf_resize(s, s->length + len); -} - -static inline char *strbuf_empty_ptr(strbuf_t *s) -{ - return s->buf + s->length; -} - -static inline void strbuf_extend_length(strbuf_t *s, int len) -{ - s->length += len; -} - -static inline int strbuf_length(strbuf_t *s) -{ - return s->length; -} - -static inline void strbuf_append_char(strbuf_t *s, const char c) -{ - strbuf_ensure_empty_length(s, 1); - s->buf[s->length++] = c; -} - -static inline void strbuf_append_char_unsafe(strbuf_t *s, const char c) -{ - s->buf[s->length++] = c; -} - -static inline void strbuf_append_mem(strbuf_t *s, const char *c, int len) -{ - strbuf_ensure_empty_length(s, len); - memcpy(s->buf + s->length, c, len); - s->length += len; -} - -static inline void strbuf_append_mem_unsafe(strbuf_t *s, const char *c, int len) -{ - memcpy(s->buf + s->length, c, len); - s->length += len; -} - -static inline void strbuf_ensure_null(strbuf_t *s) -{ - s->buf[s->length] = 0; -} - -static inline char *strbuf_string(strbuf_t *s, int *len) -{ - if (len) - *len = s->length; - - return s->buf; -} - -/* vi:ai et sw=4 ts=4: - */ diff --git a/sources/clipper/CMakeLists.txt b/sources/clipper/CMakeLists.txt deleted file mode 100644 index 9342e0a3..00000000 --- a/sources/clipper/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ - -add_library(clipper - ${CMAKE_CURRENT_LIST_DIR}/clipper.hpp - ${CMAKE_CURRENT_LIST_DIR}/clipper.cpp -) - -target_include_directories(clipper PUBLIC ${CMAKE_CURRENT_LIST_DIR}) \ No newline at end of file diff --git a/sources/clipper/clipper.cpp b/sources/clipper/clipper.cpp deleted file mode 100644 index df12aa63..00000000 --- a/sources/clipper/clipper.cpp +++ /dev/null @@ -1,4610 +0,0 @@ -/******************************************************************************* -* * -* Author : Angus Johnson * -* Version : 6.1.3a * -* Date : 22 January 2014 * -* Website : http://www.angusj.com * -* Copyright : Angus Johnson 2010-2014 * -* * -* License: * -* Use, modification & distribution is subject to Boost Software License Ver 1. * -* http://www.boost.org/LICENSE_1_0.txt * -* * -* Attributions: * -* The code in this library is an extension of Bala Vatti's clipping algorithm: * -* "A generic solution to polygon clipping" * -* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. * -* http://portal.acm.org/citation.cfm?id=129906 * -* * -* Computer graphics and geometric modeling: implementation and algorithms * -* By Max K. Agoston * -* Springer; 1 edition (January 4, 2005) * -* http://books.google.com/books?q=vatti+clipping+agoston * -* * -* See also: * -* "Polygon Offsetting by Computing Winding Numbers" * -* Paper no. DETC2005-85513 pp. 565-575 * -* ASME 2005 International Design Engineering Technical Conferences * -* and Computers and Information in Engineering Conference (IDETC/CIE2005) * -* September 24-28, 2005 , Long Beach, California, USA * -* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * -* * -*******************************************************************************/ - -/******************************************************************************* -* * -* This is a translation of the Delphi Clipper library and the naming style * -* used has retained a Delphi flavour. * -* * -*******************************************************************************/ - -#include "clipper.hpp" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ClipperLib { - -#ifdef use_int32 - static cInt const loRange = 46340; - static cInt const hiRange = 46340; -#else - static cInt const loRange = 0x3FFFFFFF; - static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL; - typedef unsigned long long ulong64; -#endif - -static double const pi = 3.141592653589793238; -static double const two_pi = pi *2; -static double const def_arc_tolerance = 0.25; - -enum Direction { dRightToLeft, dLeftToRight }; - -static int const Unassigned = -1; //edge not currently 'owning' a solution -static int const Skip = -2; //edge that would otherwise close a path - -#define HORIZONTAL (-1.0E+40) -#define TOLERANCE (1.0e-20) -#define NEAR_ZERO(val) (((val) > -TOLERANCE) && ((val) < TOLERANCE)) - -struct TEdge { - IntPoint Bot; - IntPoint Curr; - IntPoint Top; - IntPoint Delta; - double Dx; - PolyType PolyTyp; - EdgeSide Side; - int WindDelta; //1 or -1 depending on winding direction - int WindCnt; - int WindCnt2; //winding count of the opposite polytype - int OutIdx; - TEdge *Next; - TEdge *Prev; - TEdge *NextInLML; - TEdge *NextInAEL; - TEdge *PrevInAEL; - TEdge *NextInSEL; - TEdge *PrevInSEL; -}; - -struct IntersectNode { - TEdge *Edge1; - TEdge *Edge2; - IntPoint Pt; -}; - -struct LocalMinima { - cInt Y; - TEdge *LeftBound; - TEdge *RightBound; - LocalMinima *Next; -}; - -struct OutPt; - -struct OutRec { - int Idx; - bool IsHole; - bool IsOpen; - OutRec *FirstLeft; //see comments in clipper.pas - PolyNode *PolyNd; - OutPt *Pts; - OutPt *BottomPt; -}; - -struct OutPt { - int Idx; - IntPoint Pt; - OutPt *Next; - OutPt *Prev; -}; - -struct Join { - OutPt *OutPt1; - OutPt *OutPt2; - IntPoint OffPt; -}; - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ - -inline cInt Round(double val) -{ - if ((val < 0)) return static_cast(val - 0.5); - else return static_cast(val + 0.5); -} -//------------------------------------------------------------------------------ - -inline cInt Abs(cInt val) -{ - return val < 0 ? -val : val; -} - -//------------------------------------------------------------------------------ -// PolyTree methods ... -//------------------------------------------------------------------------------ - -void PolyTree::Clear() -{ - for (PolyNodes::size_type i = 0; i < AllNodes.size(); ++i) - delete AllNodes[i]; - AllNodes.resize(0); - Childs.resize(0); -} -//------------------------------------------------------------------------------ - -PolyNode* PolyTree::GetFirst() const -{ - if (!Childs.empty()) - return Childs[0]; - else - return 0; -} -//------------------------------------------------------------------------------ - -int PolyTree::Total() const -{ - return (int)AllNodes.size(); -} - -//------------------------------------------------------------------------------ -// PolyNode methods ... -//------------------------------------------------------------------------------ - -PolyNode::PolyNode(): Childs(), Parent(0), Index(0), m_IsOpen(false) -{ -} -//------------------------------------------------------------------------------ - -int PolyNode::ChildCount() const -{ - return (int)Childs.size(); -} -//------------------------------------------------------------------------------ - -void PolyNode::AddChild(PolyNode& child) -{ - unsigned cnt = (unsigned)Childs.size(); - Childs.push_back(&child); - child.Parent = this; - child.Index = cnt; -} -//------------------------------------------------------------------------------ - -PolyNode* PolyNode::GetNext() const -{ - if (!Childs.empty()) - return Childs[0]; - else - return GetNextSiblingUp(); -} -//------------------------------------------------------------------------------ - -PolyNode* PolyNode::GetNextSiblingUp() const -{ - if (!Parent) //protects against PolyTree.GetNextSiblingUp() - return 0; - else if (Index == Parent->Childs.size() - 1) - return Parent->GetNextSiblingUp(); - else - return Parent->Childs[Index + 1]; -} -//------------------------------------------------------------------------------ - -bool PolyNode::IsHole() const -{ - bool result = true; - PolyNode* node = Parent; - while (node) - { - result = !result; - node = node->Parent; - } - return result; -} -//------------------------------------------------------------------------------ - -bool PolyNode::IsOpen() const -{ - return m_IsOpen; -} -//------------------------------------------------------------------------------ - -#ifndef use_int32 - -//------------------------------------------------------------------------------ -// Int128 class (enables safe math on signed 64bit integers) -// eg Int128 val1((cInt)9223372036854775807); //ie 2^63 -1 -// Int128 val2((cInt)9223372036854775807); -// Int128 val3 = val1 * val2; -// val3.AsString => "85070591730234615847396907784232501249" (8.5e+37) -//------------------------------------------------------------------------------ - -class Int128 -{ - public: - - cUInt lo; - cInt hi; - - Int128(cInt _lo = 0) - { - lo = (cUInt)_lo; - if (_lo < 0) hi = -1; else hi = 0; - } - - - Int128(const Int128 &val): lo(val.lo), hi(val.hi){} - - Int128(const cInt& _hi, const ulong64& _lo): lo(_lo), hi(_hi){} - - Int128& operator = (const cInt &val) - { - lo = (ulong64)val; - if (val < 0) hi = -1; else hi = 0; - return *this; - } - - bool operator == (const Int128 &val) const - {return (hi == val.hi && lo == val.lo);} - - bool operator != (const Int128 &val) const - { return !(*this == val);} - - bool operator > (const Int128 &val) const - { - if (hi != val.hi) - return hi > val.hi; - else - return lo > val.lo; - } - - bool operator < (const Int128 &val) const - { - if (hi != val.hi) - return hi < val.hi; - else - return lo < val.lo; - } - - bool operator >= (const Int128 &val) const - { return !(*this < val);} - - bool operator <= (const Int128 &val) const - { return !(*this > val);} - - Int128& operator += (const Int128 &rhs) - { - hi += rhs.hi; - lo += rhs.lo; - if (lo < rhs.lo) hi++; - return *this; - } - - Int128 operator + (const Int128 &rhs) const - { - Int128 result(*this); - result+= rhs; - return result; - } - - Int128& operator -= (const Int128 &rhs) - { - *this += -rhs; - return *this; - } - - Int128 operator - (const Int128 &rhs) const - { - Int128 result(*this); - result -= rhs; - return result; - } - - Int128 operator-() const //unary negation - { - if (lo == 0) - return Int128(-hi,0); - else - return Int128(~hi,~lo +1); - } - - Int128 operator/ (const Int128 &rhs) const - { - if (rhs.lo == 0 && rhs.hi == 0) - throw "Int128 operator/: divide by zero"; - - bool negate = (rhs.hi < 0) != (hi < 0); - Int128 dividend = *this; - Int128 divisor = rhs; - if (dividend.hi < 0) dividend = -dividend; - if (divisor.hi < 0) divisor = -divisor; - - if (divisor < dividend) - { - Int128 result = Int128(0); - Int128 cntr = Int128(1); - while (divisor.hi >= 0 && !(divisor > dividend)) - { - divisor.hi <<= 1; - if ((cInt)divisor.lo < 0) divisor.hi++; - divisor.lo <<= 1; - - cntr.hi <<= 1; - if ((cInt)cntr.lo < 0) cntr.hi++; - cntr.lo <<= 1; - } - divisor.lo >>= 1; - if ((divisor.hi & 1) == 1) - divisor.lo |= 0x8000000000000000LL; - divisor.hi = (ulong64)divisor.hi >> 1; - - cntr.lo >>= 1; - if ((cntr.hi & 1) == 1) - cntr.lo |= 0x8000000000000000LL; - cntr.hi >>= 1; - - while (cntr.hi != 0 || cntr.lo != 0) - { - if (!(dividend < divisor)) - { - dividend -= divisor; - result.hi |= cntr.hi; - result.lo |= cntr.lo; - } - divisor.lo >>= 1; - if ((divisor.hi & 1) == 1) - divisor.lo |= 0x8000000000000000LL; - divisor.hi >>= 1; - - cntr.lo >>= 1; - if ((cntr.hi & 1) == 1) - cntr.lo |= 0x8000000000000000LL; - cntr.hi >>= 1; - } - if (negate) result = -result; - return result; - } - else if (rhs.hi == this->hi && rhs.lo == this->lo) - return Int128(negate ? -1: 1); - else - return Int128(0); - } - - double AsDouble() const - { - const double shift64 = 18446744073709551616.0; //2^64 - if (hi < 0) - { - cUInt lo_ = ~lo + 1; - if (lo_ == 0) return (double)hi * shift64; - else return -(double)(lo_ + ~hi * shift64); - } - else - return (double)(lo + hi * shift64); - } - -}; -//------------------------------------------------------------------------------ - -Int128 Int128Mul (cInt lhs, cInt rhs) -{ - bool negate = (lhs < 0) != (rhs < 0); - - if (lhs < 0) lhs = -lhs; - ulong64 int1Hi = ulong64(lhs) >> 32; - ulong64 int1Lo = ulong64(lhs & 0xFFFFFFFF); - - if (rhs < 0) rhs = -rhs; - ulong64 int2Hi = ulong64(rhs) >> 32; - ulong64 int2Lo = ulong64(rhs & 0xFFFFFFFF); - - //nb: see comments in clipper.pas - ulong64 a = int1Hi * int2Hi; - ulong64 b = int1Lo * int2Lo; - ulong64 c = int1Hi * int2Lo + int1Lo * int2Hi; - - Int128 tmp; - tmp.hi = cInt(a + (c >> 32)); - tmp.lo = cInt(c << 32); - tmp.lo += cInt(b); - if (tmp.lo < b) tmp.hi++; - if (negate) tmp = -tmp; - return tmp; -}; -#endif - -//------------------------------------------------------------------------------ -// Miscellaneous global functions -//------------------------------------------------------------------------------ - -bool Orientation(const Path &poly) -{ - return Area(poly) >= 0; -} -//------------------------------------------------------------------------------ - -double Area(const Path &poly) -{ - int size = (int)poly.size(); - if (size < 3) return 0; - - double a = 0; - for (int i = 0, j = size -1; i < size; ++i) - { - a += ((double)poly[j].X + poly[i].X) * ((double)poly[j].Y - poly[i].Y); - j = i; - } - return -a * 0.5; -} -//------------------------------------------------------------------------------ - -double Area(const OutRec &outRec) -{ - OutPt *op = outRec.Pts; - if (!op) return 0; - double a = 0; - do { - a += (double)(op->Prev->Pt.X + op->Pt.X) * (double)(op->Prev->Pt.Y - op->Pt.Y); - op = op->Next; - } while (op != outRec.Pts); - return a * 0.5; -} -//------------------------------------------------------------------------------ - -bool PointIsVertex(const IntPoint &Pt, OutPt *pp) -{ - OutPt *pp2 = pp; - do - { - if (pp2->Pt == Pt) return true; - pp2 = pp2->Next; - } - while (pp2 != pp); - return false; -} -//------------------------------------------------------------------------------ - -int PointInPolygon (const IntPoint &pt, const Path &path) -{ - //returns 0 if false, +1 if true, -1 if pt ON polygon boundary - //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf - int result = 0; - size_t cnt = path.size(); - if (cnt < 3) return 0; - IntPoint ip = path[0]; - for(size_t i = 1; i <= cnt; ++i) - { - IntPoint ipNext = (i == cnt ? path[0] : path[i]); - if (ipNext.Y == pt.Y) - { - if ((ipNext.X == pt.X) || (ip.Y == pt.Y && - ((ipNext.X > pt.X) == (ip.X < pt.X)))) return -1; - } - if ((ip.Y < pt.Y) != (ipNext.Y < pt.Y)) - { - if (ip.X >= pt.X) - { - if (ipNext.X > pt.X) result = 1 - result; - else - { - double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - - (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); - if (!d) return -1; - if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; - } - } else - { - if (ipNext.X > pt.X) - { - double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - - (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); - if (!d) return -1; - if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; - } - } - } - ip = ipNext; - } - return result; -} -//------------------------------------------------------------------------------ - -int PointInPolygon (const IntPoint &pt, OutPt *op) -{ - //returns 0 if false, +1 if true, -1 if pt ON polygon boundary - //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf - int result = 0; - OutPt* startOp = op; - for(;;) - { - if (op->Next->Pt.Y == pt.Y) - { - if ((op->Next->Pt.X == pt.X) || (op->Pt.Y == pt.Y && - ((op->Next->Pt.X > pt.X) == (op->Pt.X < pt.X)))) return -1; - } - if ((op->Pt.Y < pt.Y) != (op->Next->Pt.Y < pt.Y)) - { - if (op->Pt.X >= pt.X) - { - if (op->Next->Pt.X > pt.X) result = 1 - result; - else - { - double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) - - (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y); - if (!d) return -1; - if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result; - } - } else - { - if (op->Next->Pt.X > pt.X) - { - double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) - - (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y); - if (!d) return -1; - if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result; - } - } - } - op = op->Next; - if (startOp == op) break; - } - return result; -} -//------------------------------------------------------------------------------ - -bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2) -{ - OutPt* op = OutPt1; - do - { - int res = PointInPolygon(op->Pt, OutPt2); - if (res >= 0) return res != 0; - op = op->Next; - } - while (op != OutPt1); - return true; -} -//---------------------------------------------------------------------- - -bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range) -{ -#ifndef use_int32 - if (UseFullInt64Range) - return Int128Mul(e1.Delta.Y, e2.Delta.X) == Int128Mul(e1.Delta.X, e2.Delta.Y); - else -#endif - return e1.Delta.Y * e2.Delta.X == e1.Delta.X * e2.Delta.Y; -} -//------------------------------------------------------------------------------ - -bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, - const IntPoint pt3, bool UseFullInt64Range) -{ -#ifndef use_int32 - if (UseFullInt64Range) - return Int128Mul(pt1.Y-pt2.Y, pt2.X-pt3.X) == Int128Mul(pt1.X-pt2.X, pt2.Y-pt3.Y); - else -#endif - return (pt1.Y-pt2.Y)*(pt2.X-pt3.X) == (pt1.X-pt2.X)*(pt2.Y-pt3.Y); -} -//------------------------------------------------------------------------------ - -bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, - const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range) -{ -#ifndef use_int32 - if (UseFullInt64Range) - return Int128Mul(pt1.Y-pt2.Y, pt3.X-pt4.X) == Int128Mul(pt1.X-pt2.X, pt3.Y-pt4.Y); - else -#endif - return (pt1.Y-pt2.Y)*(pt3.X-pt4.X) == (pt1.X-pt2.X)*(pt3.Y-pt4.Y); -} -//------------------------------------------------------------------------------ - -inline bool IsHorizontal(TEdge &e) -{ - return e.Delta.Y == 0; -} -//------------------------------------------------------------------------------ - -inline double GetDx(const IntPoint pt1, const IntPoint pt2) -{ - return (pt1.Y == pt2.Y) ? - HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y); -} -//--------------------------------------------------------------------------- - -inline void SetDx(TEdge &e) -{ - e.Delta.X = (e.Top.X - e.Bot.X); - e.Delta.Y = (e.Top.Y - e.Bot.Y); - - if (e.Delta.Y == 0) e.Dx = HORIZONTAL; - else e.Dx = (double)(e.Delta.X) / e.Delta.Y; -} -//--------------------------------------------------------------------------- - -inline void SwapSides(TEdge &Edge1, TEdge &Edge2) -{ - EdgeSide Side = Edge1.Side; - Edge1.Side = Edge2.Side; - Edge2.Side = Side; -} -//------------------------------------------------------------------------------ - -inline void SwapPolyIndexes(TEdge &Edge1, TEdge &Edge2) -{ - int OutIdx = Edge1.OutIdx; - Edge1.OutIdx = Edge2.OutIdx; - Edge2.OutIdx = OutIdx; -} -//------------------------------------------------------------------------------ - -inline cInt TopX(TEdge &edge, const cInt currentY) -{ - return ( currentY == edge.Top.Y ) ? - edge.Top.X : edge.Bot.X + Round(edge.Dx *(currentY - edge.Bot.Y)); -} -//------------------------------------------------------------------------------ - -bool IntersectPoint(TEdge &Edge1, TEdge &Edge2, - IntPoint &ip, bool UseFullInt64Range) -{ -#ifdef use_xyz - ip.Z = 0; -#endif - double b1, b2; - //nb: with very large coordinate values, it's possible for SlopesEqual() to - //return false but for the edge.Dx value be equal due to double precision rounding. - if (SlopesEqual(Edge1, Edge2, UseFullInt64Range) || Edge1.Dx == Edge2.Dx) - { - if (Edge2.Bot.Y > Edge1.Bot.Y) ip = Edge2.Bot; - else ip = Edge1.Bot; - return false; - } - else if (Edge1.Delta.X == 0) - { - ip.X = Edge1.Bot.X; - if (IsHorizontal(Edge2)) - ip.Y = Edge2.Bot.Y; - else - { - b2 = Edge2.Bot.Y - (Edge2.Bot.X / Edge2.Dx); - ip.Y = Round(ip.X / Edge2.Dx + b2); - } - } - else if (Edge2.Delta.X == 0) - { - ip.X = Edge2.Bot.X; - if (IsHorizontal(Edge1)) - ip.Y = Edge1.Bot.Y; - else - { - b1 = Edge1.Bot.Y - (Edge1.Bot.X / Edge1.Dx); - ip.Y = Round(ip.X / Edge1.Dx + b1); - } - } - else - { - b1 = Edge1.Bot.X - Edge1.Bot.Y * Edge1.Dx; - b2 = Edge2.Bot.X - Edge2.Bot.Y * Edge2.Dx; - double q = (b2-b1) / (Edge1.Dx - Edge2.Dx); - ip.Y = Round(q); - if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx)) - ip.X = Round(Edge1.Dx * q + b1); - else - ip.X = Round(Edge2.Dx * q + b2); - } - - if (ip.Y < Edge1.Top.Y || ip.Y < Edge2.Top.Y) - { - if (Edge1.Top.Y > Edge2.Top.Y) - ip.Y = Edge1.Top.Y; - else - ip.Y = Edge2.Top.Y; - if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx)) - ip.X = TopX(Edge1, ip.Y); - else - ip.X = TopX(Edge2, ip.Y); - } - return true; -} -//------------------------------------------------------------------------------ - -void ReversePolyPtLinks(OutPt *pp) -{ - if (!pp) return; - OutPt *pp1, *pp2; - pp1 = pp; - do { - pp2 = pp1->Next; - pp1->Next = pp1->Prev; - pp1->Prev = pp2; - pp1 = pp2; - } while( pp1 != pp ); -} -//------------------------------------------------------------------------------ - -void DisposeOutPts(OutPt*& pp) -{ - if (pp == 0) return; - pp->Prev->Next = 0; - while( pp ) - { - OutPt *tmpPp = pp; - pp = pp->Next; - delete tmpPp; - } -} -//------------------------------------------------------------------------------ - -inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt) -{ - std::memset(e, 0, sizeof(TEdge)); - e->Next = eNext; - e->Prev = ePrev; - e->Curr = Pt; - e->OutIdx = Unassigned; -} -//------------------------------------------------------------------------------ - -void InitEdge2(TEdge& e, PolyType Pt) -{ - if (e.Curr.Y >= e.Next->Curr.Y) - { - e.Bot = e.Curr; - e.Top = e.Next->Curr; - } else - { - e.Top = e.Curr; - e.Bot = e.Next->Curr; - } - SetDx(e); - e.PolyTyp = Pt; -} -//------------------------------------------------------------------------------ - -TEdge* RemoveEdge(TEdge* e) -{ - //removes e from double_linked_list (but without removing from memory) - e->Prev->Next = e->Next; - e->Next->Prev = e->Prev; - TEdge* result = e->Next; - e->Prev = 0; //flag as removed (see ClipperBase.Clear) - return result; -} -//------------------------------------------------------------------------------ - -inline void ReverseHorizontal(TEdge &e) -{ - //swap horizontal edges' Top and Bottom x's so they follow the natural - //progression of the bounds - ie so their xbots will align with the - //adjoining lower edge. [Helpful in the ProcessHorizontal() method.] - cInt tmp = e.Top.X; - e.Top.X = e.Bot.X; - e.Bot.X = tmp; -#ifdef use_xyz - tmp = e.Top.Z; - e.Top.Z = e.Bot.Z; - e.Bot.Z = tmp; -#endif -} -//------------------------------------------------------------------------------ - -void SwapPoints(IntPoint &pt1, IntPoint &pt2) -{ - IntPoint tmp = pt1; - pt1 = pt2; - pt2 = tmp; -} -//------------------------------------------------------------------------------ - -bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a, - IntPoint pt2b, IntPoint &pt1, IntPoint &pt2) -{ - //precondition: segments are Collinear. - if (Abs(pt1a.X - pt1b.X) > Abs(pt1a.Y - pt1b.Y)) - { - if (pt1a.X > pt1b.X) SwapPoints(pt1a, pt1b); - if (pt2a.X > pt2b.X) SwapPoints(pt2a, pt2b); - if (pt1a.X > pt2a.X) pt1 = pt1a; else pt1 = pt2a; - if (pt1b.X < pt2b.X) pt2 = pt1b; else pt2 = pt2b; - return pt1.X < pt2.X; - } else - { - if (pt1a.Y < pt1b.Y) SwapPoints(pt1a, pt1b); - if (pt2a.Y < pt2b.Y) SwapPoints(pt2a, pt2b); - if (pt1a.Y < pt2a.Y) pt1 = pt1a; else pt1 = pt2a; - if (pt1b.Y > pt2b.Y) pt2 = pt1b; else pt2 = pt2b; - return pt1.Y > pt2.Y; - } -} -//------------------------------------------------------------------------------ - -bool FirstIsBottomPt(const OutPt* btmPt1, const OutPt* btmPt2) -{ - OutPt *p = btmPt1->Prev; - while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Prev; - double dx1p = std::fabs(GetDx(btmPt1->Pt, p->Pt)); - p = btmPt1->Next; - while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Next; - double dx1n = std::fabs(GetDx(btmPt1->Pt, p->Pt)); - - p = btmPt2->Prev; - while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Prev; - double dx2p = std::fabs(GetDx(btmPt2->Pt, p->Pt)); - p = btmPt2->Next; - while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Next; - double dx2n = std::fabs(GetDx(btmPt2->Pt, p->Pt)); - return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n); -} -//------------------------------------------------------------------------------ - -OutPt* GetBottomPt(OutPt *pp) -{ - OutPt* dups = 0; - OutPt* p = pp->Next; - while (p != pp) - { - if (p->Pt.Y > pp->Pt.Y) - { - pp = p; - dups = 0; - } - else if (p->Pt.Y == pp->Pt.Y && p->Pt.X <= pp->Pt.X) - { - if (p->Pt.X < pp->Pt.X) - { - dups = 0; - pp = p; - } else - { - if (p->Next != pp && p->Prev != pp) dups = p; - } - } - p = p->Next; - } - if (dups) - { - //there appears to be at least 2 vertices at BottomPt so ... - while (dups != p) - { - if (!FirstIsBottomPt(p, dups)) pp = dups; - dups = dups->Next; - while (dups->Pt != pp->Pt) dups = dups->Next; - } - } - return pp; -} -//------------------------------------------------------------------------------ - -bool FindSegment(OutPt* &pp, bool UseFullInt64Range, - IntPoint &pt1, IntPoint &pt2) -{ - //OutPt1 & OutPt2 => the overlap segment (if the function returns true) - if (!pp) return false; - OutPt* pp2 = pp; - IntPoint pt1a = pt1, pt2a = pt2; - do - { - if (SlopesEqual(pt1a, pt2a, pp->Pt, pp->Prev->Pt, UseFullInt64Range) && - SlopesEqual(pt1a, pt2a, pp->Pt, UseFullInt64Range) && - GetOverlapSegment(pt1a, pt2a, pp->Pt, pp->Prev->Pt, pt1, pt2)) - return true; - pp = pp->Next; - } - while (pp != pp2); - return false; -} -//------------------------------------------------------------------------------ - -bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1, - const IntPoint pt2, const IntPoint pt3) -{ - if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2)) - return false; - else if (pt1.X != pt3.X) - return (pt2.X > pt1.X) == (pt2.X < pt3.X); - else - return (pt2.Y > pt1.Y) == (pt2.Y < pt3.Y); -} -//------------------------------------------------------------------------------ - -OutPt* InsertPolyPtBetween(OutPt* p1, OutPt* p2, const IntPoint Pt) -{ - if (p1 == p2) throw "JoinError"; - OutPt* result = new OutPt; - result->Pt = Pt; - if (p2 == p1->Next) - { - p1->Next = result; - p2->Prev = result; - result->Next = p2; - result->Prev = p1; - } else - { - p2->Next = result; - p1->Prev = result; - result->Next = p1; - result->Prev = p2; - } - return result; -} -//------------------------------------------------------------------------------ - -bool HorzSegmentsOverlap(const IntPoint& pt1a, const IntPoint& pt1b, - const IntPoint& pt2a, const IntPoint& pt2b) -{ - //precondition: both segments are horizontal - if ((pt1a.X > pt2a.X) == (pt1a.X < pt2b.X)) return true; - else if ((pt1b.X > pt2a.X) == (pt1b.X < pt2b.X)) return true; - else if ((pt2a.X > pt1a.X) == (pt2a.X < pt1b.X)) return true; - else if ((pt2b.X > pt1a.X) == (pt2b.X < pt1b.X)) return true; - else if ((pt1a.X == pt2a.X) && (pt1b.X == pt2b.X)) return true; - else if ((pt1a.X == pt2b.X) && (pt1b.X == pt2a.X)) return true; - else return false; -} - - -//------------------------------------------------------------------------------ -// ClipperBase class methods ... -//------------------------------------------------------------------------------ - -ClipperBase::ClipperBase() //constructor -{ - m_MinimaList = 0; - m_CurrentLM = 0; - m_UseFullRange = false; -} -//------------------------------------------------------------------------------ - -ClipperBase::~ClipperBase() //destructor -{ - Clear(); -} -//------------------------------------------------------------------------------ - -void RangeTest(const IntPoint& Pt, bool& useFullRange) -{ - if (useFullRange) - { - if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange) - throw "Coordinate outside allowed range"; - } - else if (Pt.X > loRange|| Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange) - { - useFullRange = true; - RangeTest(Pt, useFullRange); - } -} -//------------------------------------------------------------------------------ - -TEdge* FindNextLocMin(TEdge* E) -{ - for (;;) - { - while (E->Bot != E->Prev->Bot || E->Curr == E->Top) E = E->Next; - if (!IsHorizontal(*E) && !IsHorizontal(*E->Prev)) break; - while (IsHorizontal(*E->Prev)) E = E->Prev; - TEdge* E2 = E; - while (IsHorizontal(*E)) E = E->Next; - if (E->Top.Y == E->Prev->Bot.Y) continue; //ie just an intermediate horz. - if (E2->Prev->Bot.X < E->Bot.X) E = E2; - break; - } - return E; -} -//------------------------------------------------------------------------------ - -TEdge* ClipperBase::ProcessBound(TEdge* E, bool IsClockwise) -{ - TEdge *EStart = E, *Result = E; - TEdge *Horz = 0; - cInt StartX; - if (IsHorizontal(*E)) - { - //it's possible for adjacent overlapping horz edges to start heading left - //before finishing right, so ... - if (IsClockwise) StartX = E->Prev->Bot.X; - else StartX = E->Next->Bot.X; - if (E->Bot.X != StartX) ReverseHorizontal(*E); - } - - if (Result->OutIdx != Skip) - { - if (IsClockwise) - { - while (Result->Top.Y == Result->Next->Bot.Y && Result->Next->OutIdx != Skip) - Result = Result->Next; - if (IsHorizontal(*Result) && Result->Next->OutIdx != Skip) - { - //nb: at the top of a bound, horizontals are added to the bound - //only when the preceding edge attaches to the horizontal's left vertex - //unless a Skip edge is encountered when that becomes the top divide - Horz = Result; - while (IsHorizontal(*Horz->Prev)) Horz = Horz->Prev; - if (Horz->Prev->Top.X == Result->Next->Top.X) - { - if (!IsClockwise) Result = Horz->Prev; - } - else if (Horz->Prev->Top.X > Result->Next->Top.X) Result = Horz->Prev; - } - while (E != Result) - { - E->NextInLML = E->Next; - if (IsHorizontal(*E) && E != EStart && - E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E); - E = E->Next; - } - if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Prev->Top.X) - ReverseHorizontal(*E); - Result = Result->Next; //move to the edge just beyond current bound - } else - { - while (Result->Top.Y == Result->Prev->Bot.Y && Result->Prev->OutIdx != Skip) - Result = Result->Prev; - if (IsHorizontal(*Result) && Result->Prev->OutIdx != Skip) - { - Horz = Result; - while (IsHorizontal(*Horz->Next)) Horz = Horz->Next; - if (Horz->Next->Top.X == Result->Prev->Top.X) - { - if (!IsClockwise) Result = Horz->Next; - } - else if (Horz->Next->Top.X > Result->Prev->Top.X) Result = Horz->Next; - } - - while (E != Result) - { - E->NextInLML = E->Prev; - if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X) - ReverseHorizontal(*E); - E = E->Prev; - } - if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X) - ReverseHorizontal(*E); - Result = Result->Prev; //move to the edge just beyond current bound - } - } - - if (Result->OutIdx == Skip) - { - //if edges still remain in the current bound beyond the skip edge then - //create another LocMin and call ProcessBound once more - E = Result; - if (IsClockwise) - { - while (E->Top.Y == E->Next->Bot.Y) E = E->Next; - //don't include top horizontals when parsing a bound a second time, - //they will be contained in the opposite bound ... - while (E != Result && IsHorizontal(*E)) E = E->Prev; - } else - { - while (E->Top.Y == E->Prev->Bot.Y) E = E->Prev; - while (E != Result && IsHorizontal(*E)) E = E->Next; - } - if (E == Result) - { - if (IsClockwise) Result = E->Next; - else Result = E->Prev; - } else - { - //there are more edges in the bound beyond result starting with E - if (IsClockwise) - E = Result->Next; - else - E = Result->Prev; - LocalMinima* locMin = new LocalMinima; - locMin->Next = 0; - locMin->Y = E->Bot.Y; - locMin->LeftBound = 0; - locMin->RightBound = E; - locMin->RightBound->WindDelta = 0; - Result = ProcessBound(locMin->RightBound, IsClockwise); - InsertLocalMinima(locMin); - } - } - return Result; -} -//------------------------------------------------------------------------------ - -bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) -{ -#ifdef use_lines - if (!Closed && PolyTyp == ptClip) - throw clipperException("AddPath: Open paths must be subject."); -#else - if (!Closed) - throw clipperException("AddPath: Open paths have been disabled."); -#endif - - int highI = (int)pg.size() -1; - if (Closed) while (highI > 0 && (pg[highI] == pg[0])) --highI; - while (highI > 0 && (pg[highI] == pg[highI -1])) --highI; - if ((Closed && highI < 2) || (!Closed && highI < 1)) return false; - - //create a new edge array ... - TEdge *edges = new TEdge [highI +1]; - - bool IsFlat = true; - //1. Basic (first) edge initialization ... - try - { - edges[1].Curr = pg[1]; - RangeTest(pg[0], m_UseFullRange); - RangeTest(pg[highI], m_UseFullRange); - InitEdge(&edges[0], &edges[1], &edges[highI], pg[0]); - InitEdge(&edges[highI], &edges[0], &edges[highI-1], pg[highI]); - for (int i = highI - 1; i >= 1; --i) - { - RangeTest(pg[i], m_UseFullRange); - InitEdge(&edges[i], &edges[i+1], &edges[i-1], pg[i]); - } - } - catch(...) - { - delete [] edges; - throw; //range test fails - } - TEdge *eStart = &edges[0]; - - //2. Remove duplicate vertices, and (when closed) collinear edges ... - TEdge *E = eStart, *eLoopStop = eStart; - for (;;) - { - if ((E->Curr == E->Next->Curr)) - { - if (E == E->Next) break; - if (E == eStart) eStart = E->Next; - E = RemoveEdge(E); - eLoopStop = E; - continue; - } - if (E->Prev == E->Next) - break; //only two vertices - else if (Closed && - SlopesEqual(E->Prev->Curr, E->Curr, E->Next->Curr, m_UseFullRange) && - (!m_PreserveCollinear || - !Pt2IsBetweenPt1AndPt3(E->Prev->Curr, E->Curr, E->Next->Curr))) - { - //Collinear edges are allowed for open paths but in closed paths - //the default is to merge adjacent collinear edges into a single edge. - //However, if the PreserveCollinear property is enabled, only overlapping - //collinear edges (ie spikes) will be removed from closed paths. - if (E == eStart) eStart = E->Next; - E = RemoveEdge(E); - E = E->Prev; - eLoopStop = E; - continue; - } - E = E->Next; - if (E == eLoopStop) break; - } - - if ((!Closed && (E == E->Next)) || (Closed && (E->Prev == E->Next))) - { - delete [] edges; - return false; - } - - if (!Closed) - { - m_HasOpenPaths = true; - eStart->Prev->OutIdx = Skip; - } - - //3. Do second stage of edge initialization ... - E = eStart; - do - { - InitEdge2(*E, PolyTyp); - E = E->Next; - if (IsFlat && E->Curr.Y != eStart->Curr.Y) IsFlat = false; - } - while (E != eStart); - - //4. Finally, add edge bounds to LocalMinima list ... - - //Totally flat paths must be handled differently when adding them - //to LocalMinima list to avoid endless loops etc ... - if (IsFlat) - { - if (Closed) - { - delete [] edges; - return false; - } - E->Prev->OutIdx = Skip; - if (E->Prev->Bot.X < E->Prev->Top.X) ReverseHorizontal(*E->Prev); - LocalMinima* locMin = new LocalMinima(); - locMin->Next = 0; - locMin->Y = E->Bot.Y; - locMin->LeftBound = 0; - locMin->RightBound = E; - locMin->RightBound->Side = esRight; - locMin->RightBound->WindDelta = 0; - while (E->Next->OutIdx != Skip) - { - E->NextInLML = E->Next; - if (E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E); - E = E->Next; - } - InsertLocalMinima(locMin); - m_edges.push_back(edges); - return true; - } - - m_edges.push_back(edges); - bool clockwise; - TEdge* EMin = 0; - for (;;) - { - E = FindNextLocMin(E); - if (E == EMin) break; - else if (!EMin) EMin = E; - - //E and E.Prev now share a local minima (left aligned if horizontal). - //Compare their slopes to find which starts which bound ... - LocalMinima* locMin = new LocalMinima; - locMin->Next = 0; - locMin->Y = E->Bot.Y; - if (E->Dx < E->Prev->Dx) - { - locMin->LeftBound = E->Prev; - locMin->RightBound = E; - clockwise = false; //Q.nextInLML = Q.prev - } else - { - locMin->LeftBound = E; - locMin->RightBound = E->Prev; - clockwise = true; //Q.nextInLML = Q.next - } - locMin->LeftBound->Side = esLeft; - locMin->RightBound->Side = esRight; - - if (!Closed) locMin->LeftBound->WindDelta = 0; - else if (locMin->LeftBound->Next == locMin->RightBound) - locMin->LeftBound->WindDelta = -1; - else locMin->LeftBound->WindDelta = 1; - locMin->RightBound->WindDelta = -locMin->LeftBound->WindDelta; - - E = ProcessBound(locMin->LeftBound, clockwise); - TEdge* E2 = ProcessBound(locMin->RightBound, !clockwise); - - if (locMin->LeftBound->OutIdx == Skip) - locMin->LeftBound = 0; - else if (locMin->RightBound->OutIdx == Skip) - locMin->RightBound = 0; - InsertLocalMinima(locMin); - if (!clockwise) E = E2; - } - return true; -} -//------------------------------------------------------------------------------ - -bool ClipperBase::AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed) -{ - bool result = false; - for (Paths::size_type i = 0; i < ppg.size(); ++i) - if (AddPath(ppg[i], PolyTyp, Closed)) result = true; - return result; -} -//------------------------------------------------------------------------------ - -void ClipperBase::InsertLocalMinima(LocalMinima *newLm) -{ - if( ! m_MinimaList ) - { - m_MinimaList = newLm; - } - else if( newLm->Y >= m_MinimaList->Y ) - { - newLm->Next = m_MinimaList; - m_MinimaList = newLm; - } else - { - LocalMinima* tmpLm = m_MinimaList; - while( tmpLm->Next && ( newLm->Y < tmpLm->Next->Y ) ) - tmpLm = tmpLm->Next; - newLm->Next = tmpLm->Next; - tmpLm->Next = newLm; - } -} -//------------------------------------------------------------------------------ - -void ClipperBase::Clear() -{ - DisposeLocalMinimaList(); - for (EdgeList::size_type i = 0; i < m_edges.size(); ++i) - { - //for each edge array in turn, find the first used edge and - //check for and remove any hiddenPts in each edge in the array. - TEdge* edges = m_edges[i]; - delete [] edges; - } - m_edges.clear(); - m_UseFullRange = false; - m_HasOpenPaths = false; -} -//------------------------------------------------------------------------------ - -void ClipperBase::Reset() -{ - m_CurrentLM = m_MinimaList; - if( !m_CurrentLM ) return; //ie nothing to process - - //reset all edges ... - LocalMinima* lm = m_MinimaList; - while( lm ) - { - TEdge* e = lm->LeftBound; - if (e) - { - e->Curr = e->Bot; - e->Side = esLeft; - e->OutIdx = Unassigned; - } - - e = lm->RightBound; - if (e) - { - e->Curr = e->Bot; - e->Side = esRight; - e->OutIdx = Unassigned; - } - lm = lm->Next; - } -} -//------------------------------------------------------------------------------ - -void ClipperBase::DisposeLocalMinimaList() -{ - while( m_MinimaList ) - { - LocalMinima* tmpLm = m_MinimaList->Next; - delete m_MinimaList; - m_MinimaList = tmpLm; - } - m_CurrentLM = 0; -} -//------------------------------------------------------------------------------ - -void ClipperBase::PopLocalMinima() -{ - if( ! m_CurrentLM ) return; - m_CurrentLM = m_CurrentLM->Next; -} -//------------------------------------------------------------------------------ - -IntRect ClipperBase::GetBounds() -{ - IntRect result; - LocalMinima* lm = m_MinimaList; - if (!lm) - { - result.left = result.top = result.right = result.bottom = 0; - return result; - } - result.left = lm->LeftBound->Bot.X; - result.top = lm->LeftBound->Bot.Y; - result.right = lm->LeftBound->Bot.X; - result.bottom = lm->LeftBound->Bot.Y; - while (lm) - { - if (lm->LeftBound->Bot.Y > result.bottom) - result.bottom = lm->LeftBound->Bot.Y; - TEdge* e = lm->LeftBound; - for (;;) { - TEdge* bottomE = e; - while (e->NextInLML) - { - if (e->Bot.X < result.left) result.left = e->Bot.X; - if (e->Bot.X > result.right) result.right = e->Bot.X; - e = e->NextInLML; - } - if (e->Bot.X < result.left) result.left = e->Bot.X; - if (e->Bot.X > result.right) result.right = e->Bot.X; - if (e->Top.X < result.left) result.left = e->Top.X; - if (e->Top.X > result.right) result.right = e->Top.X; - if (e->Top.Y < result.top) result.top = e->Top.Y; - - if (bottomE == lm->LeftBound) e = lm->RightBound; - else break; - } - lm = lm->Next; - } - return result; -} - -//------------------------------------------------------------------------------ -// TClipper methods ... -//------------------------------------------------------------------------------ - -Clipper::Clipper(int initOptions) : ClipperBase() //constructor -{ - m_ActiveEdges = 0; - m_SortedEdges = 0; - m_ExecuteLocked = false; - m_UseFullRange = false; - m_ReverseOutput = ((initOptions & ioReverseSolution) != 0); - m_StrictSimple = ((initOptions & ioStrictlySimple) != 0); - m_PreserveCollinear = ((initOptions & ioPreserveCollinear) != 0); - m_HasOpenPaths = false; -#ifdef use_xyz - m_ZFill = 0; -#endif -} -//------------------------------------------------------------------------------ - -Clipper::~Clipper() //destructor -{ - Clear(); - m_Scanbeam.clear(); -} -//------------------------------------------------------------------------------ - -#ifdef use_xyz -void Clipper::ZFillFunction(TZFillCallback zFillFunc) -{ - m_ZFill = zFillFunc; -} -//------------------------------------------------------------------------------ -#endif - -void Clipper::Reset() -{ - ClipperBase::Reset(); - m_Scanbeam.clear(); - m_ActiveEdges = 0; - m_SortedEdges = 0; - LocalMinima* lm = m_MinimaList; - while (lm) - { - InsertScanbeam(lm->Y); - lm = lm->Next; - } -} -//------------------------------------------------------------------------------ - -bool Clipper::Execute(ClipType clipType, Paths &solution, - PolyFillType subjFillType, PolyFillType clipFillType) -{ - if( m_ExecuteLocked ) return false; - if (m_HasOpenPaths) - throw clipperException("Error: PolyTree struct is need for open path clipping."); - m_ExecuteLocked = true; - solution.resize(0); - m_SubjFillType = subjFillType; - m_ClipFillType = clipFillType; - m_ClipType = clipType; - m_UsingPolyTree = false; - bool succeeded = ExecuteInternal(); - if (succeeded) BuildResult(solution); - DisposeAllOutRecs(); - m_ExecuteLocked = false; - return succeeded; -} -//------------------------------------------------------------------------------ - -bool Clipper::Execute(ClipType clipType, PolyTree& polytree, - PolyFillType subjFillType, PolyFillType clipFillType) -{ - if( m_ExecuteLocked ) return false; - m_ExecuteLocked = true; - m_SubjFillType = subjFillType; - m_ClipFillType = clipFillType; - m_ClipType = clipType; - m_UsingPolyTree = true; - bool succeeded = ExecuteInternal(); - if (succeeded) BuildResult2(polytree); - DisposeAllOutRecs(); - m_ExecuteLocked = false; - return succeeded; -} -//------------------------------------------------------------------------------ - -void Clipper::FixHoleLinkage(OutRec &outrec) -{ - //skip OutRecs that (a) contain outermost polygons or - //(b) already have the correct owner/child linkage ... - if (!outrec.FirstLeft || - (outrec.IsHole != outrec.FirstLeft->IsHole && - outrec.FirstLeft->Pts)) return; - - OutRec* orfl = outrec.FirstLeft; - while (orfl && ((orfl->IsHole == outrec.IsHole) || !orfl->Pts)) - orfl = orfl->FirstLeft; - outrec.FirstLeft = orfl; -} -//------------------------------------------------------------------------------ - -bool Clipper::ExecuteInternal() -{ - bool succeeded = true; - try { - Reset(); - if (!m_CurrentLM) return false; - cInt botY = PopScanbeam(); - do { - InsertLocalMinimaIntoAEL(botY); - ClearGhostJoins(); - ProcessHorizontals(false); - if (m_Scanbeam.empty()) break; - cInt topY = PopScanbeam(); - succeeded = ProcessIntersections(botY, topY); - if (!succeeded) break; - ProcessEdgesAtTopOfScanbeam(topY); - botY = topY; - } while (!m_Scanbeam.empty() || m_CurrentLM); - } - catch(...) - { - succeeded = false; - } - - if (succeeded) - { - //fix orientations ... - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) - { - OutRec *outRec = m_PolyOuts[i]; - if (!outRec->Pts || outRec->IsOpen) continue; - if ((outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0)) - ReversePolyPtLinks(outRec->Pts); - } - - if (!m_Joins.empty()) JoinCommonEdges(); - - //unfortunately FixupOutPolygon() must be done after JoinCommonEdges() - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) - { - OutRec *outRec = m_PolyOuts[i]; - if (outRec->Pts && !outRec->IsOpen) - FixupOutPolygon(*outRec); - } - - if (m_StrictSimple) DoSimplePolygons(); - } - - ClearJoins(); - ClearGhostJoins(); - return succeeded; -} -//------------------------------------------------------------------------------ - -void Clipper::InsertScanbeam(const cInt Y) -{ - m_Scanbeam.insert(Y); -} -//------------------------------------------------------------------------------ - -cInt Clipper::PopScanbeam() -{ - cInt Y = *m_Scanbeam.begin(); - m_Scanbeam.erase(m_Scanbeam.begin()); - return Y; -} -//------------------------------------------------------------------------------ - -void Clipper::DisposeAllOutRecs(){ - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) - DisposeOutRec(i); - m_PolyOuts.clear(); -} -//------------------------------------------------------------------------------ - -void Clipper::DisposeOutRec(PolyOutList::size_type index) -{ - OutRec *outRec = m_PolyOuts[index]; - if (outRec->Pts) DisposeOutPts(outRec->Pts); - delete outRec; - m_PolyOuts[index] = 0; -} -//------------------------------------------------------------------------------ - -void Clipper::SetWindingCount(TEdge &edge) -{ - TEdge *e = edge.PrevInAEL; - //find the edge of the same polytype that immediately preceeds 'edge' in AEL - while (e && ((e->PolyTyp != edge.PolyTyp) || (e->WindDelta == 0))) e = e->PrevInAEL; - if (!e) - { - edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta); - edge.WindCnt2 = 0; - e = m_ActiveEdges; //ie get ready to calc WindCnt2 - } - else if (edge.WindDelta == 0 && m_ClipType != ctUnion) - { - edge.WindCnt = 1; - edge.WindCnt2 = e->WindCnt2; - e = e->NextInAEL; //ie get ready to calc WindCnt2 - } - else if (IsEvenOddFillType(edge)) - { - //EvenOdd filling ... - if (edge.WindDelta == 0) - { - //are we inside a subj polygon ... - bool Inside = true; - TEdge *e2 = e->PrevInAEL; - while (e2) - { - if (e2->PolyTyp == e->PolyTyp && e2->WindDelta != 0) - Inside = !Inside; - e2 = e2->PrevInAEL; - } - edge.WindCnt = (Inside ? 0 : 1); - } - else - { - edge.WindCnt = edge.WindDelta; - } - edge.WindCnt2 = e->WindCnt2; - e = e->NextInAEL; //ie get ready to calc WindCnt2 - } - else - { - //nonZero, Positive or Negative filling ... - if (e->WindCnt * e->WindDelta < 0) - { - //prev edge is 'decreasing' WindCount (WC) toward zero - //so we're outside the previous polygon ... - if (Abs(e->WindCnt) > 1) - { - //outside prev poly but still inside another. - //when reversing direction of prev poly use the same WC - if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt; - //otherwise continue to 'decrease' WC ... - else edge.WindCnt = e->WindCnt + edge.WindDelta; - } - else - //now outside all polys of same polytype so set own WC ... - edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta); - } else - { - //prev edge is 'increasing' WindCount (WC) away from zero - //so we're inside the previous polygon ... - if (edge.WindDelta == 0) - edge.WindCnt = (e->WindCnt < 0 ? e->WindCnt - 1 : e->WindCnt + 1); - //if wind direction is reversing prev then use same WC - else if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt; - //otherwise add to WC ... - else edge.WindCnt = e->WindCnt + edge.WindDelta; - } - edge.WindCnt2 = e->WindCnt2; - e = e->NextInAEL; //ie get ready to calc WindCnt2 - } - - //update WindCnt2 ... - if (IsEvenOddAltFillType(edge)) - { - //EvenOdd filling ... - while (e != &edge) - { - if (e->WindDelta != 0) - edge.WindCnt2 = (edge.WindCnt2 == 0 ? 1 : 0); - e = e->NextInAEL; - } - } else - { - //nonZero, Positive or Negative filling ... - while ( e != &edge ) - { - edge.WindCnt2 += e->WindDelta; - e = e->NextInAEL; - } - } -} -//------------------------------------------------------------------------------ - -bool Clipper::IsEvenOddFillType(const TEdge& edge) const -{ - if (edge.PolyTyp == ptSubject) - return m_SubjFillType == pftEvenOdd; else - return m_ClipFillType == pftEvenOdd; -} -//------------------------------------------------------------------------------ - -bool Clipper::IsEvenOddAltFillType(const TEdge& edge) const -{ - if (edge.PolyTyp == ptSubject) - return m_ClipFillType == pftEvenOdd; else - return m_SubjFillType == pftEvenOdd; -} -//------------------------------------------------------------------------------ - -bool Clipper::IsContributing(const TEdge& edge) const -{ - PolyFillType pft, pft2; - if (edge.PolyTyp == ptSubject) - { - pft = m_SubjFillType; - pft2 = m_ClipFillType; - } else - { - pft = m_ClipFillType; - pft2 = m_SubjFillType; - } - - switch(pft) - { - case pftEvenOdd: - //return false if a subj line has been flagged as inside a subj polygon - if (edge.WindDelta == 0 && edge.WindCnt != 1) return false; - break; - case pftNonZero: - if (Abs(edge.WindCnt) != 1) return false; - break; - case pftPositive: - if (edge.WindCnt != 1) return false; - break; - default: //pftNegative - if (edge.WindCnt != -1) return false; - } - - switch(m_ClipType) - { - case ctIntersection: - switch(pft2) - { - case pftEvenOdd: - case pftNonZero: - return (edge.WindCnt2 != 0); - case pftPositive: - return (edge.WindCnt2 > 0); - default: - return (edge.WindCnt2 < 0); - } - break; - case ctUnion: - switch(pft2) - { - case pftEvenOdd: - case pftNonZero: - return (edge.WindCnt2 == 0); - case pftPositive: - return (edge.WindCnt2 <= 0); - default: - return (edge.WindCnt2 >= 0); - } - break; - case ctDifference: - if (edge.PolyTyp == ptSubject) - switch(pft2) - { - case pftEvenOdd: - case pftNonZero: - return (edge.WindCnt2 == 0); - case pftPositive: - return (edge.WindCnt2 <= 0); - default: - return (edge.WindCnt2 >= 0); - } - else - switch(pft2) - { - case pftEvenOdd: - case pftNonZero: - return (edge.WindCnt2 != 0); - case pftPositive: - return (edge.WindCnt2 > 0); - default: - return (edge.WindCnt2 < 0); - } - break; - case ctXor: - if (edge.WindDelta == 0) //XOr always contributing unless open - switch(pft2) - { - case pftEvenOdd: - case pftNonZero: - return (edge.WindCnt2 == 0); - case pftPositive: - return (edge.WindCnt2 <= 0); - default: - return (edge.WindCnt2 >= 0); - } - else - return true; - break; - default: - return true; - } -} -//------------------------------------------------------------------------------ - -OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt) -{ - OutPt* result; - TEdge *e, *prevE; - if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx )) - { - result = AddOutPt(e1, Pt); - e2->OutIdx = e1->OutIdx; - e1->Side = esLeft; - e2->Side = esRight; - e = e1; - if (e->PrevInAEL == e2) - prevE = e2->PrevInAEL; - else - prevE = e->PrevInAEL; - } else - { - result = AddOutPt(e2, Pt); - e1->OutIdx = e2->OutIdx; - e1->Side = esRight; - e2->Side = esLeft; - e = e2; - if (e->PrevInAEL == e1) - prevE = e1->PrevInAEL; - else - prevE = e->PrevInAEL; - } - - if (prevE && prevE->OutIdx >= 0 && - (TopX(*prevE, Pt.Y) == TopX(*e, Pt.Y)) && - SlopesEqual(*e, *prevE, m_UseFullRange) && - (e->WindDelta != 0) && (prevE->WindDelta != 0)) - { - OutPt* outPt = AddOutPt(prevE, Pt); - AddJoin(result, outPt, e->Top); - } - return result; -} -//------------------------------------------------------------------------------ - -void Clipper::AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt) -{ - AddOutPt( e1, Pt ); - if (e2->WindDelta == 0) AddOutPt(e2, Pt); - if( e1->OutIdx == e2->OutIdx ) - { - e1->OutIdx = Unassigned; - e2->OutIdx = Unassigned; - } - else if (e1->OutIdx < e2->OutIdx) - AppendPolygon(e1, e2); - else - AppendPolygon(e2, e1); -} -//------------------------------------------------------------------------------ - -void Clipper::AddEdgeToSEL(TEdge *edge) -{ - //SEL pointers in PEdge are reused to build a list of horizontal edges. - //However, we don't need to worry about order with horizontal edge processing. - if( !m_SortedEdges ) - { - m_SortedEdges = edge; - edge->PrevInSEL = 0; - edge->NextInSEL = 0; - } - else - { - edge->NextInSEL = m_SortedEdges; - edge->PrevInSEL = 0; - m_SortedEdges->PrevInSEL = edge; - m_SortedEdges = edge; - } -} -//------------------------------------------------------------------------------ - -void Clipper::CopyAELToSEL() -{ - TEdge* e = m_ActiveEdges; - m_SortedEdges = e; - while ( e ) - { - e->PrevInSEL = e->PrevInAEL; - e->NextInSEL = e->NextInAEL; - e = e->NextInAEL; - } -} -//------------------------------------------------------------------------------ - -void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint OffPt) -{ - Join* j = new Join; - j->OutPt1 = op1; - j->OutPt2 = op2; - j->OffPt = OffPt; - m_Joins.push_back(j); -} -//------------------------------------------------------------------------------ - -void Clipper::ClearJoins() -{ - for (JoinList::size_type i = 0; i < m_Joins.size(); i++) - delete m_Joins[i]; - m_Joins.resize(0); -} -//------------------------------------------------------------------------------ - -void Clipper::ClearGhostJoins() -{ - for (JoinList::size_type i = 0; i < m_GhostJoins.size(); i++) - delete m_GhostJoins[i]; - m_GhostJoins.resize(0); -} -//------------------------------------------------------------------------------ - -void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt) -{ - Join* j = new Join; - j->OutPt1 = op; - j->OutPt2 = 0; - j->OffPt = OffPt; - m_GhostJoins.push_back(j); -} -//------------------------------------------------------------------------------ - -void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) -{ - while( m_CurrentLM && ( m_CurrentLM->Y == botY ) ) - { - TEdge* lb = m_CurrentLM->LeftBound; - TEdge* rb = m_CurrentLM->RightBound; - PopLocalMinima(); - OutPt *Op1 = 0; - if (!lb) - { - //nb: don't insert LB into either AEL or SEL - InsertEdgeIntoAEL(rb, 0); - SetWindingCount(*rb); - if (IsContributing(*rb)) - Op1 = AddOutPt(rb, rb->Bot); - } - else if (!rb) - { - InsertEdgeIntoAEL(lb, 0); - SetWindingCount(*lb); - if (IsContributing(*lb)) - Op1 = AddOutPt(lb, lb->Bot); - InsertScanbeam(lb->Top.Y); - } - else - { - InsertEdgeIntoAEL(lb, 0); - InsertEdgeIntoAEL(rb, lb); - SetWindingCount( *lb ); - rb->WindCnt = lb->WindCnt; - rb->WindCnt2 = lb->WindCnt2; - if (IsContributing(*lb)) - Op1 = AddLocalMinPoly(lb, rb, lb->Bot); - InsertScanbeam(lb->Top.Y); - } - - if (rb) - { - if(IsHorizontal(*rb)) AddEdgeToSEL(rb); - else InsertScanbeam( rb->Top.Y ); - } - - if (!lb || !rb) continue; - - //if any output polygons share an edge, they'll need joining later ... - if (Op1 && IsHorizontal(*rb) && - m_GhostJoins.size() > 0 && (rb->WindDelta != 0)) - { - for (JoinList::size_type i = 0; i < m_GhostJoins.size(); ++i) - { - Join* jr = m_GhostJoins[i]; - //if the horizontal Rb and a 'ghost' horizontal overlap, then convert - //the 'ghost' join to a real join ready for later ... - if (HorzSegmentsOverlap(jr->OutPt1->Pt, jr->OffPt, rb->Bot, rb->Top)) - AddJoin(jr->OutPt1, Op1, jr->OffPt); - } - } - - if (lb->OutIdx >= 0 && lb->PrevInAEL && - lb->PrevInAEL->Curr.X == lb->Bot.X && - lb->PrevInAEL->OutIdx >= 0 && - SlopesEqual(*lb->PrevInAEL, *lb, m_UseFullRange) && - (lb->WindDelta != 0) && (lb->PrevInAEL->WindDelta != 0)) - { - OutPt *Op2 = AddOutPt(lb->PrevInAEL, lb->Bot); - AddJoin(Op1, Op2, lb->Top); - } - - if(lb->NextInAEL != rb) - { - - if (rb->OutIdx >= 0 && rb->PrevInAEL->OutIdx >= 0 && - SlopesEqual(*rb->PrevInAEL, *rb, m_UseFullRange) && - (rb->WindDelta != 0) && (rb->PrevInAEL->WindDelta != 0)) - { - OutPt *Op2 = AddOutPt(rb->PrevInAEL, rb->Bot); - AddJoin(Op1, Op2, rb->Top); - } - - TEdge* e = lb->NextInAEL; - if (e) - { - while( e != rb ) - { - //nb: For calculating winding counts etc, IntersectEdges() assumes - //that param1 will be to the Right of param2 ABOVE the intersection ... - IntersectEdges(rb , e , lb->Curr); //order important here - e = e->NextInAEL; - } - } - } - - } -} -//------------------------------------------------------------------------------ - -void Clipper::DeleteFromAEL(TEdge *e) -{ - TEdge* AelPrev = e->PrevInAEL; - TEdge* AelNext = e->NextInAEL; - if( !AelPrev && !AelNext && (e != m_ActiveEdges) ) return; //already deleted - if( AelPrev ) AelPrev->NextInAEL = AelNext; - else m_ActiveEdges = AelNext; - if( AelNext ) AelNext->PrevInAEL = AelPrev; - e->NextInAEL = 0; - e->PrevInAEL = 0; -} -//------------------------------------------------------------------------------ - -void Clipper::DeleteFromSEL(TEdge *e) -{ - TEdge* SelPrev = e->PrevInSEL; - TEdge* SelNext = e->NextInSEL; - if( !SelPrev && !SelNext && (e != m_SortedEdges) ) return; //already deleted - if( SelPrev ) SelPrev->NextInSEL = SelNext; - else m_SortedEdges = SelNext; - if( SelNext ) SelNext->PrevInSEL = SelPrev; - e->NextInSEL = 0; - e->PrevInSEL = 0; -} -//------------------------------------------------------------------------------ - -#ifdef use_xyz - -void Clipper::SetZ(IntPoint& pt, TEdge& e) -{ - pt.Z = 0; - if (m_ZFill) - { - //put the 'preferred' point as first parameter ... - if (e.OutIdx < 0) - (*m_ZFill)(e.Bot, e.Top, pt); //outside a path so presume entering - else - (*m_ZFill)(e.Top, e.Bot, pt); //inside a path so presume exiting - } -} -//------------------------------------------------------------------------------ -#endif - -void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, - const IntPoint &Pt, bool protect) -{ - //e1 will be to the Left of e2 BELOW the intersection. Therefore e1 is before - //e2 in AEL except when e1 is being inserted at the intersection point ... - bool e1stops = !protect && !e1->NextInLML && - e1->Top.X == Pt.X && e1->Top.Y == Pt.Y; - bool e2stops = !protect && !e2->NextInLML && - e2->Top.X == Pt.X && e2->Top.Y == Pt.Y; - bool e1Contributing = ( e1->OutIdx >= 0 ); - bool e2Contributing = ( e2->OutIdx >= 0 ); - -#ifdef use_lines - //if either edge is on an OPEN path ... - if (e1->WindDelta == 0 || e2->WindDelta == 0) - { - //ignore subject-subject open path intersections UNLESS they - //are both open paths, AND they are both 'contributing maximas' ... - if (e1->WindDelta == 0 && e2->WindDelta == 0) - { - if ((e1stops || e2stops) && e1Contributing && e2Contributing) - AddLocalMaxPoly(e1, e2, Pt); - } - - //if intersecting a subj line with a subj poly ... - else if (e1->PolyTyp == e2->PolyTyp && - e1->WindDelta != e2->WindDelta && m_ClipType == ctUnion) - { - if (e1->WindDelta == 0) - { - if (e2Contributing) - { - AddOutPt(e1, Pt); - if (e1Contributing) e1->OutIdx = Unassigned; - } - } - else - { - if (e1Contributing) - { - AddOutPt(e2, Pt); - if (e2Contributing) e2->OutIdx = Unassigned; - } - } - } - else if (e1->PolyTyp != e2->PolyTyp) - { - //toggle subj open path OutIdx on/off when Abs(clip.WndCnt) == 1 ... - if ((e1->WindDelta == 0) && abs(e2->WindCnt) == 1 && - (m_ClipType != ctUnion || e2->WindCnt2 == 0)) - { - AddOutPt(e1, Pt); - if (e1Contributing) e1->OutIdx = Unassigned; - } - else if ((e2->WindDelta == 0) && (abs(e1->WindCnt) == 1) && - (m_ClipType != ctUnion || e1->WindCnt2 == 0)) - { - AddOutPt(e2, Pt); - if (e2Contributing) e2->OutIdx = Unassigned; - } - } - - if (e1stops) - if (e1->OutIdx < 0) DeleteFromAEL(e1); - else throw clipperException("Error intersecting polylines"); - if (e2stops) - if (e2->OutIdx < 0) DeleteFromAEL(e2); - else throw clipperException("Error intersecting polylines"); - return; - } -#endif - - //update winding counts... - //assumes that e1 will be to the Right of e2 ABOVE the intersection - if ( e1->PolyTyp == e2->PolyTyp ) - { - if ( IsEvenOddFillType( *e1) ) - { - int oldE1WindCnt = e1->WindCnt; - e1->WindCnt = e2->WindCnt; - e2->WindCnt = oldE1WindCnt; - } else - { - if (e1->WindCnt + e2->WindDelta == 0 ) e1->WindCnt = -e1->WindCnt; - else e1->WindCnt += e2->WindDelta; - if ( e2->WindCnt - e1->WindDelta == 0 ) e2->WindCnt = -e2->WindCnt; - else e2->WindCnt -= e1->WindDelta; - } - } else - { - if (!IsEvenOddFillType(*e2)) e1->WindCnt2 += e2->WindDelta; - else e1->WindCnt2 = ( e1->WindCnt2 == 0 ) ? 1 : 0; - if (!IsEvenOddFillType(*e1)) e2->WindCnt2 -= e1->WindDelta; - else e2->WindCnt2 = ( e2->WindCnt2 == 0 ) ? 1 : 0; - } - - PolyFillType e1FillType, e2FillType, e1FillType2, e2FillType2; - if (e1->PolyTyp == ptSubject) - { - e1FillType = m_SubjFillType; - e1FillType2 = m_ClipFillType; - } else - { - e1FillType = m_ClipFillType; - e1FillType2 = m_SubjFillType; - } - if (e2->PolyTyp == ptSubject) - { - e2FillType = m_SubjFillType; - e2FillType2 = m_ClipFillType; - } else - { - e2FillType = m_ClipFillType; - e2FillType2 = m_SubjFillType; - } - - cInt e1Wc, e2Wc; - switch (e1FillType) - { - case pftPositive: e1Wc = e1->WindCnt; break; - case pftNegative: e1Wc = -e1->WindCnt; break; - default: e1Wc = Abs(e1->WindCnt); - } - switch(e2FillType) - { - case pftPositive: e2Wc = e2->WindCnt; break; - case pftNegative: e2Wc = -e2->WindCnt; break; - default: e2Wc = Abs(e2->WindCnt); - } - - if ( e1Contributing && e2Contributing ) - { - if ( e1stops || e2stops || - (e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) || - (e1->PolyTyp != e2->PolyTyp && m_ClipType != ctXor) ) - AddLocalMaxPoly(e1, e2, Pt); - else - { - AddOutPt(e1, Pt); - AddOutPt(e2, Pt); - SwapSides( *e1 , *e2 ); - SwapPolyIndexes( *e1 , *e2 ); - } - } - else if ( e1Contributing ) - { - if (e2Wc == 0 || e2Wc == 1) - { - AddOutPt(e1, Pt); - SwapSides(*e1, *e2); - SwapPolyIndexes(*e1, *e2); - } - } - else if ( e2Contributing ) - { - if (e1Wc == 0 || e1Wc == 1) - { - AddOutPt(e2, Pt); - SwapSides(*e1, *e2); - SwapPolyIndexes(*e1, *e2); - } - } - else if ( (e1Wc == 0 || e1Wc == 1) && - (e2Wc == 0 || e2Wc == 1) && !e1stops && !e2stops ) - { - //neither edge is currently contributing ... - - cInt e1Wc2, e2Wc2; - switch (e1FillType2) - { - case pftPositive: e1Wc2 = e1->WindCnt2; break; - case pftNegative : e1Wc2 = -e1->WindCnt2; break; - default: e1Wc2 = Abs(e1->WindCnt2); - } - switch (e2FillType2) - { - case pftPositive: e2Wc2 = e2->WindCnt2; break; - case pftNegative: e2Wc2 = -e2->WindCnt2; break; - default: e2Wc2 = Abs(e2->WindCnt2); - } - - if (e1->PolyTyp != e2->PolyTyp) - AddLocalMinPoly(e1, e2, Pt); - else if (e1Wc == 1 && e2Wc == 1) - switch( m_ClipType ) { - case ctIntersection: - if (e1Wc2 > 0 && e2Wc2 > 0) - AddLocalMinPoly(e1, e2, Pt); - break; - case ctUnion: - if ( e1Wc2 <= 0 && e2Wc2 <= 0 ) - AddLocalMinPoly(e1, e2, Pt); - break; - case ctDifference: - if (((e1->PolyTyp == ptClip) && (e1Wc2 > 0) && (e2Wc2 > 0)) || - ((e1->PolyTyp == ptSubject) && (e1Wc2 <= 0) && (e2Wc2 <= 0))) - AddLocalMinPoly(e1, e2, Pt); - break; - case ctXor: - AddLocalMinPoly(e1, e2, Pt); - } - else - SwapSides( *e1, *e2 ); - } - - if( (e1stops != e2stops) && - ( (e1stops && (e1->OutIdx >= 0)) || (e2stops && (e2->OutIdx >= 0)) ) ) - { - SwapSides( *e1, *e2 ); - SwapPolyIndexes( *e1, *e2 ); - } - - //finally, delete any non-contributing maxima edges ... - if( e1stops ) DeleteFromAEL( e1 ); - if( e2stops ) DeleteFromAEL( e2 ); -} -//------------------------------------------------------------------------------ - -void Clipper::SetHoleState(TEdge *e, OutRec *outrec) -{ - bool IsHole = false; - TEdge *e2 = e->PrevInAEL; - while (e2) - { - if (e2->OutIdx >= 0 && e2->WindDelta != 0) - { - IsHole = !IsHole; - if (! outrec->FirstLeft) - outrec->FirstLeft = m_PolyOuts[e2->OutIdx]; - } - e2 = e2->PrevInAEL; - } - if (IsHole) outrec->IsHole = true; -} -//------------------------------------------------------------------------------ - -OutRec* GetLowermostRec(OutRec *outRec1, OutRec *outRec2) -{ - //work out which polygon fragment has the correct hole state ... - if (!outRec1->BottomPt) - outRec1->BottomPt = GetBottomPt(outRec1->Pts); - if (!outRec2->BottomPt) - outRec2->BottomPt = GetBottomPt(outRec2->Pts); - OutPt *OutPt1 = outRec1->BottomPt; - OutPt *OutPt2 = outRec2->BottomPt; - if (OutPt1->Pt.Y > OutPt2->Pt.Y) return outRec1; - else if (OutPt1->Pt.Y < OutPt2->Pt.Y) return outRec2; - else if (OutPt1->Pt.X < OutPt2->Pt.X) return outRec1; - else if (OutPt1->Pt.X > OutPt2->Pt.X) return outRec2; - else if (OutPt1->Next == OutPt1) return outRec2; - else if (OutPt2->Next == OutPt2) return outRec1; - else if (FirstIsBottomPt(OutPt1, OutPt2)) return outRec1; - else return outRec2; -} -//------------------------------------------------------------------------------ - -bool Param1RightOfParam2(OutRec* outRec1, OutRec* outRec2) -{ - do - { - outRec1 = outRec1->FirstLeft; - if (outRec1 == outRec2) return true; - } while (outRec1); - return false; -} -//------------------------------------------------------------------------------ - -OutRec* Clipper::GetOutRec(int Idx) -{ - OutRec* outrec = m_PolyOuts[Idx]; - while (outrec != m_PolyOuts[outrec->Idx]) - outrec = m_PolyOuts[outrec->Idx]; - return outrec; -} -//------------------------------------------------------------------------------ - -void Clipper::AppendPolygon(TEdge *e1, TEdge *e2) -{ - //get the start and ends of both output polygons ... - OutRec *outRec1 = m_PolyOuts[e1->OutIdx]; - OutRec *outRec2 = m_PolyOuts[e2->OutIdx]; - - OutRec *holeStateRec; - if (Param1RightOfParam2(outRec1, outRec2)) - holeStateRec = outRec2; - else if (Param1RightOfParam2(outRec2, outRec1)) - holeStateRec = outRec1; - else - holeStateRec = GetLowermostRec(outRec1, outRec2); - - //get the start and ends of both output polygons and - //join e2 poly onto e1 poly and delete pointers to e2 ... - - OutPt* p1_lft = outRec1->Pts; - OutPt* p1_rt = p1_lft->Prev; - OutPt* p2_lft = outRec2->Pts; - OutPt* p2_rt = p2_lft->Prev; - - EdgeSide Side; - //join e2 poly onto e1 poly and delete pointers to e2 ... - if( e1->Side == esLeft ) - { - if( e2->Side == esLeft ) - { - //z y x a b c - ReversePolyPtLinks(p2_lft); - p2_lft->Next = p1_lft; - p1_lft->Prev = p2_lft; - p1_rt->Next = p2_rt; - p2_rt->Prev = p1_rt; - outRec1->Pts = p2_rt; - } else - { - //x y z a b c - p2_rt->Next = p1_lft; - p1_lft->Prev = p2_rt; - p2_lft->Prev = p1_rt; - p1_rt->Next = p2_lft; - outRec1->Pts = p2_lft; - } - Side = esLeft; - } else - { - if( e2->Side == esRight ) - { - //a b c z y x - ReversePolyPtLinks(p2_lft); - p1_rt->Next = p2_rt; - p2_rt->Prev = p1_rt; - p2_lft->Next = p1_lft; - p1_lft->Prev = p2_lft; - } else - { - //a b c x y z - p1_rt->Next = p2_lft; - p2_lft->Prev = p1_rt; - p1_lft->Prev = p2_rt; - p2_rt->Next = p1_lft; - } - Side = esRight; - } - - outRec1->BottomPt = 0; - if (holeStateRec == outRec2) - { - if (outRec2->FirstLeft != outRec1) - outRec1->FirstLeft = outRec2->FirstLeft; - outRec1->IsHole = outRec2->IsHole; - } - outRec2->Pts = 0; - outRec2->BottomPt = 0; - outRec2->FirstLeft = outRec1; - - int OKIdx = e1->OutIdx; - int ObsoleteIdx = e2->OutIdx; - - e1->OutIdx = Unassigned; //nb: safe because we only get here via AddLocalMaxPoly - e2->OutIdx = Unassigned; - - TEdge* e = m_ActiveEdges; - while( e ) - { - if( e->OutIdx == ObsoleteIdx ) - { - e->OutIdx = OKIdx; - e->Side = Side; - break; - } - e = e->NextInAEL; - } - - outRec2->Idx = outRec1->Idx; -} -//------------------------------------------------------------------------------ - -OutRec* Clipper::CreateOutRec() -{ - OutRec* result = new OutRec; - result->IsHole = false; - result->IsOpen = false; - result->FirstLeft = 0; - result->Pts = 0; - result->BottomPt = 0; - result->PolyNd = 0; - m_PolyOuts.push_back(result); - result->Idx = (int)m_PolyOuts.size()-1; - return result; -} -//------------------------------------------------------------------------------ - -OutPt* Clipper::AddOutPt(TEdge *e, const IntPoint &pt) -{ - bool ToFront = (e->Side == esLeft); - if( e->OutIdx < 0 ) - { - OutRec *outRec = CreateOutRec(); - outRec->IsOpen = (e->WindDelta == 0); - OutPt* newOp = new OutPt; - outRec->Pts = newOp; - newOp->Idx = outRec->Idx; - newOp->Pt = pt; - newOp->Next = newOp; - newOp->Prev = newOp; - if (!outRec->IsOpen) - SetHoleState(e, outRec); -#ifdef use_xyz - if (pt == e->Bot) newOp->Pt = e->Bot; - else if (pt == e->Top) newOp->Pt = e->Top; - else SetZ(newOp->Pt, *e); -#endif - e->OutIdx = outRec->Idx; //nb: do this after SetZ ! - return newOp; - } else - { - OutRec *outRec = m_PolyOuts[e->OutIdx]; - //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most' - OutPt* op = outRec->Pts; - - if (ToFront && (pt == op->Pt)) return op; - else if (!ToFront && (pt == op->Prev->Pt)) return op->Prev; - - OutPt* newOp = new OutPt; - newOp->Idx = outRec->Idx; - newOp->Pt = pt; - newOp->Next = op; - newOp->Prev = op->Prev; - newOp->Prev->Next = newOp; - op->Prev = newOp; - if (ToFront) outRec->Pts = newOp; -#ifdef use_xyz - if (pt == e->Bot) newOp->Pt = e->Bot; - else if (pt == e->Top) newOp->Pt = e->Top; - else SetZ(newOp->Pt, *e); -#endif - return newOp; - } -} -//------------------------------------------------------------------------------ - -void Clipper::ProcessHorizontals(bool IsTopOfScanbeam) -{ - TEdge* horzEdge = m_SortedEdges; - while(horzEdge) - { - DeleteFromSEL(horzEdge); - ProcessHorizontal(horzEdge, IsTopOfScanbeam); - horzEdge = m_SortedEdges; - } -} -//------------------------------------------------------------------------------ - -inline bool IsMinima(TEdge *e) -{ - return e && (e->Prev->NextInLML != e) && (e->Next->NextInLML != e); -} -//------------------------------------------------------------------------------ - -inline bool IsMaxima(TEdge *e, const cInt Y) -{ - return e && e->Top.Y == Y && !e->NextInLML; -} -//------------------------------------------------------------------------------ - -inline bool IsIntermediate(TEdge *e, const cInt Y) -{ - return e->Top.Y == Y && e->NextInLML; -} -//------------------------------------------------------------------------------ - -TEdge *GetMaximaPair(TEdge *e) -{ - TEdge* result = 0; - if ((e->Next->Top == e->Top) && !e->Next->NextInLML) - result = e->Next; - else if ((e->Prev->Top == e->Top) && !e->Prev->NextInLML) - result = e->Prev; - - if (result && (result->OutIdx == Skip || - //result is false if both NextInAEL & PrevInAEL are nil & not horizontal ... - (result->NextInAEL == result->PrevInAEL && !IsHorizontal(*result)))) - return 0; - return result; -} -//------------------------------------------------------------------------------ - -void Clipper::SwapPositionsInAEL(TEdge *Edge1, TEdge *Edge2) -{ - //check that one or other edge hasn't already been removed from AEL ... - if (Edge1->NextInAEL == Edge1->PrevInAEL || - Edge2->NextInAEL == Edge2->PrevInAEL) return; - - if( Edge1->NextInAEL == Edge2 ) - { - TEdge* Next = Edge2->NextInAEL; - if( Next ) Next->PrevInAEL = Edge1; - TEdge* Prev = Edge1->PrevInAEL; - if( Prev ) Prev->NextInAEL = Edge2; - Edge2->PrevInAEL = Prev; - Edge2->NextInAEL = Edge1; - Edge1->PrevInAEL = Edge2; - Edge1->NextInAEL = Next; - } - else if( Edge2->NextInAEL == Edge1 ) - { - TEdge* Next = Edge1->NextInAEL; - if( Next ) Next->PrevInAEL = Edge2; - TEdge* Prev = Edge2->PrevInAEL; - if( Prev ) Prev->NextInAEL = Edge1; - Edge1->PrevInAEL = Prev; - Edge1->NextInAEL = Edge2; - Edge2->PrevInAEL = Edge1; - Edge2->NextInAEL = Next; - } - else - { - TEdge* Next = Edge1->NextInAEL; - TEdge* Prev = Edge1->PrevInAEL; - Edge1->NextInAEL = Edge2->NextInAEL; - if( Edge1->NextInAEL ) Edge1->NextInAEL->PrevInAEL = Edge1; - Edge1->PrevInAEL = Edge2->PrevInAEL; - if( Edge1->PrevInAEL ) Edge1->PrevInAEL->NextInAEL = Edge1; - Edge2->NextInAEL = Next; - if( Edge2->NextInAEL ) Edge2->NextInAEL->PrevInAEL = Edge2; - Edge2->PrevInAEL = Prev; - if( Edge2->PrevInAEL ) Edge2->PrevInAEL->NextInAEL = Edge2; - } - - if( !Edge1->PrevInAEL ) m_ActiveEdges = Edge1; - else if( !Edge2->PrevInAEL ) m_ActiveEdges = Edge2; -} -//------------------------------------------------------------------------------ - -void Clipper::SwapPositionsInSEL(TEdge *Edge1, TEdge *Edge2) -{ - if( !( Edge1->NextInSEL ) && !( Edge1->PrevInSEL ) ) return; - if( !( Edge2->NextInSEL ) && !( Edge2->PrevInSEL ) ) return; - - if( Edge1->NextInSEL == Edge2 ) - { - TEdge* Next = Edge2->NextInSEL; - if( Next ) Next->PrevInSEL = Edge1; - TEdge* Prev = Edge1->PrevInSEL; - if( Prev ) Prev->NextInSEL = Edge2; - Edge2->PrevInSEL = Prev; - Edge2->NextInSEL = Edge1; - Edge1->PrevInSEL = Edge2; - Edge1->NextInSEL = Next; - } - else if( Edge2->NextInSEL == Edge1 ) - { - TEdge* Next = Edge1->NextInSEL; - if( Next ) Next->PrevInSEL = Edge2; - TEdge* Prev = Edge2->PrevInSEL; - if( Prev ) Prev->NextInSEL = Edge1; - Edge1->PrevInSEL = Prev; - Edge1->NextInSEL = Edge2; - Edge2->PrevInSEL = Edge1; - Edge2->NextInSEL = Next; - } - else - { - TEdge* Next = Edge1->NextInSEL; - TEdge* Prev = Edge1->PrevInSEL; - Edge1->NextInSEL = Edge2->NextInSEL; - if( Edge1->NextInSEL ) Edge1->NextInSEL->PrevInSEL = Edge1; - Edge1->PrevInSEL = Edge2->PrevInSEL; - if( Edge1->PrevInSEL ) Edge1->PrevInSEL->NextInSEL = Edge1; - Edge2->NextInSEL = Next; - if( Edge2->NextInSEL ) Edge2->NextInSEL->PrevInSEL = Edge2; - Edge2->PrevInSEL = Prev; - if( Edge2->PrevInSEL ) Edge2->PrevInSEL->NextInSEL = Edge2; - } - - if( !Edge1->PrevInSEL ) m_SortedEdges = Edge1; - else if( !Edge2->PrevInSEL ) m_SortedEdges = Edge2; -} -//------------------------------------------------------------------------------ - -TEdge* GetNextInAEL(TEdge *e, Direction dir) -{ - return dir == dLeftToRight ? e->NextInAEL : e->PrevInAEL; -} -//------------------------------------------------------------------------------ - -void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& Right) -{ - if (HorzEdge.Bot.X < HorzEdge.Top.X) - { - Left = HorzEdge.Bot.X; - Right = HorzEdge.Top.X; - Dir = dLeftToRight; - } else - { - Left = HorzEdge.Top.X; - Right = HorzEdge.Bot.X; - Dir = dRightToLeft; - } -} -//------------------------------------------------------------------------ - -void Clipper::PrepareHorzJoins(TEdge* horzEdge, bool isTopOfScanbeam) -{ - //get the last Op for this horizontal edge - //the point may be anywhere along the horizontal ... - OutPt* outPt = m_PolyOuts[horzEdge->OutIdx]->Pts; - if (horzEdge->Side != esLeft) outPt = outPt->Prev; - - //First, match up overlapping horizontal edges (eg when one polygon's - //intermediate horz edge overlaps an intermediate horz edge of another, or - //when one polygon sits on top of another) ... - //for (JoinList::size_type i = 0; i < m_GhostJoins.size(); ++i) - //{ - // Join* j = m_GhostJoins[i]; - // if (HorzSegmentsOverlap(j->OutPt1->Pt, j->OffPt, horzEdge->Bot, horzEdge->Top)) - // AddJoin(j->OutPt1, outPt, j->OffPt); - //} - - //Also, since horizontal edges at the top of one SB are often removed from - //the AEL before we process the horizontal edges at the bottom of the next, - //we need to create 'ghost' Join records of 'contrubuting' horizontals that - //we can compare with horizontals at the bottom of the next SB. - if (isTopOfScanbeam) - { - if (outPt->Pt == horzEdge->Top) - AddGhostJoin(outPt, horzEdge->Bot); - else - AddGhostJoin(outPt, horzEdge->Top); - } -} -//------------------------------------------------------------------------------ - -/******************************************************************************* -* Notes: Horizontal edges (HEs) at scanline intersections (ie at the Top or * -* Bottom of a scanbeam) are processed as if layered. The order in which HEs * -* are processed doesn't matter. HEs intersect with other HE Bot.Xs only [#] * -* (or they could intersect with Top.Xs only, ie EITHER Bot.Xs OR Top.Xs), * -* and with other non-horizontal edges [*]. Once these intersections are * -* processed, intermediate HEs then 'promote' the Edge above (NextInLML) into * -* the AEL. These 'promoted' edges may in turn intersect [%] with other HEs. * -*******************************************************************************/ - -void Clipper::ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam) -{ - Direction dir; - cInt horzLeft, horzRight; - - GetHorzDirection(*horzEdge, dir, horzLeft, horzRight); - - TEdge* eLastHorz = horzEdge, *eMaxPair = 0; - while (eLastHorz->NextInLML && IsHorizontal(*eLastHorz->NextInLML)) - eLastHorz = eLastHorz->NextInLML; - if (!eLastHorz->NextInLML) - eMaxPair = GetMaximaPair(eLastHorz); - - for (;;) - { - bool IsLastHorz = (horzEdge == eLastHorz); - TEdge* e = GetNextInAEL(horzEdge, dir); - while(e) - { - //Break if we've got to the end of an intermediate horizontal edge ... - //nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal. - if (e->Curr.X == horzEdge->Top.X && horzEdge->NextInLML && - e->Dx < horzEdge->NextInLML->Dx) break; - - TEdge* eNext = GetNextInAEL(e, dir); //saves eNext for later - - if ((dir == dLeftToRight && e->Curr.X <= horzRight) || - (dir == dRightToLeft && e->Curr.X >= horzLeft)) - { - if (horzEdge->OutIdx >= 0 && horzEdge->WindDelta != 0) - PrepareHorzJoins(horzEdge, isTopOfScanbeam); - //so far we're still in range of the horizontal Edge but make sure - //we're at the last of consec. horizontals when matching with eMaxPair - if(e == eMaxPair && IsLastHorz) - { - if (dir == dLeftToRight) - IntersectEdges(horzEdge, e, e->Top); - else - IntersectEdges(e, horzEdge, e->Top); - if (eMaxPair->OutIdx >= 0) throw clipperException("ProcessHorizontal error"); - return; - } - else if(dir == dLeftToRight) - { - IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y); - IntersectEdges(horzEdge, e, Pt, true); - } - else - { - IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y); - IntersectEdges( e, horzEdge, Pt, true); - } - SwapPositionsInAEL( horzEdge, e ); - } - else if( (dir == dLeftToRight && e->Curr.X >= horzRight) || - (dir == dRightToLeft && e->Curr.X <= horzLeft) ) break; - e = eNext; - } //end while - - if (horzEdge->OutIdx >= 0 && horzEdge->WindDelta != 0) - PrepareHorzJoins(horzEdge, isTopOfScanbeam); - - if (horzEdge->NextInLML && IsHorizontal(*horzEdge->NextInLML)) - { - UpdateEdgeIntoAEL(horzEdge); - if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Bot); - GetHorzDirection(*horzEdge, dir, horzLeft, horzRight); - } else - break; - } //end for (;;) - - if(horzEdge->NextInLML) - { - if(horzEdge->OutIdx >= 0) - { - OutPt* op1 = AddOutPt( horzEdge, horzEdge->Top); - UpdateEdgeIntoAEL(horzEdge); - if (horzEdge->WindDelta == 0) return; - //nb: HorzEdge is no longer horizontal here - TEdge* ePrev = horzEdge->PrevInAEL; - TEdge* eNext = horzEdge->NextInAEL; - if (ePrev && ePrev->Curr.X == horzEdge->Bot.X && - ePrev->Curr.Y == horzEdge->Bot.Y && ePrev->WindDelta != 0 && - (ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y && - SlopesEqual(*horzEdge, *ePrev, m_UseFullRange))) - { - OutPt* op2 = AddOutPt(ePrev, horzEdge->Bot); - AddJoin(op1, op2, horzEdge->Top); - } - else if (eNext && eNext->Curr.X == horzEdge->Bot.X && - eNext->Curr.Y == horzEdge->Bot.Y && eNext->WindDelta != 0 && - eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y && - SlopesEqual(*horzEdge, *eNext, m_UseFullRange)) - { - OutPt* op2 = AddOutPt(eNext, horzEdge->Bot); - AddJoin(op1, op2, horzEdge->Top); - } - } - else - UpdateEdgeIntoAEL(horzEdge); - } - else if (eMaxPair) - { - if (eMaxPair->OutIdx >= 0) - { - if (dir == dLeftToRight) - IntersectEdges(horzEdge, eMaxPair, horzEdge->Top); - else - IntersectEdges(eMaxPair, horzEdge, horzEdge->Top); - if (eMaxPair->OutIdx >= 0) - throw clipperException("ProcessHorizontal error"); - } else - { - DeleteFromAEL(horzEdge); - DeleteFromAEL(eMaxPair); - } - } else - { - if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Top); - DeleteFromAEL(horzEdge); - } -} -//------------------------------------------------------------------------------ - -void Clipper::UpdateEdgeIntoAEL(TEdge *&e) -{ - if( !e->NextInLML ) throw - clipperException("UpdateEdgeIntoAEL: invalid call"); - - e->NextInLML->OutIdx = e->OutIdx; - TEdge* AelPrev = e->PrevInAEL; - TEdge* AelNext = e->NextInAEL; - if (AelPrev) AelPrev->NextInAEL = e->NextInLML; - else m_ActiveEdges = e->NextInLML; - if (AelNext) AelNext->PrevInAEL = e->NextInLML; - e->NextInLML->Side = e->Side; - e->NextInLML->WindDelta = e->WindDelta; - e->NextInLML->WindCnt = e->WindCnt; - e->NextInLML->WindCnt2 = e->WindCnt2; - e = e->NextInLML; - e->Curr = e->Bot; - e->PrevInAEL = AelPrev; - e->NextInAEL = AelNext; - if (!IsHorizontal(*e)) InsertScanbeam(e->Top.Y); -} -//------------------------------------------------------------------------------ - -bool Clipper::ProcessIntersections(const cInt botY, const cInt topY) -{ - if( !m_ActiveEdges ) return true; - try { - BuildIntersectList(botY, topY); - size_t IlSize = m_IntersectList.size(); - if (IlSize == 0) return true; - if (IlSize == 1 || FixupIntersectionOrder()) ProcessIntersectList(); - else return false; - } - catch(...) - { - m_SortedEdges = 0; - DisposeIntersectNodes(); - throw clipperException("ProcessIntersections error"); - } - m_SortedEdges = 0; - return true; -} -//------------------------------------------------------------------------------ - -void Clipper::DisposeIntersectNodes() -{ - for (size_t i = 0; i < m_IntersectList.size(); ++i ) - delete m_IntersectList[i]; - m_IntersectList.clear(); -} -//------------------------------------------------------------------------------ - -void Clipper::BuildIntersectList(const cInt botY, const cInt topY) -{ - if ( !m_ActiveEdges ) return; - - //prepare for sorting ... - TEdge* e = m_ActiveEdges; - m_SortedEdges = e; - while( e ) - { - e->PrevInSEL = e->PrevInAEL; - e->NextInSEL = e->NextInAEL; - e->Curr.X = TopX( *e, topY ); - e = e->NextInAEL; - } - - //bubblesort ... - bool isModified; - do - { - isModified = false; - e = m_SortedEdges; - while( e->NextInSEL ) - { - TEdge *eNext = e->NextInSEL; - IntPoint Pt; - if(e->Curr.X > eNext->Curr.X) - { - if (!IntersectPoint(*e, *eNext, Pt, m_UseFullRange) && e->Curr.X > eNext->Curr.X +1) - throw clipperException("Intersection error"); - if (Pt.Y > botY) - { - Pt.Y = botY; - if (std::fabs(e->Dx) > std::fabs(eNext->Dx)) - Pt.X = TopX(*eNext, botY); else - Pt.X = TopX(*e, botY); - } - - IntersectNode * newNode = new IntersectNode; - newNode->Edge1 = e; - newNode->Edge2 = eNext; - newNode->Pt = Pt; - m_IntersectList.push_back(newNode); - - SwapPositionsInSEL(e, eNext); - isModified = true; - } - else - e = eNext; - } - if( e->PrevInSEL ) e->PrevInSEL->NextInSEL = 0; - else break; - } - while ( isModified ); - m_SortedEdges = 0; //important -} -//------------------------------------------------------------------------------ - - -void Clipper::ProcessIntersectList() -{ - for (size_t i = 0; i < m_IntersectList.size(); ++i) - { - IntersectNode* iNode = m_IntersectList[i]; - { - IntersectEdges( iNode->Edge1, iNode->Edge2, iNode->Pt, true); - SwapPositionsInAEL( iNode->Edge1 , iNode->Edge2 ); - } - delete iNode; - } - m_IntersectList.clear(); -} -//------------------------------------------------------------------------------ - -bool IntersectListSort(IntersectNode* node1, IntersectNode* node2) -{ - return node2->Pt.Y < node1->Pt.Y; -} -//------------------------------------------------------------------------------ - -inline bool EdgesAdjacent(const IntersectNode &inode) -{ - return (inode.Edge1->NextInSEL == inode.Edge2) || - (inode.Edge1->PrevInSEL == inode.Edge2); -} -//------------------------------------------------------------------------------ - -bool Clipper::FixupIntersectionOrder() -{ - //pre-condition: intersections are sorted Bottom-most first. - //Now it's crucial that intersections are made only between adjacent edges, - //so to ensure this the order of intersections may need adjusting ... - CopyAELToSEL(); - std::sort(m_IntersectList.begin(), m_IntersectList.end(), IntersectListSort); - size_t cnt = m_IntersectList.size(); - for (size_t i = 0; i < cnt; ++i) - { - if (!EdgesAdjacent(*m_IntersectList[i])) - { - size_t j = i + 1; - while (j < cnt && !EdgesAdjacent(*m_IntersectList[j])) j++; - if (j == cnt) return false; - std::swap(m_IntersectList[i], m_IntersectList[j]); - } - SwapPositionsInSEL(m_IntersectList[i]->Edge1, m_IntersectList[i]->Edge2); - } - return true; -} -//------------------------------------------------------------------------------ - -void Clipper::DoMaxima(TEdge *e) -{ - TEdge* eMaxPair = GetMaximaPair(e); - if (!eMaxPair) - { - if (e->OutIdx >= 0) - AddOutPt(e, e->Top); - DeleteFromAEL(e); - return; - } - - TEdge* eNext = e->NextInAEL; - while(eNext && eNext != eMaxPair) - { - IntersectEdges(e, eNext, e->Top, true); - SwapPositionsInAEL(e, eNext); - eNext = e->NextInAEL; - } - - if(e->OutIdx == Unassigned && eMaxPair->OutIdx == Unassigned) - { - DeleteFromAEL(e); - DeleteFromAEL(eMaxPair); - } - else if( e->OutIdx >= 0 && eMaxPair->OutIdx >= 0 ) - { - IntersectEdges( e, eMaxPair, e->Top); - } -#ifdef use_lines - else if (e->WindDelta == 0) - { - if (e->OutIdx >= 0) - { - AddOutPt(e, e->Top); - e->OutIdx = Unassigned; - } - DeleteFromAEL(e); - - if (eMaxPair->OutIdx >= 0) - { - AddOutPt(eMaxPair, e->Top); - eMaxPair->OutIdx = Unassigned; - } - DeleteFromAEL(eMaxPair); - } -#endif - else throw clipperException("DoMaxima error"); -} -//------------------------------------------------------------------------------ - -void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) -{ - TEdge* e = m_ActiveEdges; - while( e ) - { - //1. process maxima, treating them as if they're 'bent' horizontal edges, - // but exclude maxima with horizontal edges. nb: e can't be a horizontal. - bool IsMaximaEdge = IsMaxima(e, topY); - - if(IsMaximaEdge) - { - TEdge* eMaxPair = GetMaximaPair(e); - IsMaximaEdge = (!eMaxPair || !IsHorizontal(*eMaxPair)); - } - - if(IsMaximaEdge) - { - TEdge* ePrev = e->PrevInAEL; - DoMaxima(e); - if( !ePrev ) e = m_ActiveEdges; - else e = ePrev->NextInAEL; - } - else - { - //2. promote horizontal edges, otherwise update Curr.X and Curr.Y ... - if (IsIntermediate(e, topY) && IsHorizontal(*e->NextInLML)) - { - UpdateEdgeIntoAEL(e); - if (e->OutIdx >= 0) - AddOutPt(e, e->Bot); - AddEdgeToSEL(e); - } - else - { - e->Curr.X = TopX( *e, topY ); - e->Curr.Y = topY; - } - - if (m_StrictSimple) - { - TEdge* ePrev = e->PrevInAEL; - if ((e->OutIdx >= 0) && (e->WindDelta != 0) && ePrev && (ePrev->OutIdx >= 0) && - (ePrev->Curr.X == e->Curr.X) && (ePrev->WindDelta != 0)) - { - OutPt* op = AddOutPt(ePrev, e->Curr); - OutPt* op2 = AddOutPt(e, e->Curr); - AddJoin(op, op2, e->Curr); //StrictlySimple (type-3) join - } - } - - e = e->NextInAEL; - } - } - - //3. Process horizontals at the Top of the scanbeam ... - ProcessHorizontals(true); - - //4. Promote intermediate vertices ... - e = m_ActiveEdges; - while(e) - { - if(IsIntermediate(e, topY)) - { - OutPt* op = 0; - if( e->OutIdx >= 0 ) - op = AddOutPt(e, e->Top); - UpdateEdgeIntoAEL(e); - - //if output polygons share an edge, they'll need joining later ... - TEdge* ePrev = e->PrevInAEL; - TEdge* eNext = e->NextInAEL; - if (ePrev && ePrev->Curr.X == e->Bot.X && - ePrev->Curr.Y == e->Bot.Y && op && - ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y && - SlopesEqual(*e, *ePrev, m_UseFullRange) && - (e->WindDelta != 0) && (ePrev->WindDelta != 0)) - { - OutPt* op2 = AddOutPt(ePrev, e->Bot); - AddJoin(op, op2, e->Top); - } - else if (eNext && eNext->Curr.X == e->Bot.X && - eNext->Curr.Y == e->Bot.Y && op && - eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y && - SlopesEqual(*e, *eNext, m_UseFullRange) && - (e->WindDelta != 0) && (eNext->WindDelta != 0)) - { - OutPt* op2 = AddOutPt(eNext, e->Bot); - AddJoin(op, op2, e->Top); - } - } - e = e->NextInAEL; - } -} -//------------------------------------------------------------------------------ - -void Clipper::FixupOutPolygon(OutRec &outrec) -{ - //FixupOutPolygon() - removes duplicate points and simplifies consecutive - //parallel edges by removing the middle vertex. - OutPt *lastOK = 0; - outrec.BottomPt = 0; - OutPt *pp = outrec.Pts; - - for (;;) - { - if (pp->Prev == pp || pp->Prev == pp->Next ) - { - DisposeOutPts(pp); - outrec.Pts = 0; - return; - } - - //test for duplicate points and collinear edges ... - if ((pp->Pt == pp->Next->Pt) || (pp->Pt == pp->Prev->Pt) || - (SlopesEqual(pp->Prev->Pt, pp->Pt, pp->Next->Pt, m_UseFullRange) && - (!m_PreserveCollinear || - !Pt2IsBetweenPt1AndPt3(pp->Prev->Pt, pp->Pt, pp->Next->Pt)))) - { - lastOK = 0; - OutPt *tmp = pp; - pp->Prev->Next = pp->Next; - pp->Next->Prev = pp->Prev; - pp = pp->Prev; - delete tmp; - } - else if (pp == lastOK) break; - else - { - if (!lastOK) lastOK = pp; - pp = pp->Next; - } - } - outrec.Pts = pp; -} -//------------------------------------------------------------------------------ - -int PointCount(OutPt *Pts) -{ - if (!Pts) return 0; - int result = 0; - OutPt* p = Pts; - do - { - result++; - p = p->Next; - } - while (p != Pts); - return result; -} -//------------------------------------------------------------------------------ - -void Clipper::BuildResult(Paths &polys) -{ - polys.reserve(m_PolyOuts.size()); - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) - { - if (!m_PolyOuts[i]->Pts) continue; - Path pg; - OutPt* p = m_PolyOuts[i]->Pts->Prev; - int cnt = PointCount(p); - if (cnt < 2) continue; - pg.reserve(cnt); - for (int i = 0; i < cnt; ++i) - { - pg.push_back(p->Pt); - p = p->Prev; - } - polys.push_back(pg); - } -} -//------------------------------------------------------------------------------ - -void Clipper::BuildResult2(PolyTree& polytree) -{ - polytree.Clear(); - polytree.AllNodes.reserve(m_PolyOuts.size()); - //add each output polygon/contour to polytree ... - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++) - { - OutRec* outRec = m_PolyOuts[i]; - int cnt = PointCount(outRec->Pts); - if ((outRec->IsOpen && cnt < 2) || (!outRec->IsOpen && cnt < 3)) continue; - FixHoleLinkage(*outRec); - PolyNode* pn = new PolyNode(); - //nb: polytree takes ownership of all the PolyNodes - polytree.AllNodes.push_back(pn); - outRec->PolyNd = pn; - pn->Parent = 0; - pn->Index = 0; - pn->Contour.reserve(cnt); - OutPt *op = outRec->Pts->Prev; - for (int j = 0; j < cnt; j++) - { - pn->Contour.push_back(op->Pt); - op = op->Prev; - } - } - - //fixup PolyNode links etc ... - polytree.Childs.reserve(m_PolyOuts.size()); - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++) - { - OutRec* outRec = m_PolyOuts[i]; - if (!outRec->PolyNd) continue; - if (outRec->IsOpen) - { - outRec->PolyNd->m_IsOpen = true; - polytree.AddChild(*outRec->PolyNd); - } - else if (outRec->FirstLeft && outRec->FirstLeft->PolyNd) - outRec->FirstLeft->PolyNd->AddChild(*outRec->PolyNd); - else - polytree.AddChild(*outRec->PolyNd); - } -} -//------------------------------------------------------------------------------ - -void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2) -{ - //just swap the contents (because fIntersectNodes is a single-linked-list) - IntersectNode inode = int1; //gets a copy of Int1 - int1.Edge1 = int2.Edge1; - int1.Edge2 = int2.Edge2; - int1.Pt = int2.Pt; - int2.Edge1 = inode.Edge1; - int2.Edge2 = inode.Edge2; - int2.Pt = inode.Pt; -} -//------------------------------------------------------------------------------ - -inline bool E2InsertsBeforeE1(TEdge &e1, TEdge &e2) -{ - if (e2.Curr.X == e1.Curr.X) - { - if (e2.Top.Y > e1.Top.Y) - return e2.Top.X < TopX(e1, e2.Top.Y); - else return e1.Top.X > TopX(e2, e1.Top.Y); - } - else return e2.Curr.X < e1.Curr.X; -} -//------------------------------------------------------------------------------ - -bool GetOverlap(const cInt a1, const cInt a2, const cInt b1, const cInt b2, - cInt& Left, cInt& Right) -{ - if (a1 < a2) - { - if (b1 < b2) {Left = std::max(a1,b1); Right = std::min(a2,b2);} - else {Left = std::max(a1,b2); Right = std::min(a2,b1);} - } - else - { - if (b1 < b2) {Left = std::max(a2,b1); Right = std::min(a1,b2);} - else {Left = std::max(a2,b2); Right = std::min(a1,b1);} - } - return Left < Right; -} -//------------------------------------------------------------------------------ - -inline void UpdateOutPtIdxs(OutRec& outrec) -{ - OutPt* op = outrec.Pts; - do - { - op->Idx = outrec.Idx; - op = op->Prev; - } - while(op != outrec.Pts); -} -//------------------------------------------------------------------------------ - -void Clipper::InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge) -{ - if(!m_ActiveEdges) - { - edge->PrevInAEL = 0; - edge->NextInAEL = 0; - m_ActiveEdges = edge; - } - else if(!startEdge && E2InsertsBeforeE1(*m_ActiveEdges, *edge)) - { - edge->PrevInAEL = 0; - edge->NextInAEL = m_ActiveEdges; - m_ActiveEdges->PrevInAEL = edge; - m_ActiveEdges = edge; - } - else - { - if(!startEdge) startEdge = m_ActiveEdges; - while(startEdge->NextInAEL && - !E2InsertsBeforeE1(*startEdge->NextInAEL , *edge)) - startEdge = startEdge->NextInAEL; - edge->NextInAEL = startEdge->NextInAEL; - if(startEdge->NextInAEL) startEdge->NextInAEL->PrevInAEL = edge; - edge->PrevInAEL = startEdge; - startEdge->NextInAEL = edge; - } -} -//---------------------------------------------------------------------- - -OutPt* DupOutPt(OutPt* outPt, bool InsertAfter) -{ - OutPt* result = new OutPt; - result->Pt = outPt->Pt; - result->Idx = outPt->Idx; - if (InsertAfter) - { - result->Next = outPt->Next; - result->Prev = outPt; - outPt->Next->Prev = result; - outPt->Next = result; - } - else - { - result->Prev = outPt->Prev; - result->Next = outPt; - outPt->Prev->Next = result; - outPt->Prev = result; - } - return result; -} -//------------------------------------------------------------------------------ - -bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, - const IntPoint Pt, bool DiscardLeft) -{ - Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? dRightToLeft : dLeftToRight); - Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? dRightToLeft : dLeftToRight); - if (Dir1 == Dir2) return false; - - //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we - //want Op1b to be on the Right. (And likewise with Op2 and Op2b.) - //So, to facilitate this while inserting Op1b and Op2b ... - //when DiscardLeft, make sure we're AT or RIGHT of Pt before adding Op1b, - //otherwise make sure we're AT or LEFT of Pt. (Likewise with Op2b.) - if (Dir1 == dLeftToRight) - { - while (op1->Next->Pt.X <= Pt.X && - op1->Next->Pt.X >= op1->Pt.X && op1->Next->Pt.Y == Pt.Y) - op1 = op1->Next; - if (DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next; - op1b = DupOutPt(op1, !DiscardLeft); - if (op1b->Pt != Pt) - { - op1 = op1b; - op1->Pt = Pt; - op1b = DupOutPt(op1, !DiscardLeft); - } - } - else - { - while (op1->Next->Pt.X >= Pt.X && - op1->Next->Pt.X <= op1->Pt.X && op1->Next->Pt.Y == Pt.Y) - op1 = op1->Next; - if (!DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next; - op1b = DupOutPt(op1, DiscardLeft); - if (op1b->Pt != Pt) - { - op1 = op1b; - op1->Pt = Pt; - op1b = DupOutPt(op1, DiscardLeft); - } - } - - if (Dir2 == dLeftToRight) - { - while (op2->Next->Pt.X <= Pt.X && - op2->Next->Pt.X >= op2->Pt.X && op2->Next->Pt.Y == Pt.Y) - op2 = op2->Next; - if (DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next; - op2b = DupOutPt(op2, !DiscardLeft); - if (op2b->Pt != Pt) - { - op2 = op2b; - op2->Pt = Pt; - op2b = DupOutPt(op2, !DiscardLeft); - }; - } else - { - while (op2->Next->Pt.X >= Pt.X && - op2->Next->Pt.X <= op2->Pt.X && op2->Next->Pt.Y == Pt.Y) - op2 = op2->Next; - if (!DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next; - op2b = DupOutPt(op2, DiscardLeft); - if (op2b->Pt != Pt) - { - op2 = op2b; - op2->Pt = Pt; - op2b = DupOutPt(op2, DiscardLeft); - }; - }; - - if ((Dir1 == dLeftToRight) == DiscardLeft) - { - op1->Prev = op2; - op2->Next = op1; - op1b->Next = op2b; - op2b->Prev = op1b; - } - else - { - op1->Next = op2; - op2->Prev = op1; - op1b->Prev = op2b; - op2b->Next = op1b; - } - return true; -} -//------------------------------------------------------------------------------ - -bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) -{ - OutPt *op1 = j->OutPt1, *op1b; - OutPt *op2 = j->OutPt2, *op2b; - - //There are 3 kinds of joins for output polygons ... - //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are a vertices anywhere - //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal). - //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same - //location at the Bottom of the overlapping segment (& Join.OffPt is above). - //3. StrictSimple joins where edges touch but are not collinear and where - //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point. - bool isHorizontal = (j->OutPt1->Pt.Y == j->OffPt.Y); - - if (isHorizontal && (j->OffPt == j->OutPt1->Pt) && - (j->OffPt == j->OutPt2->Pt)) - { - //Strictly Simple join ... - op1b = j->OutPt1->Next; - while (op1b != op1 && (op1b->Pt == j->OffPt)) - op1b = op1b->Next; - bool reverse1 = (op1b->Pt.Y > j->OffPt.Y); - op2b = j->OutPt2->Next; - while (op2b != op2 && (op2b->Pt == j->OffPt)) - op2b = op2b->Next; - bool reverse2 = (op2b->Pt.Y > j->OffPt.Y); - if (reverse1 == reverse2) return false; - if (reverse1) - { - op1b = DupOutPt(op1, false); - op2b = DupOutPt(op2, true); - op1->Prev = op2; - op2->Next = op1; - op1b->Next = op2b; - op2b->Prev = op1b; - j->OutPt1 = op1; - j->OutPt2 = op1b; - return true; - } else - { - op1b = DupOutPt(op1, true); - op2b = DupOutPt(op2, false); - op1->Next = op2; - op2->Prev = op1; - op1b->Prev = op2b; - op2b->Next = op1b; - j->OutPt1 = op1; - j->OutPt2 = op1b; - return true; - } - } - else if (isHorizontal) - { - //treat horizontal joins differently to non-horizontal joins since with - //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt - //may be anywhere along the horizontal edge. - op1b = op1; - while (op1->Prev->Pt.Y == op1->Pt.Y && op1->Prev != op1b && op1->Prev != op2) - op1 = op1->Prev; - while (op1b->Next->Pt.Y == op1b->Pt.Y && op1b->Next != op1 && op1b->Next != op2) - op1b = op1b->Next; - if (op1b->Next == op1 || op1b->Next == op2) return false; //a flat 'polygon' - - op2b = op2; - while (op2->Prev->Pt.Y == op2->Pt.Y && op2->Prev != op2b && op2->Prev != op1b) - op2 = op2->Prev; - while (op2b->Next->Pt.Y == op2b->Pt.Y && op2b->Next != op2 && op2b->Next != op1) - op2b = op2b->Next; - if (op2b->Next == op2 || op2b->Next == op1) return false; //a flat 'polygon' - - cInt Left, Right; - //Op1 --> Op1b & Op2 --> Op2b are the extremites of the horizontal edges - if (!GetOverlap(op1->Pt.X, op1b->Pt.X, op2->Pt.X, op2b->Pt.X, Left, Right)) - return false; - - //DiscardLeftSide: when overlapping edges are joined, a spike will created - //which needs to be cleaned up. However, we don't want Op1 or Op2 caught up - //on the discard Side as either may still be needed for other joins ... - IntPoint Pt; - bool DiscardLeftSide; - if (op1->Pt.X >= Left && op1->Pt.X <= Right) - { - Pt = op1->Pt; DiscardLeftSide = (op1->Pt.X > op1b->Pt.X); - } - else if (op2->Pt.X >= Left&& op2->Pt.X <= Right) - { - Pt = op2->Pt; DiscardLeftSide = (op2->Pt.X > op2b->Pt.X); - } - else if (op1b->Pt.X >= Left && op1b->Pt.X <= Right) - { - Pt = op1b->Pt; DiscardLeftSide = op1b->Pt.X > op1->Pt.X; - } - else - { - Pt = op2b->Pt; DiscardLeftSide = (op2b->Pt.X > op2->Pt.X); - } - j->OutPt1 = op1; j->OutPt2 = op2; - return JoinHorz(op1, op1b, op2, op2b, Pt, DiscardLeftSide); - } else - { - //nb: For non-horizontal joins ... - // 1. Jr.OutPt1.Pt.Y == Jr.OutPt2.Pt.Y - // 2. Jr.OutPt1.Pt > Jr.OffPt.Y - - //make sure the polygons are correctly oriented ... - op1b = op1->Next; - while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Next; - bool Reverse1 = ((op1b->Pt.Y > op1->Pt.Y) || - !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)); - if (Reverse1) - { - op1b = op1->Prev; - while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Prev; - if ((op1b->Pt.Y > op1->Pt.Y) || - !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)) return false; - }; - op2b = op2->Next; - while ((op2b->Pt == op2->Pt) && (op2b != op2))op2b = op2b->Next; - bool Reverse2 = ((op2b->Pt.Y > op2->Pt.Y) || - !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)); - if (Reverse2) - { - op2b = op2->Prev; - while ((op2b->Pt == op2->Pt) && (op2b != op2)) op2b = op2b->Prev; - if ((op2b->Pt.Y > op2->Pt.Y) || - !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)) return false; - } - - if ((op1b == op1) || (op2b == op2) || (op1b == op2b) || - ((outRec1 == outRec2) && (Reverse1 == Reverse2))) return false; - - if (Reverse1) - { - op1b = DupOutPt(op1, false); - op2b = DupOutPt(op2, true); - op1->Prev = op2; - op2->Next = op1; - op1b->Next = op2b; - op2b->Prev = op1b; - j->OutPt1 = op1; - j->OutPt2 = op1b; - return true; - } else - { - op1b = DupOutPt(op1, true); - op2b = DupOutPt(op2, false); - op1->Next = op2; - op2->Prev = op1; - op1b->Prev = op2b; - op2b->Next = op1b; - j->OutPt1 = op1; - j->OutPt2 = op1b; - return true; - } - } -} -//---------------------------------------------------------------------- - -void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec) -{ - - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) - { - OutRec* outRec = m_PolyOuts[i]; - if (outRec->Pts && outRec->FirstLeft == OldOutRec) - { - if (Poly2ContainsPoly1(outRec->Pts, NewOutRec->Pts)) - outRec->FirstLeft = NewOutRec; - } - } -} -//---------------------------------------------------------------------- - -void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec) -{ - for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i) - { - OutRec* outRec = m_PolyOuts[i]; - if (outRec->FirstLeft == OldOutRec) outRec->FirstLeft = NewOutRec; - } -} -//---------------------------------------------------------------------- - -static OutRec* ParseFirstLeft(OutRec* FirstLeft) -{ - while (FirstLeft && !FirstLeft->Pts) - FirstLeft = FirstLeft->FirstLeft; - return FirstLeft; -} -//------------------------------------------------------------------------------ - -void Clipper::JoinCommonEdges() -{ - for (JoinList::size_type i = 0; i < m_Joins.size(); i++) - { - Join* join = m_Joins[i]; - - OutRec *outRec1 = GetOutRec(join->OutPt1->Idx); - OutRec *outRec2 = GetOutRec(join->OutPt2->Idx); - - if (!outRec1->Pts || !outRec2->Pts) continue; - - //get the polygon fragment with the correct hole state (FirstLeft) - //before calling JoinPoints() ... - OutRec *holeStateRec; - if (outRec1 == outRec2) holeStateRec = outRec1; - else if (Param1RightOfParam2(outRec1, outRec2)) holeStateRec = outRec2; - else if (Param1RightOfParam2(outRec2, outRec1)) holeStateRec = outRec1; - else holeStateRec = GetLowermostRec(outRec1, outRec2); - - if (!JoinPoints(join, outRec1, outRec2)) continue; - - if (outRec1 == outRec2) - { - //instead of joining two polygons, we've just created a new one by - //splitting one polygon into two. - outRec1->Pts = join->OutPt1; - outRec1->BottomPt = 0; - outRec2 = CreateOutRec(); - outRec2->Pts = join->OutPt2; - - //update all OutRec2.Pts Idx's ... - UpdateOutPtIdxs(*outRec2); - - //We now need to check every OutRec.FirstLeft pointer. If it points - //to OutRec1 it may need to point to OutRec2 instead ... - if (m_UsingPolyTree) - for (PolyOutList::size_type j = 0; j < m_PolyOuts.size() - 1; j++) - { - OutRec* oRec = m_PolyOuts[j]; - if (!oRec->Pts || ParseFirstLeft(oRec->FirstLeft) != outRec1 || - oRec->IsHole == outRec1->IsHole) continue; - if (Poly2ContainsPoly1(oRec->Pts, join->OutPt2)) - oRec->FirstLeft = outRec2; - } - - if (Poly2ContainsPoly1(outRec2->Pts, outRec1->Pts)) - { - //outRec2 is contained by outRec1 ... - outRec2->IsHole = !outRec1->IsHole; - outRec2->FirstLeft = outRec1; - - //fixup FirstLeft pointers that may need reassigning to OutRec1 - if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1); - - if ((outRec2->IsHole ^ m_ReverseOutput) == (Area(*outRec2) > 0)) - ReversePolyPtLinks(outRec2->Pts); - - } else if (Poly2ContainsPoly1(outRec1->Pts, outRec2->Pts)) - { - //outRec1 is contained by outRec2 ... - outRec2->IsHole = outRec1->IsHole; - outRec1->IsHole = !outRec2->IsHole; - outRec2->FirstLeft = outRec1->FirstLeft; - outRec1->FirstLeft = outRec2; - - //fixup FirstLeft pointers that may need reassigning to OutRec1 - if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2); - - if ((outRec1->IsHole ^ m_ReverseOutput) == (Area(*outRec1) > 0)) - ReversePolyPtLinks(outRec1->Pts); - } - else - { - //the 2 polygons are completely separate ... - outRec2->IsHole = outRec1->IsHole; - outRec2->FirstLeft = outRec1->FirstLeft; - - //fixup FirstLeft pointers that may need reassigning to OutRec2 - if (m_UsingPolyTree) FixupFirstLefts1(outRec1, outRec2); - } - - } else - { - //joined 2 polygons together ... - - outRec2->Pts = 0; - outRec2->BottomPt = 0; - outRec2->Idx = outRec1->Idx; - - outRec1->IsHole = holeStateRec->IsHole; - if (holeStateRec == outRec2) - outRec1->FirstLeft = outRec2->FirstLeft; - outRec2->FirstLeft = outRec1; - - //fixup FirstLeft pointers that may need reassigning to OutRec1 - if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1); - } - } -} - -//------------------------------------------------------------------------------ -// ClipperOffset support functions ... -//------------------------------------------------------------------------------ - -DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2) -{ - if(pt2.X == pt1.X && pt2.Y == pt1.Y) - return DoublePoint(0, 0); - - double Dx = (double)(pt2.X - pt1.X); - double dy = (double)(pt2.Y - pt1.Y); - double f = 1 *1.0/ std::sqrt( Dx*Dx + dy*dy ); - Dx *= f; - dy *= f; - return DoublePoint(dy, -Dx); -} - -//------------------------------------------------------------------------------ -// ClipperOffset class -//------------------------------------------------------------------------------ - -ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance) -{ - this->MiterLimit = miterLimit; - this->ArcTolerance = arcTolerance; - m_lowest.X = -1; -} -//------------------------------------------------------------------------------ - -ClipperOffset::~ClipperOffset() -{ - Clear(); -} -//------------------------------------------------------------------------------ - -void ClipperOffset::Clear() -{ - for (int i = 0; i < m_polyNodes.ChildCount(); ++i) - delete m_polyNodes.Childs[i]; - m_polyNodes.Childs.clear(); - m_lowest.X = -1; -} -//------------------------------------------------------------------------------ - -void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType) -{ - int highI = (int)path.size() - 1; - if (highI < 0) return; - PolyNode* newNode = new PolyNode(); - newNode->m_jointype = joinType; - newNode->m_endtype = endType; - - //strip duplicate points from path and also get index to the lowest point ... - if (endType == etClosedLine || endType == etClosedPolygon) - while (highI > 0 && path[0] == path[highI]) highI--; - newNode->Contour.reserve(highI + 1); - newNode->Contour.push_back(path[0]); - int j = 0, k = 0; - for (int i = 1; i <= highI; i++) - if (newNode->Contour[j] != path[i]) - { - j++; - newNode->Contour.push_back(path[i]); - if (path[i].Y > newNode->Contour[k].Y || - (path[i].Y == newNode->Contour[k].Y && - path[i].X < newNode->Contour[k].X)) k = j; - } - if ((endType == etClosedPolygon && j < 2) || - (endType != etClosedPolygon && j < 0)) - { - delete newNode; - return; - } - m_polyNodes.AddChild(*newNode); - - //if this path's lowest pt is lower than all the others then update m_lowest - if (endType != etClosedPolygon) return; - if (m_lowest.X < 0) - m_lowest = IntPoint(0, k); - else - { - IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X]->Contour[(int)m_lowest.Y]; - if (newNode->Contour[k].Y > ip.Y || - (newNode->Contour[k].Y == ip.Y && - newNode->Contour[k].X < ip.X)) - m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k); - } -} -//------------------------------------------------------------------------------ - -void ClipperOffset::AddPaths(const Paths& paths, JoinType joinType, EndType endType) -{ - for (Paths::size_type i = 0; i < paths.size(); ++i) - AddPath(paths[i], joinType, endType); -} -//------------------------------------------------------------------------------ - -void ClipperOffset::FixOrientations() -{ - //fixup orientations of all closed paths if the orientation of the - //closed path with the lowermost vertex is wrong ... - if (m_lowest.X >= 0 && - !Orientation(m_polyNodes.Childs[(int)m_lowest.X]->Contour)) - { - for (int i = 0; i < m_polyNodes.ChildCount(); ++i) - { - PolyNode& node = *m_polyNodes.Childs[i]; - if (node.m_endtype == etClosedPolygon || - (node.m_endtype == etClosedLine && Orientation(node.Contour))) - ReversePath(node.Contour); - } - } else - { - for (int i = 0; i < m_polyNodes.ChildCount(); ++i) - { - PolyNode& node = *m_polyNodes.Childs[i]; - if (node.m_endtype == etClosedLine && !Orientation(node.Contour)) - ReversePath(node.Contour); - } - } -} -//------------------------------------------------------------------------------ - -void ClipperOffset::Execute(Paths& solution, double delta) -{ - solution.clear(); - FixOrientations(); - DoOffset(delta); - - //now clean up 'corners' ... - Clipper clpr; - clpr.AddPaths(m_destPolys, ptSubject, true); - if (delta > 0) - { - clpr.Execute(ctUnion, solution, pftPositive, pftPositive); - } - else - { - IntRect r = clpr.GetBounds(); - Path outer(4); - outer[0] = IntPoint(r.left - 10, r.bottom + 10); - outer[1] = IntPoint(r.right + 10, r.bottom + 10); - outer[2] = IntPoint(r.right + 10, r.top - 10); - outer[3] = IntPoint(r.left - 10, r.top - 10); - - clpr.AddPath(outer, ptSubject, true); - clpr.ReverseSolution(true); - clpr.Execute(ctUnion, solution, pftNegative, pftNegative); - if (solution.size() > 0) solution.erase(solution.begin()); - } -} -//------------------------------------------------------------------------------ - -void ClipperOffset::Execute(PolyTree& solution, double delta) -{ - solution.Clear(); - FixOrientations(); - DoOffset(delta); - - //now clean up 'corners' ... - Clipper clpr; - clpr.AddPaths(m_destPolys, ptSubject, true); - if (delta > 0) - { - clpr.Execute(ctUnion, solution, pftPositive, pftPositive); - } - else - { - IntRect r = clpr.GetBounds(); - Path outer(4); - outer[0] = IntPoint(r.left - 10, r.bottom + 10); - outer[1] = IntPoint(r.right + 10, r.bottom + 10); - outer[2] = IntPoint(r.right + 10, r.top - 10); - outer[3] = IntPoint(r.left - 10, r.top - 10); - - clpr.AddPath(outer, ptSubject, true); - clpr.ReverseSolution(true); - clpr.Execute(ctUnion, solution, pftNegative, pftNegative); - //remove the outer PolyNode rectangle ... - if (solution.ChildCount() == 1 && solution.Childs[0]->ChildCount() > 0) - { - PolyNode* outerNode = solution.Childs[0]; - solution.Childs.reserve(outerNode->ChildCount()); - solution.Childs[0] = outerNode->Childs[0]; - for (int i = 1; i < outerNode->ChildCount(); ++i) - solution.AddChild(*outerNode->Childs[i]); - } - else - solution.Clear(); - } -} -//------------------------------------------------------------------------------ - -void ClipperOffset::DoOffset(double delta) -{ - m_destPolys.clear(); - m_delta = delta; - - //if Zero offset, just copy any CLOSED polygons to m_p and return ... - if (NEAR_ZERO(delta)) - { - m_destPolys.reserve(m_polyNodes.ChildCount()); - for (int i = 0; i < m_polyNodes.ChildCount(); i++) - { - PolyNode& node = *m_polyNodes.Childs[i]; - if (node.m_endtype == etClosedPolygon) - m_destPolys.push_back(node.Contour); - } - return; - } - - //see offset_triginometry3.svg in the documentation folder ... - if (MiterLimit > 2) m_miterLim = 2/(MiterLimit * MiterLimit); - else m_miterLim = 0.5; - - double y; - if (ArcTolerance <= 0.0) y = def_arc_tolerance; - else if (ArcTolerance > std::fabs(delta) * def_arc_tolerance) - y = std::fabs(delta) * def_arc_tolerance; - else y = ArcTolerance; - //see offset_triginometry2.svg in the documentation folder ... - double steps = pi / std::acos(1 - y / std::fabs(delta)); - if (steps > std::fabs(delta) * pi) - steps = std::fabs(delta) * pi; //ie excessive precision check - m_sin = std::sin(two_pi / steps); - m_cos = std::cos(two_pi / steps); - m_StepsPerRad = steps / two_pi; - if (delta < 0.0) m_sin = -m_sin; - - m_destPolys.reserve(m_polyNodes.ChildCount() * 2); - for (int i = 0; i < m_polyNodes.ChildCount(); i++) - { - PolyNode& node = *m_polyNodes.Childs[i]; - m_srcPoly = node.Contour; - - int len = (int)m_srcPoly.size(); - if (len == 0 || (delta <= 0 && (len < 3 || node.m_endtype != etClosedPolygon))) - continue; - - m_destPoly.clear(); - if (len == 1) - { - if (node.m_jointype == jtRound) - { - double X = 1.0, Y = 0.0; - for (cInt j = 1; j <= steps; j++) - { - m_destPoly.push_back(IntPoint( - Round(m_srcPoly[0].X + X * delta), - Round(m_srcPoly[0].Y + Y * delta))); - double X2 = X; - X = X * m_cos - m_sin * Y; - Y = X2 * m_sin + Y * m_cos; - } - } - else - { - double X = -1.0, Y = -1.0; - for (int j = 0; j < 4; ++j) - { - m_destPoly.push_back(IntPoint( - Round(m_srcPoly[0].X + X * delta), - Round(m_srcPoly[0].Y + Y * delta))); - if (X < 0) X = 1; - else if (Y < 0) Y = 1; - else X = -1; - } - } - m_destPolys.push_back(m_destPoly); - continue; - } - //build m_normals ... - m_normals.clear(); - m_normals.reserve(len); - for (int j = 0; j < len - 1; ++j) - m_normals.push_back(GetUnitNormal(m_srcPoly[j], m_srcPoly[j + 1])); - if (node.m_endtype == etClosedLine || node.m_endtype == etClosedPolygon) - m_normals.push_back(GetUnitNormal(m_srcPoly[len - 1], m_srcPoly[0])); - else - m_normals.push_back(DoublePoint(m_normals[len - 2])); - - if (node.m_endtype == etClosedPolygon) - { - int k = len - 1; - for (int j = 0; j < len; ++j) - OffsetPoint(j, k, node.m_jointype); - m_destPolys.push_back(m_destPoly); - } - else if (node.m_endtype == etClosedLine) - { - int k = len - 1; - for (int j = 0; j < len; ++j) - OffsetPoint(j, k, node.m_jointype); - m_destPolys.push_back(m_destPoly); - m_destPoly.clear(); - //re-build m_normals ... - DoublePoint n = m_normals[len -1]; - for (int j = len - 1; j > 0; j--) - m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y); - m_normals[0] = DoublePoint(-n.X, -n.Y); - k = 0; - for (int j = len - 1; j >= 0; j--) - OffsetPoint(j, k, node.m_jointype); - m_destPolys.push_back(m_destPoly); - } - else - { - int k = 0; - for (int j = 1; j < len - 1; ++j) - OffsetPoint(j, k, node.m_jointype); - - IntPoint pt1; - if (node.m_endtype == etOpenButt) - { - int j = len - 1; - pt1 = IntPoint((cInt)Round(m_srcPoly[j].X + m_normals[j].X * - delta), (cInt)Round(m_srcPoly[j].Y + m_normals[j].Y * delta)); - m_destPoly.push_back(pt1); - pt1 = IntPoint((cInt)Round(m_srcPoly[j].X - m_normals[j].X * - delta), (cInt)Round(m_srcPoly[j].Y - m_normals[j].Y * delta)); - m_destPoly.push_back(pt1); - } - else - { - int j = len - 1; - k = len - 2; - m_sinA = 0; - m_normals[j] = DoublePoint(-m_normals[j].X, -m_normals[j].Y); - if (node.m_endtype == etOpenSquare) - DoSquare(j, k); - else - DoRound(j, k); - } - - //re-build m_normals ... - for (int j = len - 1; j > 0; j--) - m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y); - m_normals[0] = DoublePoint(-m_normals[1].X, -m_normals[1].Y); - - k = len - 1; - for (int j = k - 1; j > 0; --j) OffsetPoint(j, k, node.m_jointype); - - if (node.m_endtype == etOpenButt) - { - pt1 = IntPoint((cInt)Round(m_srcPoly[0].X - m_normals[0].X * delta), - (cInt)Round(m_srcPoly[0].Y - m_normals[0].Y * delta)); - m_destPoly.push_back(pt1); - pt1 = IntPoint((cInt)Round(m_srcPoly[0].X + m_normals[0].X * delta), - (cInt)Round(m_srcPoly[0].Y + m_normals[0].Y * delta)); - m_destPoly.push_back(pt1); - } - else - { - k = 1; - m_sinA = 0; - if (node.m_endtype == etOpenSquare) - DoSquare(0, 1); - else - DoRound(0, 1); - } - m_destPolys.push_back(m_destPoly); - } - } -} -//------------------------------------------------------------------------------ - -void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype) -{ - m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y); - if (m_sinA < 0.00005 && m_sinA > -0.00005) return; - else if (m_sinA > 1.0) m_sinA = 1.0; - else if (m_sinA < -1.0) m_sinA = -1.0; - - if (m_sinA * m_delta < 0) - { - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta))); - m_destPoly.push_back(m_srcPoly[j]); - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta))); - } - else - switch (jointype) - { - case jtMiter: - { - double r = 1 + (m_normals[j].X * m_normals[k].X + - m_normals[j].Y * m_normals[k].Y); - if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k); - break; - } - case jtSquare: DoSquare(j, k); break; - case jtRound: DoRound(j, k); break; - } - k = j; -} -//------------------------------------------------------------------------------ - -void ClipperOffset::DoSquare(int j, int k) -{ - double dx = std::tan(std::atan2(m_sinA, - m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y) / 4); - m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + m_delta * (m_normals[k].X - m_normals[k].Y * dx)), - Round(m_srcPoly[j].Y + m_delta * (m_normals[k].Y + m_normals[k].X * dx)))); - m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + m_delta * (m_normals[j].X + m_normals[j].Y * dx)), - Round(m_srcPoly[j].Y + m_delta * (m_normals[j].Y - m_normals[j].X * dx)))); -} -//------------------------------------------------------------------------------ - -void ClipperOffset::DoMiter(int j, int k, double r) -{ - double q = m_delta / r; - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + (m_normals[k].X + m_normals[j].X) * q), - Round(m_srcPoly[j].Y + (m_normals[k].Y + m_normals[j].Y) * q))); -} -//------------------------------------------------------------------------------ - -void ClipperOffset::DoRound(int j, int k) -{ - double a = std::atan2(m_sinA, - m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y); - int steps = (int)Round(m_StepsPerRad * std::fabs(a)); - - double X = m_normals[k].X, Y = m_normals[k].Y, X2; - for (int i = 0; i < steps; ++i) - { - m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + X * m_delta), - Round(m_srcPoly[j].Y + Y * m_delta))); - X2 = X; - X = X * m_cos - m_sin * Y; - Y = X2 * m_sin + Y * m_cos; - } - m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + m_normals[j].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta))); -} - -//------------------------------------------------------------------------------ -// Miscellaneous public functions -//------------------------------------------------------------------------------ - -void Clipper::DoSimplePolygons() -{ - PolyOutList::size_type i = 0; - while (i < m_PolyOuts.size()) - { - OutRec* outrec = m_PolyOuts[i++]; - OutPt* op = outrec->Pts; - if (!op) continue; - do //for each Pt in Polygon until duplicate found do ... - { - OutPt* op2 = op->Next; - while (op2 != outrec->Pts) - { - if ((op->Pt == op2->Pt) && op2->Next != op && op2->Prev != op) - { - //split the polygon into two ... - OutPt* op3 = op->Prev; - OutPt* op4 = op2->Prev; - op->Prev = op4; - op4->Next = op; - op2->Prev = op3; - op3->Next = op2; - - outrec->Pts = op; - OutRec* outrec2 = CreateOutRec(); - outrec2->Pts = op2; - UpdateOutPtIdxs(*outrec2); - if (Poly2ContainsPoly1(outrec2->Pts, outrec->Pts)) - { - //OutRec2 is contained by OutRec1 ... - outrec2->IsHole = !outrec->IsHole; - outrec2->FirstLeft = outrec; - } - else - if (Poly2ContainsPoly1(outrec->Pts, outrec2->Pts)) - { - //OutRec1 is contained by OutRec2 ... - outrec2->IsHole = outrec->IsHole; - outrec->IsHole = !outrec2->IsHole; - outrec2->FirstLeft = outrec->FirstLeft; - outrec->FirstLeft = outrec2; - } else - { - //the 2 polygons are separate ... - outrec2->IsHole = outrec->IsHole; - outrec2->FirstLeft = outrec->FirstLeft; - } - op2 = op; //ie get ready for the Next iteration - } - op2 = op2->Next; - } - op = op->Next; - } - while (op != outrec->Pts); - } -} -//------------------------------------------------------------------------------ - -void ReversePath(Path& p) -{ - std::reverse(p.begin(), p.end()); -} -//------------------------------------------------------------------------------ - -void ReversePaths(Paths& p) -{ - for (Paths::size_type i = 0; i < p.size(); ++i) - ReversePath(p[i]); -} -//------------------------------------------------------------------------------ - -void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType) -{ - Clipper c; - c.StrictlySimple(true); - c.AddPath(in_poly, ptSubject, true); - c.Execute(ctUnion, out_polys, fillType, fillType); -} -//------------------------------------------------------------------------------ - -void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType) -{ - Clipper c; - c.StrictlySimple(true); - c.AddPaths(in_polys, ptSubject, true); - c.Execute(ctUnion, out_polys, fillType, fillType); -} -//------------------------------------------------------------------------------ - -void SimplifyPolygons(Paths &polys, PolyFillType fillType) -{ - SimplifyPolygons(polys, polys, fillType); -} -//------------------------------------------------------------------------------ - -inline double DistanceSqrd(const IntPoint& pt1, const IntPoint& pt2) -{ - double Dx = ((double)pt1.X - pt2.X); - double dy = ((double)pt1.Y - pt2.Y); - return (Dx*Dx + dy*dy); -} -//------------------------------------------------------------------------------ - -double DistanceFromLineSqrd( - const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2) -{ - //The equation of a line in general form (Ax + By + C = 0) - //given 2 points (x¹,y¹) & (x²,y²) is ... - //(y¹ - y²)x + (x² - x¹)y + (y² - y¹)x¹ - (x² - x¹)y¹ = 0 - //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹ - //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²) - //see http://en.wikipedia.org/wiki/Perpendicular_distance - double A = double(ln1.Y - ln2.Y); - double B = double(ln2.X - ln1.X); - double C = A * ln1.X + B * ln1.Y; - C = A * pt.X + B * pt.Y - C; - return (C * C) / (A * A + B * B); -} -//--------------------------------------------------------------------------- - -bool SlopesNearCollinear(const IntPoint& pt1, - const IntPoint& pt2, const IntPoint& pt3, double distSqrd) -{ - return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd; -} -//------------------------------------------------------------------------------ - -bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd) -{ - double Dx = (double)pt1.X - pt2.X; - double dy = (double)pt1.Y - pt2.Y; - return ((Dx * Dx) + (dy * dy) <= distSqrd); -} -//------------------------------------------------------------------------------ - -OutPt* ExcludeOp(OutPt* op) -{ - OutPt* result = op->Prev; - result->Next = op->Next; - op->Next->Prev = result; - result->Idx = 0; - return result; -} -//------------------------------------------------------------------------------ - -void CleanPolygon(const Path& in_poly, Path& out_poly, double distance) -{ - //distance = proximity in units/pixels below which vertices - //will be stripped. Default ~= sqrt(2). - - size_t size = in_poly.size(); - - if (size == 0) - { - out_poly.clear(); - return; - } - - OutPt* outPts = new OutPt[size]; - for (size_t i = 0; i < size; ++i) - { - outPts[i].Pt = in_poly[i]; - outPts[i].Next = &outPts[(i + 1) % size]; - outPts[i].Next->Prev = &outPts[i]; - outPts[i].Idx = 0; - } - - double distSqrd = distance * distance; - OutPt* op = &outPts[0]; - while (op->Idx == 0 && op->Next != op->Prev) - { - if (PointsAreClose(op->Pt, op->Prev->Pt, distSqrd)) - { - op = ExcludeOp(op); - size--; - } - else if (PointsAreClose(op->Prev->Pt, op->Next->Pt, distSqrd)) - { - ExcludeOp(op->Next); - op = ExcludeOp(op); - size -= 2; - } - else if (SlopesNearCollinear(op->Prev->Pt, op->Pt, op->Next->Pt, distSqrd)) - { - op = ExcludeOp(op); - size--; - } - else - { - op->Idx = 1; - op = op->Next; - } - } - - if (size < 3) size = 0; - out_poly.resize(size); - for (size_t i = 0; i < size; ++i) - { - out_poly[i] = op->Pt; - op = op->Next; - } - delete [] outPts; -} -//------------------------------------------------------------------------------ - -void CleanPolygon(Path& poly, double distance) -{ - CleanPolygon(poly, poly, distance); -} -//------------------------------------------------------------------------------ - -void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance) -{ - for (Paths::size_type i = 0; i < in_polys.size(); ++i) - CleanPolygon(in_polys[i], out_polys[i], distance); -} -//------------------------------------------------------------------------------ - -void CleanPolygons(Paths& polys, double distance) -{ - CleanPolygons(polys, polys, distance); -} -//------------------------------------------------------------------------------ - -void Minkowski(const Path& poly, const Path& path, - Paths& solution, bool isSum, bool isClosed) -{ - int delta = (isClosed ? 1 : 0); - size_t polyCnt = poly.size(); - size_t pathCnt = path.size(); - Paths pp; - pp.reserve(pathCnt); - if (isSum) - for (size_t i = 0; i < pathCnt; ++i) - { - Path p; - p.reserve(polyCnt); - for (size_t j = 0; j < poly.size(); ++j) - p.push_back(IntPoint(path[i].X + poly[j].X, path[i].Y + poly[j].Y)); - pp.push_back(p); - } - else - for (size_t i = 0; i < pathCnt; ++i) - { - Path p; - p.reserve(polyCnt); - for (size_t j = 0; j < poly.size(); ++j) - p.push_back(IntPoint(path[i].X - poly[j].X, path[i].Y - poly[j].Y)); - pp.push_back(p); - } - - Paths quads; - quads.reserve((pathCnt + delta) * (polyCnt + 1)); - for (size_t i = 0; i < pathCnt - 1 + delta; ++i) - for (size_t j = 0; j < polyCnt; ++j) - { - Path quad; - quad.reserve(4); - quad.push_back(pp[i % pathCnt][j % polyCnt]); - quad.push_back(pp[(i + 1) % pathCnt][j % polyCnt]); - quad.push_back(pp[(i + 1) % pathCnt][(j + 1) % polyCnt]); - quad.push_back(pp[i % pathCnt][(j + 1) % polyCnt]); - if (!Orientation(quad)) ReversePath(quad); - quads.push_back(quad); - } - - Clipper c; - c.AddPaths(quads, ptSubject, true); - c.Execute(ctUnion, solution, pftNonZero, pftNonZero); -} -//------------------------------------------------------------------------------ - -void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed) -{ - Minkowski(pattern, path, solution, true, pathIsClosed); -} -//------------------------------------------------------------------------------ - -void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, - PolyFillType pathFillType, bool pathIsClosed) -{ - Clipper c; - for (size_t i = 0; i < paths.size(); ++i) - { - Paths tmp; - Minkowski(pattern, paths[i], tmp, true, pathIsClosed); - c.AddPaths(tmp, ptSubject, true); - } - if (pathIsClosed) c.AddPaths(paths, ptClip, true); - c.Execute(ctUnion, solution, pathFillType, pathFillType); -} -//------------------------------------------------------------------------------ - -void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution) -{ - Minkowski(poly1, poly2, solution, false, true); -} -//------------------------------------------------------------------------------ - -enum NodeType {ntAny, ntOpen, ntClosed}; - -void AddPolyNodeToPolygons(const PolyNode& polynode, NodeType nodetype, Paths& paths) -{ - bool match = true; - if (nodetype == ntClosed) match = !polynode.IsOpen(); - else if (nodetype == ntOpen) return; - - if (!polynode.Contour.empty() && match) - paths.push_back(polynode.Contour); - for (int i = 0; i < polynode.ChildCount(); ++i) - AddPolyNodeToPolygons(*polynode.Childs[i], nodetype, paths); -} -//------------------------------------------------------------------------------ - -void PolyTreeToPaths(const PolyTree& polytree, Paths& paths) -{ - paths.resize(0); - paths.reserve(polytree.Total()); - AddPolyNodeToPolygons(polytree, ntAny, paths); -} -//------------------------------------------------------------------------------ - -void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths) -{ - paths.resize(0); - paths.reserve(polytree.Total()); - AddPolyNodeToPolygons(polytree, ntClosed, paths); -} -//------------------------------------------------------------------------------ - -void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths) -{ - paths.resize(0); - paths.reserve(polytree.Total()); - //Open paths are top level only, so ... - for (int i = 0; i < polytree.ChildCount(); ++i) - if (polytree.Childs[i]->IsOpen()) - paths.push_back(polytree.Childs[i]->Contour); -} -//------------------------------------------------------------------------------ - -std::ostream& operator <<(std::ostream &s, const IntPoint &p) -{ - s << "(" << p.X << "," << p.Y << ")"; - return s; -} -//------------------------------------------------------------------------------ - -std::ostream& operator <<(std::ostream &s, const Path &p) -{ - if (p.empty()) return s; - Path::size_type last = p.size() -1; - for (Path::size_type i = 0; i < last; i++) - s << "(" << p[i].X << "," << p[i].Y << "), "; - s << "(" << p[last].X << "," << p[last].Y << ")\n"; - return s; -} -//------------------------------------------------------------------------------ - -std::ostream& operator <<(std::ostream &s, const Paths &p) -{ - for (Paths::size_type i = 0; i < p.size(); i++) - s << p[i]; - s << "\n"; - return s; -} -//------------------------------------------------------------------------------ - -#ifdef use_deprecated - -void OffsetPaths(const Paths &in_polys, Paths &out_polys, - double delta, JoinType jointype, EndType_ endtype, double limit) -{ - ClipperOffset co(limit, limit); - co.AddPaths(in_polys, jointype, (EndType)endtype); - co.Execute(out_polys, delta); -} -//------------------------------------------------------------------------------ - -#endif - - -} //ClipperLib namespace diff --git a/sources/clipper/clipper.hpp b/sources/clipper/clipper.hpp deleted file mode 100755 index 84870141..00000000 --- a/sources/clipper/clipper.hpp +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* -* * -* Author : Angus Johnson * -* Version : 6.1.3a * -* Date : 22 January 2014 * -* Website : http://www.angusj.com * -* Copyright : Angus Johnson 2010-2014 * -* * -* License: * -* Use, modification & distribution is subject to Boost Software License Ver 1. * -* http://www.boost.org/LICENSE_1_0.txt * -* * -* Attributions: * -* The code in this library is an extension of Bala Vatti's clipping algorithm: * -* "A generic solution to polygon clipping" * -* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. * -* http://portal.acm.org/citation.cfm?id=129906 * -* * -* Computer graphics and geometric modeling: implementation and algorithms * -* By Max K. Agoston * -* Springer; 1 edition (January 4, 2005) * -* http://books.google.com/books?q=vatti+clipping+agoston * -* * -* See also: * -* "Polygon Offsetting by Computing Winding Numbers" * -* Paper no. DETC2005-85513 pp. 565-575 * -* ASME 2005 International Design Engineering Technical Conferences * -* and Computers and Information in Engineering Conference (IDETC/CIE2005) * -* September 24-28, 2005 , Long Beach, California, USA * -* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * -* * -*******************************************************************************/ - -#ifndef clipper_hpp -#define clipper_hpp - -#define CLIPPER_VERSION "6.1.3" - -//use_int32: When enabled 32bit ints are used instead of 64bit ints. This -//improve performance but coordinate values are limited to the range +/- 46340 -//#define use_int32 - -//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance. -//#define use_xyz - -//use_lines: Enables line clipping. Adds a very minor cost to performance. -//#define use_lines - -//use_deprecated: Enables support for the obsolete OffsetPaths() function -//which has been replace with the ClipperOffset class. -#define use_deprecated - -#include -#include -#include -#include -#include -#include -#include - -namespace ClipperLib { - -enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; -enum PolyType { ptSubject, ptClip }; -//By far the most widely used winding rules for polygon filling are -//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32) -//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL) -//see http://glprogramming.com/red/chapter11.html -enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; - -#ifdef use_int32 -typedef int cInt; -typedef unsigned int cUInt; -#else -typedef signed long long cInt; -typedef unsigned long long cUInt; -#endif - -struct IntPoint { - cInt X; - cInt Y; -#ifdef use_xyz - cInt Z; - IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {}; -#else - IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {}; -#endif - - friend inline bool operator== (const IntPoint& a, const IntPoint& b) - { - return a.X == b.X && a.Y == b.Y; - } - friend inline bool operator!= (const IntPoint& a, const IntPoint& b) - { - return a.X != b.X || a.Y != b.Y; - } -}; -//------------------------------------------------------------------------------ - -typedef std::vector< IntPoint > Path; -typedef std::vector< Path > Paths; - -inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;} -inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;} - -std::ostream& operator <<(std::ostream &s, const IntPoint &p); -std::ostream& operator <<(std::ostream &s, const Path &p); -std::ostream& operator <<(std::ostream &s, const Paths &p); - -struct DoublePoint -{ - double X; - double Y; - DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {} - DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {} -}; -//------------------------------------------------------------------------------ - -#ifdef use_xyz -typedef void (*TZFillCallback)(IntPoint& z1, IntPoint& z2, IntPoint& pt); -#endif - -enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4}; -enum JoinType {jtSquare, jtRound, jtMiter}; -enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound}; -#ifdef use_deprecated - enum EndType_ {etClosed, etButt = 2, etSquare, etRound}; -#endif - -class PolyNode; -typedef std::vector< PolyNode* > PolyNodes; - -class PolyNode -{ -public: - PolyNode(); - Path Contour; - PolyNodes Childs; - PolyNode* Parent; - PolyNode* GetNext() const; - bool IsHole() const; - bool IsOpen() const; - int ChildCount() const; -private: - unsigned Index; //node index in Parent.Childs - bool m_IsOpen; - JoinType m_jointype; - EndType m_endtype; - PolyNode* GetNextSiblingUp() const; - void AddChild(PolyNode& child); - friend class Clipper; //to access Index - friend class ClipperOffset; -}; - -class PolyTree: public PolyNode -{ -public: - ~PolyTree(){Clear();}; - PolyNode* GetFirst() const; - void Clear(); - int Total() const; -private: - PolyNodes AllNodes; - friend class Clipper; //to access AllNodes -}; - -bool Orientation(const Path &poly); -double Area(const Path &poly); -int PointInPolygon(const IntPoint &pt, const Path &path); - -#ifdef use_deprecated - void OffsetPaths(const Paths &in_polys, Paths &out_polys, - double delta, JoinType jointype, EndType_ endtype, double limit = 0); -#endif - -void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd); -void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd); -void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd); - -void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415); -void CleanPolygon(Path& poly, double distance = 1.415); -void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415); -void CleanPolygons(Paths& polys, double distance = 1.415); - -void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed); -void MinkowskiSum(const Path& pattern, const Paths& paths, - Paths& solution, PolyFillType pathFillType, bool pathIsClosed); -void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution); - -void PolyTreeToPaths(const PolyTree& polytree, Paths& paths); -void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths); -void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths); - -void ReversePath(Path& p); -void ReversePaths(Paths& p); - -struct IntRect { cInt left; cInt top; cInt right; cInt bottom; }; - -//enums that are used internally ... -enum EdgeSide { esLeft = 1, esRight = 2}; - -//forward declarations (for stuff used internally) ... -struct TEdge; -struct IntersectNode; -struct LocalMinima; -struct Scanbeam; -struct OutPt; -struct OutRec; -struct Join; - -typedef std::vector < OutRec* > PolyOutList; -typedef std::vector < TEdge* > EdgeList; -typedef std::vector < Join* > JoinList; -typedef std::vector < IntersectNode* > IntersectList; - - -//------------------------------------------------------------------------------ - -//ClipperBase is the ancestor to the Clipper class. It should not be -//instantiated directly. This class simply abstracts the conversion of sets of -//polygon coordinates into edge objects that are stored in a LocalMinima list. -class ClipperBase -{ -public: - ClipperBase(); - virtual ~ClipperBase(); - bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed); - bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed); - virtual void Clear(); - IntRect GetBounds(); - bool PreserveCollinear() {return m_PreserveCollinear;}; - void PreserveCollinear(bool value) {m_PreserveCollinear = value;}; -protected: - void DisposeLocalMinimaList(); - TEdge* AddBoundsToLML(TEdge *e, bool IsClosed); - void PopLocalMinima(); - virtual void Reset(); - TEdge* ProcessBound(TEdge* E, bool IsClockwise); - void InsertLocalMinima(LocalMinima *newLm); - void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed); - TEdge* DescendToMin(TEdge *&E); - void AscendToMax(TEdge *&E, bool Appending, bool IsClosed); - LocalMinima *m_CurrentLM; - LocalMinima *m_MinimaList; - bool m_UseFullRange; - EdgeList m_edges; - bool m_PreserveCollinear; - bool m_HasOpenPaths; -}; -//------------------------------------------------------------------------------ - -class Clipper : public virtual ClipperBase -{ -public: - Clipper(int initOptions = 0); - ~Clipper(); - bool Execute(ClipType clipType, - Paths &solution, - PolyFillType subjFillType = pftEvenOdd, - PolyFillType clipFillType = pftEvenOdd); - bool Execute(ClipType clipType, - PolyTree &polytree, - PolyFillType subjFillType = pftEvenOdd, - PolyFillType clipFillType = pftEvenOdd); - bool ReverseSolution() {return m_ReverseOutput;}; - void ReverseSolution(bool value) {m_ReverseOutput = value;}; - bool StrictlySimple() {return m_StrictSimple;}; - void StrictlySimple(bool value) {m_StrictSimple = value;}; - //set the callback function for z value filling on intersections (otherwise Z is 0) -#ifdef use_xyz - void ZFillFunction(TZFillCallback zFillFunc); -#endif -protected: - void Reset(); - virtual bool ExecuteInternal(); -private: - PolyOutList m_PolyOuts; - JoinList m_Joins; - JoinList m_GhostJoins; - IntersectList m_IntersectList; - ClipType m_ClipType; - std::set< cInt, std::greater > m_Scanbeam; - TEdge *m_ActiveEdges; - TEdge *m_SortedEdges; - bool m_ExecuteLocked; - PolyFillType m_ClipFillType; - PolyFillType m_SubjFillType; - bool m_ReverseOutput; - bool m_UsingPolyTree; - bool m_StrictSimple; -#ifdef use_xyz - TZFillCallback m_ZFill; //custom callback -#endif - void SetWindingCount(TEdge& edge); - bool IsEvenOddFillType(const TEdge& edge) const; - bool IsEvenOddAltFillType(const TEdge& edge) const; - void InsertScanbeam(const cInt Y); - cInt PopScanbeam(); - void InsertLocalMinimaIntoAEL(const cInt botY); - void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge); - void AddEdgeToSEL(TEdge *edge); - void CopyAELToSEL(); - void DeleteFromSEL(TEdge *e); - void DeleteFromAEL(TEdge *e); - void UpdateEdgeIntoAEL(TEdge *&e); - void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2); - bool IsContributing(const TEdge& edge) const; - bool IsTopHorz(const cInt XPos); - void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2); - void DoMaxima(TEdge *e); - void PrepareHorzJoins(TEdge* horzEdge, bool isTopOfScanbeam); - void ProcessHorizontals(bool IsTopOfScanbeam); - void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam); - void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); - OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); - OutRec* GetOutRec(int idx); - void AppendPolygon(TEdge *e1, TEdge *e2); - void IntersectEdges(TEdge *e1, TEdge *e2, - const IntPoint &pt, bool protect = false); - OutRec* CreateOutRec(); - OutPt* AddOutPt(TEdge *e, const IntPoint &pt); - void DisposeAllOutRecs(); - void DisposeOutRec(PolyOutList::size_type index); - bool ProcessIntersections(const cInt botY, const cInt topY); - void BuildIntersectList(const cInt botY, const cInt topY); - void ProcessIntersectList(); - void ProcessEdgesAtTopOfScanbeam(const cInt topY); - void BuildResult(Paths& polys); - void BuildResult2(PolyTree& polytree); - void SetHoleState(TEdge *e, OutRec *outrec); - void DisposeIntersectNodes(); - bool FixupIntersectionOrder(); - void FixupOutPolygon(OutRec &outrec); - bool IsHole(TEdge *e); - bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl); - void FixHoleLinkage(OutRec &outrec); - void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt); - void ClearJoins(); - void ClearGhostJoins(); - void AddGhostJoin(OutPt *op, const IntPoint offPt); - bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2); - void JoinCommonEdges(); - void DoSimplePolygons(); - void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec); - void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec); -#ifdef use_xyz - void SetZ(IntPoint& pt, TEdge& e); -#endif -}; -//------------------------------------------------------------------------------ - -class ClipperOffset -{ -public: - ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25); - ~ClipperOffset(); - void AddPath(const Path& path, JoinType joinType, EndType endType); - void AddPaths(const Paths& paths, JoinType joinType, EndType endType); - void Execute(Paths& solution, double delta); - void Execute(PolyTree& solution, double delta); - void Clear(); - double MiterLimit; - double ArcTolerance; -private: - Paths m_destPolys; - Path m_srcPoly; - Path m_destPoly; - std::vector m_normals; - double m_delta, m_sinA, m_sin, m_cos; - double m_miterLim, m_StepsPerRad; - IntPoint m_lowest; - PolyNode m_polyNodes; - - void FixOrientations(); - void DoOffset(double delta); - void OffsetPoint(int j, int& k, JoinType jointype); - void DoSquare(int j, int k); - void DoMiter(int j, int k, double r); - void DoRound(int j, int k); -}; -//------------------------------------------------------------------------------ - -class clipperException : public std::exception -{ - public: - clipperException(const char* description): m_descr(description) {} - virtual ~clipperException() throw() {} - virtual const char* what() const throw() {return m_descr.c_str();} - private: - std::string m_descr; -}; -//------------------------------------------------------------------------------ - -} //ClipperLib namespace - -#endif //clipper_hpp - - diff --git a/sources/firefox/GLConsts.h b/sources/firefox/GLConsts.h deleted file mode 100644 index 17219f24..00000000 --- a/sources/firefox/GLConsts.h +++ /dev/null @@ -1,6825 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GLCONSTS_H_ -#define GLCONSTS_H_ - -/** - * GENERATED FILE, DO NOT MODIFY DIRECTLY. - * This is a file generated directly from the official OpenGL registry - * xml available http://www.opengl.org/registry/#specfiles. - * - * To generate this file, see tutorial in 'GLParseRegistryXML.py'. - */ - -// GL -#define LOCAL_GL_1PASS_EXT 0x80A1 -#define LOCAL_GL_1PASS_SGIS 0x80A1 -#define LOCAL_GL_2D 0x0600 -#define LOCAL_GL_2PASS_0_EXT 0x80A2 -#define LOCAL_GL_2PASS_0_SGIS 0x80A2 -#define LOCAL_GL_2PASS_1_EXT 0x80A3 -#define LOCAL_GL_2PASS_1_SGIS 0x80A3 -#define LOCAL_GL_2X_BIT_ATI 0x00000001 -#define LOCAL_GL_2_BYTES 0x1407 -#define LOCAL_GL_2_BYTES_NV 0x1407 -#define LOCAL_GL_3D 0x0601 -#define LOCAL_GL_3DC_XY_AMD 0x87FA -#define LOCAL_GL_3DC_X_AMD 0x87F9 -#define LOCAL_GL_3D_COLOR 0x0602 -#define LOCAL_GL_3D_COLOR_TEXTURE 0x0603 -#define LOCAL_GL_3_BYTES 0x1408 -#define LOCAL_GL_3_BYTES_NV 0x1408 -#define LOCAL_GL_422_AVERAGE_EXT 0x80CE -#define LOCAL_GL_422_EXT 0x80CC -#define LOCAL_GL_422_REV_AVERAGE_EXT 0x80CF -#define LOCAL_GL_422_REV_EXT 0x80CD -#define LOCAL_GL_4D_COLOR_TEXTURE 0x0604 -#define LOCAL_GL_4PASS_0_EXT 0x80A4 -#define LOCAL_GL_4PASS_0_SGIS 0x80A4 -#define LOCAL_GL_4PASS_1_EXT 0x80A5 -#define LOCAL_GL_4PASS_1_SGIS 0x80A5 -#define LOCAL_GL_4PASS_2_EXT 0x80A6 -#define LOCAL_GL_4PASS_2_SGIS 0x80A6 -#define LOCAL_GL_4PASS_3_EXT 0x80A7 -#define LOCAL_GL_4PASS_3_SGIS 0x80A7 -#define LOCAL_GL_4X_BIT_ATI 0x00000002 -#define LOCAL_GL_4_BYTES 0x1409 -#define LOCAL_GL_4_BYTES_NV 0x1409 -#define LOCAL_GL_8X_BIT_ATI 0x00000004 -#define LOCAL_GL_ABGR_EXT 0x8000 -#define LOCAL_GL_ACCUM 0x0100 -#define LOCAL_GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define LOCAL_GL_ACCUM_ALPHA_BITS 0x0D5B -#define LOCAL_GL_ACCUM_BLUE_BITS 0x0D5A -#define LOCAL_GL_ACCUM_BUFFER_BIT 0x00000200 -#define LOCAL_GL_ACCUM_CLEAR_VALUE 0x0B80 -#define LOCAL_GL_ACCUM_GREEN_BITS 0x0D59 -#define LOCAL_GL_ACCUM_RED_BITS 0x0D58 -#define LOCAL_GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define LOCAL_GL_ACTIVE_ATTRIBUTES 0x8B89 -#define LOCAL_GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define LOCAL_GL_ACTIVE_PROGRAM 0x8259 -#define LOCAL_GL_ACTIVE_PROGRAM_EXT 0x8B8D -#define LOCAL_GL_ACTIVE_RESOURCES 0x92F5 -#define LOCAL_GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#define LOCAL_GL_ACTIVE_SUBROUTINES 0x8DE5 -#define LOCAL_GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define LOCAL_GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define LOCAL_GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define LOCAL_GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define LOCAL_GL_ACTIVE_TEXTURE 0x84E0 -#define LOCAL_GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define LOCAL_GL_ACTIVE_UNIFORMS 0x8B86 -#define LOCAL_GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define LOCAL_GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define LOCAL_GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define LOCAL_GL_ACTIVE_VARIABLES 0x9305 -#define LOCAL_GL_ACTIVE_VARYINGS_NV 0x8C81 -#define LOCAL_GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define LOCAL_GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define LOCAL_GL_ADD 0x0104 -#define LOCAL_GL_ADD_ATI 0x8963 -#define LOCAL_GL_ADD_BLEND_IMG 0x8C09 -#define LOCAL_GL_ADD_SIGNED 0x8574 -#define LOCAL_GL_ADD_SIGNED_ARB 0x8574 -#define LOCAL_GL_ADD_SIGNED_EXT 0x8574 -#define LOCAL_GL_ADJACENT_PAIRS_NV 0x90AE -#define LOCAL_GL_AFFINE_2D_NV 0x9092 -#define LOCAL_GL_AFFINE_3D_NV 0x9094 -#define LOCAL_GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define LOCAL_GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define LOCAL_GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define LOCAL_GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define LOCAL_GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define LOCAL_GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define LOCAL_GL_ALL_ATTRIB_BITS 0xFFFFFFFF -#define LOCAL_GL_ALL_BARRIER_BITS 0xFFFFFFFF -#define LOCAL_GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF -#define LOCAL_GL_ALL_COMPLETED_NV 0x84F2 -#define LOCAL_GL_ALL_PIXELS_AMD 0xFFFFFFFF -#define LOCAL_GL_ALL_SHADER_BITS 0xFFFFFFFF -#define LOCAL_GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF -#define LOCAL_GL_ALL_STATIC_DATA_IBM 103060 -#define LOCAL_GL_ALPHA 0x1906 -#define LOCAL_GL_ALPHA12 0x803D -#define LOCAL_GL_ALPHA12_EXT 0x803D -#define LOCAL_GL_ALPHA16 0x803E -#define LOCAL_GL_ALPHA16F_ARB 0x881C -#define LOCAL_GL_ALPHA16F_EXT 0x881C -#define LOCAL_GL_ALPHA16I_EXT 0x8D8A -#define LOCAL_GL_ALPHA16UI_EXT 0x8D78 -#define LOCAL_GL_ALPHA16_EXT 0x803E -#define LOCAL_GL_ALPHA16_SNORM 0x9018 -#define LOCAL_GL_ALPHA32F_ARB 0x8816 -#define LOCAL_GL_ALPHA32F_EXT 0x8816 -#define LOCAL_GL_ALPHA32I_EXT 0x8D84 -#define LOCAL_GL_ALPHA32UI_EXT 0x8D72 -#define LOCAL_GL_ALPHA4 0x803B -#define LOCAL_GL_ALPHA4_EXT 0x803B -#define LOCAL_GL_ALPHA8 0x803C -#define LOCAL_GL_ALPHA8I_EXT 0x8D90 -#define LOCAL_GL_ALPHA8UI_EXT 0x8D7E -#define LOCAL_GL_ALPHA8_EXT 0x803C -#define LOCAL_GL_ALPHA8_OES 0x803C -#define LOCAL_GL_ALPHA8_SNORM 0x9014 -#define LOCAL_GL_ALPHA_BIAS 0x0D1D -#define LOCAL_GL_ALPHA_BITS 0x0D55 -#define LOCAL_GL_ALPHA_FLOAT16_APPLE 0x881C -#define LOCAL_GL_ALPHA_FLOAT16_ATI 0x881C -#define LOCAL_GL_ALPHA_FLOAT32_APPLE 0x8816 -#define LOCAL_GL_ALPHA_FLOAT32_ATI 0x8816 -#define LOCAL_GL_ALPHA_INTEGER 0x8D97 -#define LOCAL_GL_ALPHA_INTEGER_EXT 0x8D97 -#define LOCAL_GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#define LOCAL_GL_ALPHA_MAX_SGIX 0x8321 -#define LOCAL_GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define LOCAL_GL_ALPHA_MIN_SGIX 0x8320 -#define LOCAL_GL_ALPHA_REF_COMMAND_NV 0x000F -#define LOCAL_GL_ALPHA_SCALE 0x0D1C -#define LOCAL_GL_ALPHA_SNORM 0x9010 -#define LOCAL_GL_ALPHA_TEST 0x0BC0 -#define LOCAL_GL_ALPHA_TEST_FUNC 0x0BC1 -#define LOCAL_GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 -#define LOCAL_GL_ALPHA_TEST_QCOM 0x0BC0 -#define LOCAL_GL_ALPHA_TEST_REF 0x0BC2 -#define LOCAL_GL_ALPHA_TEST_REF_QCOM 0x0BC2 -#define LOCAL_GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D -#define LOCAL_GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F -#define LOCAL_GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E -#define LOCAL_GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF -#define LOCAL_GL_ALREADY_SIGNALED 0x911A -#define LOCAL_GL_ALREADY_SIGNALED_APPLE 0x911A -#define LOCAL_GL_ALWAYS 0x0207 -#define LOCAL_GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define LOCAL_GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define LOCAL_GL_AMBIENT 0x1200 -#define LOCAL_GL_AMBIENT_AND_DIFFUSE 0x1602 -#define LOCAL_GL_AND 0x1501 -#define LOCAL_GL_AND_INVERTED 0x1504 -#define LOCAL_GL_AND_REVERSE 0x1502 -#define LOCAL_GL_ANY_SAMPLES_PASSED 0x8C2F -#define LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define LOCAL_GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A -#define LOCAL_GL_ANY_SAMPLES_PASSED_EXT 0x8C2F -#define LOCAL_GL_ARC_TO_NV 0xFE -#define LOCAL_GL_ARRAY_BUFFER 0x8892 -#define LOCAL_GL_ARRAY_BUFFER_ARB 0x8892 -#define LOCAL_GL_ARRAY_BUFFER_BINDING 0x8894 -#define LOCAL_GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define LOCAL_GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#define LOCAL_GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define LOCAL_GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define LOCAL_GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#define LOCAL_GL_ARRAY_SIZE 0x92FB -#define LOCAL_GL_ARRAY_STRIDE 0x92FE -#define LOCAL_GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define LOCAL_GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define LOCAL_GL_ASYNC_MARKER_SGIX 0x8329 -#define LOCAL_GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define LOCAL_GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define LOCAL_GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define LOCAL_GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#define LOCAL_GL_ATC_RGB_AMD 0x8C92 -#define LOCAL_GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define LOCAL_GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define LOCAL_GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define LOCAL_GL_ATTACHED_SHADERS 0x8B85 -#define LOCAL_GL_ATTENUATION_EXT 0x834D -#define LOCAL_GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 -#define LOCAL_GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define LOCAL_GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define LOCAL_GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define LOCAL_GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define LOCAL_GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define LOCAL_GL_AUTO_GENERATE_MIPMAP 0x8295 -#define LOCAL_GL_AUTO_NORMAL 0x0D80 -#define LOCAL_GL_AUX0 0x0409 -#define LOCAL_GL_AUX1 0x040A -#define LOCAL_GL_AUX2 0x040B -#define LOCAL_GL_AUX3 0x040C -#define LOCAL_GL_AUX_BUFFERS 0x0C00 -#define LOCAL_GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#define LOCAL_GL_AVERAGE_EXT 0x8335 -#define LOCAL_GL_AVERAGE_HP 0x8160 -#define LOCAL_GL_BACK 0x0405 -#define LOCAL_GL_BACK_LEFT 0x0402 -#define LOCAL_GL_BACK_NORMALS_HINT_PGI 0x1A223 -#define LOCAL_GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define LOCAL_GL_BACK_RIGHT 0x0403 -#define LOCAL_GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define LOCAL_GL_BEVEL_NV 0x90A6 -#define LOCAL_GL_BGR 0x80E0 -#define LOCAL_GL_BGRA 0x80E1 -#define LOCAL_GL_BGRA8_EXT 0x93A1 -#define LOCAL_GL_BGRA_EXT 0x80E1 -#define LOCAL_GL_BGRA_IMG 0x80E1 -#define LOCAL_GL_BGRA_INTEGER 0x8D9B -#define LOCAL_GL_BGRA_INTEGER_EXT 0x8D9B -#define LOCAL_GL_BGR_EXT 0x80E0 -#define LOCAL_GL_BGR_INTEGER 0x8D9A -#define LOCAL_GL_BGR_INTEGER_EXT 0x8D9A -#define LOCAL_GL_BIAS_BIT_ATI 0x00000008 -#define LOCAL_GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define LOCAL_GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 -#define LOCAL_GL_BINORMAL_ARRAY_EXT 0x843A -#define LOCAL_GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define LOCAL_GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define LOCAL_GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define LOCAL_GL_BITMAP 0x1A00 -#define LOCAL_GL_BITMAP_TOKEN 0x0704 -#define LOCAL_GL_BLEND 0x0BE2 -#define LOCAL_GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 -#define LOCAL_GL_BLEND_ADVANCED_COHERENT_NV 0x9285 -#define LOCAL_GL_BLEND_COLOR 0x8005 -#define LOCAL_GL_BLEND_COLOR_COMMAND_NV 0x000B -#define LOCAL_GL_BLEND_COLOR_EXT 0x8005 -#define LOCAL_GL_BLEND_DST 0x0BE0 -#define LOCAL_GL_BLEND_DST_ALPHA 0x80CA -#define LOCAL_GL_BLEND_DST_ALPHA_EXT 0x80CA -#define LOCAL_GL_BLEND_DST_ALPHA_OES 0x80CA -#define LOCAL_GL_BLEND_DST_RGB 0x80C8 -#define LOCAL_GL_BLEND_DST_RGB_EXT 0x80C8 -#define LOCAL_GL_BLEND_DST_RGB_OES 0x80C8 -#define LOCAL_GL_BLEND_EQUATION 0x8009 -#define LOCAL_GL_BLEND_EQUATION_ALPHA 0x883D -#define LOCAL_GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#define LOCAL_GL_BLEND_EQUATION_ALPHA_OES 0x883D -#define LOCAL_GL_BLEND_EQUATION_EXT 0x8009 -#define LOCAL_GL_BLEND_EQUATION_OES 0x8009 -#define LOCAL_GL_BLEND_EQUATION_RGB 0x8009 -#define LOCAL_GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define LOCAL_GL_BLEND_EQUATION_RGB_OES 0x8009 -#define LOCAL_GL_BLEND_OVERLAP_NV 0x9281 -#define LOCAL_GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 -#define LOCAL_GL_BLEND_SRC 0x0BE1 -#define LOCAL_GL_BLEND_SRC_ALPHA 0x80CB -#define LOCAL_GL_BLEND_SRC_ALPHA_EXT 0x80CB -#define LOCAL_GL_BLEND_SRC_ALPHA_OES 0x80CB -#define LOCAL_GL_BLEND_SRC_RGB 0x80C9 -#define LOCAL_GL_BLEND_SRC_RGB_EXT 0x80C9 -#define LOCAL_GL_BLEND_SRC_RGB_OES 0x80C9 -#define LOCAL_GL_BLOCK_INDEX 0x92FD -#define LOCAL_GL_BLUE 0x1905 -#define LOCAL_GL_BLUE_BIAS 0x0D1B -#define LOCAL_GL_BLUE_BITS 0x0D54 -#define LOCAL_GL_BLUE_BIT_ATI 0x00000004 -#define LOCAL_GL_BLUE_INTEGER 0x8D96 -#define LOCAL_GL_BLUE_INTEGER_EXT 0x8D96 -#define LOCAL_GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define LOCAL_GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define LOCAL_GL_BLUE_NV 0x1905 -#define LOCAL_GL_BLUE_SCALE 0x0D1A -#define LOCAL_GL_BOLD_BIT_NV 0x01 -#define LOCAL_GL_BOOL 0x8B56 -#define LOCAL_GL_BOOL_ARB 0x8B56 -#define LOCAL_GL_BOOL_VEC2 0x8B57 -#define LOCAL_GL_BOOL_VEC2_ARB 0x8B57 -#define LOCAL_GL_BOOL_VEC3 0x8B58 -#define LOCAL_GL_BOOL_VEC3_ARB 0x8B58 -#define LOCAL_GL_BOOL_VEC4 0x8B59 -#define LOCAL_GL_BOOL_VEC4_ARB 0x8B59 -#define LOCAL_GL_BOUNDING_BOX_NV 0x908D -#define LOCAL_GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define LOCAL_GL_BROWSER_DEFAULT_WEBGL 0x9244 -#define LOCAL_GL_BUFFER 0x82E0 -#define LOCAL_GL_BUFFER_ACCESS 0x88BB -#define LOCAL_GL_BUFFER_ACCESS_ARB 0x88BB -#define LOCAL_GL_BUFFER_ACCESS_FLAGS 0x911F -#define LOCAL_GL_BUFFER_ACCESS_OES 0x88BB -#define LOCAL_GL_BUFFER_BINDING 0x9302 -#define LOCAL_GL_BUFFER_DATA_SIZE 0x9303 -#define LOCAL_GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#define LOCAL_GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define LOCAL_GL_BUFFER_IMMUTABLE_STORAGE 0x821F -#define LOCAL_GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F -#define LOCAL_GL_BUFFER_KHR 0x82E0 -#define LOCAL_GL_BUFFER_MAPPED 0x88BC -#define LOCAL_GL_BUFFER_MAPPED_ARB 0x88BC -#define LOCAL_GL_BUFFER_MAPPED_OES 0x88BC -#define LOCAL_GL_BUFFER_MAP_LENGTH 0x9120 -#define LOCAL_GL_BUFFER_MAP_OFFSET 0x9121 -#define LOCAL_GL_BUFFER_MAP_POINTER 0x88BD -#define LOCAL_GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define LOCAL_GL_BUFFER_MAP_POINTER_OES 0x88BD -#define LOCAL_GL_BUFFER_OBJECT_APPLE 0x85B3 -#define LOCAL_GL_BUFFER_OBJECT_EXT 0x9151 -#define LOCAL_GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define LOCAL_GL_BUFFER_SIZE 0x8764 -#define LOCAL_GL_BUFFER_SIZE_ARB 0x8764 -#define LOCAL_GL_BUFFER_STORAGE_FLAGS 0x8220 -#define LOCAL_GL_BUFFER_STORAGE_FLAGS_EXT 0x8220 -#define LOCAL_GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define LOCAL_GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define LOCAL_GL_BUFFER_USAGE 0x8765 -#define LOCAL_GL_BUFFER_USAGE_ARB 0x8765 -#define LOCAL_GL_BUFFER_VARIABLE 0x92E5 -#define LOCAL_GL_BUMP_ENVMAP_ATI 0x877B -#define LOCAL_GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define LOCAL_GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define LOCAL_GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define LOCAL_GL_BUMP_TARGET_ATI 0x877C -#define LOCAL_GL_BUMP_TEX_UNITS_ATI 0x8778 -#define LOCAL_GL_BYTE 0x1400 -#define LOCAL_GL_C3F_V3F 0x2A24 -#define LOCAL_GL_C4F_N3F_V3F 0x2A26 -#define LOCAL_GL_C4UB_V2F 0x2A22 -#define LOCAL_GL_C4UB_V3F 0x2A23 -#define LOCAL_GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#define LOCAL_GL_CAVEAT_SUPPORT 0x82B8 -#define LOCAL_GL_CCW 0x0901 -#define LOCAL_GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define LOCAL_GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define LOCAL_GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define LOCAL_GL_CLAMP 0x2900 -#define LOCAL_GL_CLAMP_FRAGMENT_COLOR 0x891B -#define LOCAL_GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define LOCAL_GL_CLAMP_READ_COLOR 0x891C -#define LOCAL_GL_CLAMP_READ_COLOR_ARB 0x891C -#define LOCAL_GL_CLAMP_TO_BORDER 0x812D -#define LOCAL_GL_CLAMP_TO_BORDER_ARB 0x812D -#define LOCAL_GL_CLAMP_TO_BORDER_EXT 0x812D -#define LOCAL_GL_CLAMP_TO_BORDER_NV 0x812D -#define LOCAL_GL_CLAMP_TO_BORDER_OES 0x812D -#define LOCAL_GL_CLAMP_TO_BORDER_SGIS 0x812D -#define LOCAL_GL_CLAMP_TO_EDGE 0x812F -#define LOCAL_GL_CLAMP_TO_EDGE_SGIS 0x812F -#define LOCAL_GL_CLAMP_VERTEX_COLOR 0x891A -#define LOCAL_GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define LOCAL_GL_CLEAR 0x1500 -#define LOCAL_GL_CLEAR_BUFFER 0x82B4 -#define LOCAL_GL_CLEAR_TEXTURE 0x9365 -#define LOCAL_GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define LOCAL_GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define LOCAL_GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF -#define LOCAL_GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define LOCAL_GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 -#define LOCAL_GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 -#define LOCAL_GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define LOCAL_GL_CLIENT_STORAGE_BIT 0x0200 -#define LOCAL_GL_CLIENT_STORAGE_BIT_EXT 0x0200 -#define LOCAL_GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define LOCAL_GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 -#define LOCAL_GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 -#define LOCAL_GL_CLIP_DEPTH_MODE 0x935D -#define LOCAL_GL_CLIP_DISTANCE0 0x3000 -#define LOCAL_GL_CLIP_DISTANCE0_APPLE 0x3000 -#define LOCAL_GL_CLIP_DISTANCE0_EXT 0x3000 -#define LOCAL_GL_CLIP_DISTANCE1 0x3001 -#define LOCAL_GL_CLIP_DISTANCE1_APPLE 0x3001 -#define LOCAL_GL_CLIP_DISTANCE1_EXT 0x3001 -#define LOCAL_GL_CLIP_DISTANCE2 0x3002 -#define LOCAL_GL_CLIP_DISTANCE2_APPLE 0x3002 -#define LOCAL_GL_CLIP_DISTANCE2_EXT 0x3002 -#define LOCAL_GL_CLIP_DISTANCE3 0x3003 -#define LOCAL_GL_CLIP_DISTANCE3_APPLE 0x3003 -#define LOCAL_GL_CLIP_DISTANCE3_EXT 0x3003 -#define LOCAL_GL_CLIP_DISTANCE4 0x3004 -#define LOCAL_GL_CLIP_DISTANCE4_APPLE 0x3004 -#define LOCAL_GL_CLIP_DISTANCE4_EXT 0x3004 -#define LOCAL_GL_CLIP_DISTANCE5 0x3005 -#define LOCAL_GL_CLIP_DISTANCE5_APPLE 0x3005 -#define LOCAL_GL_CLIP_DISTANCE5_EXT 0x3005 -#define LOCAL_GL_CLIP_DISTANCE6 0x3006 -#define LOCAL_GL_CLIP_DISTANCE6_APPLE 0x3006 -#define LOCAL_GL_CLIP_DISTANCE6_EXT 0x3006 -#define LOCAL_GL_CLIP_DISTANCE7 0x3007 -#define LOCAL_GL_CLIP_DISTANCE7_APPLE 0x3007 -#define LOCAL_GL_CLIP_DISTANCE7_EXT 0x3007 -#define LOCAL_GL_CLIP_DISTANCE_NV 0x8C7A -#define LOCAL_GL_CLIP_FAR_HINT_PGI 0x1A221 -#define LOCAL_GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define LOCAL_GL_CLIP_ORIGIN 0x935C -#define LOCAL_GL_CLIP_PLANE0 0x3000 -#define LOCAL_GL_CLIP_PLANE0_IMG 0x3000 -#define LOCAL_GL_CLIP_PLANE1 0x3001 -#define LOCAL_GL_CLIP_PLANE1_IMG 0x3001 -#define LOCAL_GL_CLIP_PLANE2 0x3002 -#define LOCAL_GL_CLIP_PLANE2_IMG 0x3002 -#define LOCAL_GL_CLIP_PLANE3 0x3003 -#define LOCAL_GL_CLIP_PLANE3_IMG 0x3003 -#define LOCAL_GL_CLIP_PLANE4 0x3004 -#define LOCAL_GL_CLIP_PLANE4_IMG 0x3004 -#define LOCAL_GL_CLIP_PLANE5 0x3005 -#define LOCAL_GL_CLIP_PLANE5_IMG 0x3005 -#define LOCAL_GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#define LOCAL_GL_CLOSE_PATH_NV 0x00 -#define LOCAL_GL_CMYKA_EXT 0x800D -#define LOCAL_GL_CMYK_EXT 0x800C -#define LOCAL_GL_CND0_ATI 0x896B -#define LOCAL_GL_CND_ATI 0x896A -#define LOCAL_GL_COEFF 0x0A00 -#define LOCAL_GL_COLOR 0x1800 -#define LOCAL_GL_COLOR3_BIT_PGI 0x00010000 -#define LOCAL_GL_COLOR4_BIT_PGI 0x00020000 -#define LOCAL_GL_COLORBURN 0x929A -#define LOCAL_GL_COLORBURN_KHR 0x929A -#define LOCAL_GL_COLORBURN_NV 0x929A -#define LOCAL_GL_COLORDODGE 0x9299 -#define LOCAL_GL_COLORDODGE_KHR 0x9299 -#define LOCAL_GL_COLORDODGE_NV 0x9299 -#define LOCAL_GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define LOCAL_GL_COLOR_ARRAY 0x8076 -#define LOCAL_GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define LOCAL_GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define LOCAL_GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define LOCAL_GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define LOCAL_GL_COLOR_ARRAY_EXT 0x8076 -#define LOCAL_GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define LOCAL_GL_COLOR_ARRAY_LIST_IBM 103072 -#define LOCAL_GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define LOCAL_GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define LOCAL_GL_COLOR_ARRAY_POINTER 0x8090 -#define LOCAL_GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define LOCAL_GL_COLOR_ARRAY_SIZE 0x8081 -#define LOCAL_GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define LOCAL_GL_COLOR_ARRAY_STRIDE 0x8083 -#define LOCAL_GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define LOCAL_GL_COLOR_ARRAY_TYPE 0x8082 -#define LOCAL_GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define LOCAL_GL_COLOR_ATTACHMENT0 0x8CE0 -#define LOCAL_GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define LOCAL_GL_COLOR_ATTACHMENT0_NV 0x8CE0 -#define LOCAL_GL_COLOR_ATTACHMENT0_OES 0x8CE0 -#define LOCAL_GL_COLOR_ATTACHMENT1 0x8CE1 -#define LOCAL_GL_COLOR_ATTACHMENT10 0x8CEA -#define LOCAL_GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define LOCAL_GL_COLOR_ATTACHMENT10_NV 0x8CEA -#define LOCAL_GL_COLOR_ATTACHMENT11 0x8CEB -#define LOCAL_GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define LOCAL_GL_COLOR_ATTACHMENT11_NV 0x8CEB -#define LOCAL_GL_COLOR_ATTACHMENT12 0x8CEC -#define LOCAL_GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define LOCAL_GL_COLOR_ATTACHMENT12_NV 0x8CEC -#define LOCAL_GL_COLOR_ATTACHMENT13 0x8CED -#define LOCAL_GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define LOCAL_GL_COLOR_ATTACHMENT13_NV 0x8CED -#define LOCAL_GL_COLOR_ATTACHMENT14 0x8CEE -#define LOCAL_GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define LOCAL_GL_COLOR_ATTACHMENT14_NV 0x8CEE -#define LOCAL_GL_COLOR_ATTACHMENT15 0x8CEF -#define LOCAL_GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define LOCAL_GL_COLOR_ATTACHMENT15_NV 0x8CEF -#define LOCAL_GL_COLOR_ATTACHMENT16 0x8CF0 -#define LOCAL_GL_COLOR_ATTACHMENT17 0x8CF1 -#define LOCAL_GL_COLOR_ATTACHMENT18 0x8CF2 -#define LOCAL_GL_COLOR_ATTACHMENT19 0x8CF3 -#define LOCAL_GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define LOCAL_GL_COLOR_ATTACHMENT1_NV 0x8CE1 -#define LOCAL_GL_COLOR_ATTACHMENT2 0x8CE2 -#define LOCAL_GL_COLOR_ATTACHMENT20 0x8CF4 -#define LOCAL_GL_COLOR_ATTACHMENT21 0x8CF5 -#define LOCAL_GL_COLOR_ATTACHMENT22 0x8CF6 -#define LOCAL_GL_COLOR_ATTACHMENT23 0x8CF7 -#define LOCAL_GL_COLOR_ATTACHMENT24 0x8CF8 -#define LOCAL_GL_COLOR_ATTACHMENT25 0x8CF9 -#define LOCAL_GL_COLOR_ATTACHMENT26 0x8CFA -#define LOCAL_GL_COLOR_ATTACHMENT27 0x8CFB -#define LOCAL_GL_COLOR_ATTACHMENT28 0x8CFC -#define LOCAL_GL_COLOR_ATTACHMENT29 0x8CFD -#define LOCAL_GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define LOCAL_GL_COLOR_ATTACHMENT2_NV 0x8CE2 -#define LOCAL_GL_COLOR_ATTACHMENT3 0x8CE3 -#define LOCAL_GL_COLOR_ATTACHMENT30 0x8CFE -#define LOCAL_GL_COLOR_ATTACHMENT31 0x8CFF -#define LOCAL_GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define LOCAL_GL_COLOR_ATTACHMENT3_NV 0x8CE3 -#define LOCAL_GL_COLOR_ATTACHMENT4 0x8CE4 -#define LOCAL_GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define LOCAL_GL_COLOR_ATTACHMENT4_NV 0x8CE4 -#define LOCAL_GL_COLOR_ATTACHMENT5 0x8CE5 -#define LOCAL_GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define LOCAL_GL_COLOR_ATTACHMENT5_NV 0x8CE5 -#define LOCAL_GL_COLOR_ATTACHMENT6 0x8CE6 -#define LOCAL_GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define LOCAL_GL_COLOR_ATTACHMENT6_NV 0x8CE6 -#define LOCAL_GL_COLOR_ATTACHMENT7 0x8CE7 -#define LOCAL_GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define LOCAL_GL_COLOR_ATTACHMENT7_NV 0x8CE7 -#define LOCAL_GL_COLOR_ATTACHMENT8 0x8CE8 -#define LOCAL_GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define LOCAL_GL_COLOR_ATTACHMENT8_NV 0x8CE8 -#define LOCAL_GL_COLOR_ATTACHMENT9 0x8CE9 -#define LOCAL_GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define LOCAL_GL_COLOR_ATTACHMENT9_NV 0x8CE9 -#define LOCAL_GL_COLOR_ATTACHMENT_EXT 0x90F0 -#define LOCAL_GL_COLOR_BUFFER_BIT 0x00004000 -#define LOCAL_GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define LOCAL_GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define LOCAL_GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define LOCAL_GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define LOCAL_GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define LOCAL_GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define LOCAL_GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define LOCAL_GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define LOCAL_GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#define LOCAL_GL_COLOR_CLEAR_VALUE 0x0C22 -#define LOCAL_GL_COLOR_COMPONENTS 0x8283 -#define LOCAL_GL_COLOR_ENCODING 0x8296 -#define LOCAL_GL_COLOR_EXT 0x1800 -#define LOCAL_GL_COLOR_FLOAT_APPLE 0x8A0F -#define LOCAL_GL_COLOR_INDEX 0x1900 -#define LOCAL_GL_COLOR_INDEX12_EXT 0x80E6 -#define LOCAL_GL_COLOR_INDEX16_EXT 0x80E7 -#define LOCAL_GL_COLOR_INDEX1_EXT 0x80E2 -#define LOCAL_GL_COLOR_INDEX2_EXT 0x80E3 -#define LOCAL_GL_COLOR_INDEX4_EXT 0x80E4 -#define LOCAL_GL_COLOR_INDEX8_EXT 0x80E5 -#define LOCAL_GL_COLOR_INDEXES 0x1603 -#define LOCAL_GL_COLOR_LOGIC_OP 0x0BF2 -#define LOCAL_GL_COLOR_MATERIAL 0x0B57 -#define LOCAL_GL_COLOR_MATERIAL_FACE 0x0B55 -#define LOCAL_GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define LOCAL_GL_COLOR_MATRIX 0x80B1 -#define LOCAL_GL_COLOR_MATRIX_SGI 0x80B1 -#define LOCAL_GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define LOCAL_GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define LOCAL_GL_COLOR_RENDERABLE 0x8286 -#define LOCAL_GL_COLOR_SAMPLES_NV 0x8E20 -#define LOCAL_GL_COLOR_SUM 0x8458 -#define LOCAL_GL_COLOR_SUM_ARB 0x8458 -#define LOCAL_GL_COLOR_SUM_CLAMP_NV 0x854F -#define LOCAL_GL_COLOR_SUM_EXT 0x8458 -#define LOCAL_GL_COLOR_TABLE 0x80D0 -#define LOCAL_GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define LOCAL_GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define LOCAL_GL_COLOR_TABLE_BIAS 0x80D7 -#define LOCAL_GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define LOCAL_GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define LOCAL_GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define LOCAL_GL_COLOR_TABLE_FORMAT 0x80D8 -#define LOCAL_GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define LOCAL_GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define LOCAL_GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define LOCAL_GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define LOCAL_GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#define LOCAL_GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define LOCAL_GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define LOCAL_GL_COLOR_TABLE_RED_SIZE 0x80DA -#define LOCAL_GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define LOCAL_GL_COLOR_TABLE_SCALE 0x80D6 -#define LOCAL_GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define LOCAL_GL_COLOR_TABLE_SGI 0x80D0 -#define LOCAL_GL_COLOR_TABLE_WIDTH 0x80D9 -#define LOCAL_GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define LOCAL_GL_COLOR_WRITEMASK 0x0C23 -#define LOCAL_GL_COMBINE 0x8570 -#define LOCAL_GL_COMBINE4_NV 0x8503 -#define LOCAL_GL_COMBINER0_NV 0x8550 -#define LOCAL_GL_COMBINER1_NV 0x8551 -#define LOCAL_GL_COMBINER2_NV 0x8552 -#define LOCAL_GL_COMBINER3_NV 0x8553 -#define LOCAL_GL_COMBINER4_NV 0x8554 -#define LOCAL_GL_COMBINER5_NV 0x8555 -#define LOCAL_GL_COMBINER6_NV 0x8556 -#define LOCAL_GL_COMBINER7_NV 0x8557 -#define LOCAL_GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define LOCAL_GL_COMBINER_AB_OUTPUT_NV 0x854A -#define LOCAL_GL_COMBINER_BIAS_NV 0x8549 -#define LOCAL_GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define LOCAL_GL_COMBINER_CD_OUTPUT_NV 0x854B -#define LOCAL_GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define LOCAL_GL_COMBINER_INPUT_NV 0x8542 -#define LOCAL_GL_COMBINER_MAPPING_NV 0x8543 -#define LOCAL_GL_COMBINER_MUX_SUM_NV 0x8547 -#define LOCAL_GL_COMBINER_SCALE_NV 0x8548 -#define LOCAL_GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define LOCAL_GL_COMBINE_ALPHA 0x8572 -#define LOCAL_GL_COMBINE_ALPHA_ARB 0x8572 -#define LOCAL_GL_COMBINE_ALPHA_EXT 0x8572 -#define LOCAL_GL_COMBINE_ARB 0x8570 -#define LOCAL_GL_COMBINE_EXT 0x8570 -#define LOCAL_GL_COMBINE_RGB 0x8571 -#define LOCAL_GL_COMBINE_RGB_ARB 0x8571 -#define LOCAL_GL_COMBINE_RGB_EXT 0x8571 -#define LOCAL_GL_COMMAND_BARRIER_BIT 0x00000040 -#define LOCAL_GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define LOCAL_GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -#define LOCAL_GL_COMPARE_REF_TO_TEXTURE 0x884E -#define LOCAL_GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E -#define LOCAL_GL_COMPARE_R_TO_TEXTURE 0x884E -#define LOCAL_GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#define LOCAL_GL_COMPATIBLE_SUBROUTINES 0x8E4B -#define LOCAL_GL_COMPILE 0x1300 -#define LOCAL_GL_COMPILE_AND_EXECUTE 0x1301 -#define LOCAL_GL_COMPILE_STATUS 0x8B81 -#define LOCAL_GL_COMPLETION_STATUS_ARB 0x91B1 -#define LOCAL_GL_COMPRESSED_ALPHA 0x84E9 -#define LOCAL_GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define LOCAL_GL_COMPRESSED_INTENSITY 0x84EC -#define LOCAL_GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define LOCAL_GL_COMPRESSED_LUMINANCE 0x84EA -#define LOCAL_GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define LOCAL_GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 -#define LOCAL_GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define LOCAL_GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define LOCAL_GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define LOCAL_GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define LOCAL_GL_COMPRESSED_R11_EAC 0x9270 -#define LOCAL_GL_COMPRESSED_R11_EAC_OES 0x9270 -#define LOCAL_GL_COMPRESSED_RED 0x8225 -#define LOCAL_GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define LOCAL_GL_COMPRESSED_RED_RGTC1 0x8DBB -#define LOCAL_GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define LOCAL_GL_COMPRESSED_RG 0x8226 -#define LOCAL_GL_COMPRESSED_RG11_EAC 0x9272 -#define LOCAL_GL_COMPRESSED_RG11_EAC_OES 0x9272 -#define LOCAL_GL_COMPRESSED_RGB 0x84ED -#define LOCAL_GL_COMPRESSED_RGB8_ETC2 0x9274 -#define LOCAL_GL_COMPRESSED_RGB8_ETC2_OES 0x9274 -#define LOCAL_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define LOCAL_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2_OES 0x9276 -#define LOCAL_GL_COMPRESSED_RGBA 0x84EE -#define LOCAL_GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define LOCAL_GL_COMPRESSED_RGBA8_ETC2_EAC_OES 0x9278 -#define LOCAL_GL_COMPRESSED_RGBA_ARB 0x84EE -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x10 0x93BB -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x5 0x93B8 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x6 0x93B9 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x8 0x93BA -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_12x10 0x93BC -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_12x12 0x93BD -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_4x4 0x93B0 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x4 0x93B1 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x5 0x93B2 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x5 0x93B3 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x6 0x93B4 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_8x5 0x93B5 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_8x6 0x93B6 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_8x8 0x93B7 -#define LOCAL_GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define LOCAL_GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C -#define LOCAL_GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define LOCAL_GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#define LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#define LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 -#define LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 -#define LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 -#define LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 -#define LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#define LOCAL_GL_COMPRESSED_RGB_ARB 0x84ED -#define LOCAL_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E -#define LOCAL_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define LOCAL_GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#define LOCAL_GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#define LOCAL_GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define LOCAL_GL_COMPRESSED_RG_RGTC2 0x8DBD -#define LOCAL_GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#define LOCAL_GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define LOCAL_GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define LOCAL_GL_COMPRESSED_SIGNED_R11_EAC_OES 0x9271 -#define LOCAL_GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#define LOCAL_GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define LOCAL_GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define LOCAL_GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define LOCAL_GL_COMPRESSED_SIGNED_RG11_EAC_OES 0x9273 -#define LOCAL_GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#define LOCAL_GL_COMPRESSED_SLUMINANCE 0x8C4A -#define LOCAL_GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#define LOCAL_GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define LOCAL_GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define LOCAL_GL_COMPRESSED_SRGB 0x8C48 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10 0x93DB -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5 0x93D8 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6 0x93D9 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8 0x93DA -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10 0x93DC -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12 0x93DD -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4 0x93D0 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4 0x93D1 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5 0x93D2 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5 0x93D3 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6 0x93D4 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5 0x93D5 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6 0x93D6 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8 0x93D7 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 -#define LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC_OES 0x9279 -#define LOCAL_GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define LOCAL_GL_COMPRESSED_SRGB8_ETC2_OES 0x9275 -#define LOCAL_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define LOCAL_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2_OES 0x9277 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#define LOCAL_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F -#define LOCAL_GL_COMPRESSED_SRGB_EXT 0x8C48 -#define LOCAL_GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 -#define LOCAL_GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 -#define LOCAL_GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define LOCAL_GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C -#define LOCAL_GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define LOCAL_GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#define LOCAL_GL_COMPUTE_PROGRAM_NV 0x90FB -#define LOCAL_GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC -#define LOCAL_GL_COMPUTE_SHADER 0x91B9 -#define LOCAL_GL_COMPUTE_SHADER_BIT 0x00000020 -#define LOCAL_GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 -#define LOCAL_GL_COMPUTE_SUBROUTINE 0x92ED -#define LOCAL_GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#define LOCAL_GL_COMPUTE_TEXTURE 0x82A0 -#define LOCAL_GL_COMPUTE_WORK_GROUP_SIZE 0x8267 -#define LOCAL_GL_COMP_BIT_ATI 0x00000002 -#define LOCAL_GL_CONDITION_SATISFIED 0x911C -#define LOCAL_GL_CONDITION_SATISFIED_APPLE 0x911C -#define LOCAL_GL_CONFORMANT_NV 0x9374 -#define LOCAL_GL_CONIC_CURVE_TO_NV 0x1A -#define LOCAL_GL_CONJOINT_NV 0x9284 -#define LOCAL_GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE -#define LOCAL_GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 -#define LOCAL_GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B -#define LOCAL_GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 -#define LOCAL_GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A -#define LOCAL_GL_CONSERVATIVE_RASTER_MODE_NV 0x954D -#define LOCAL_GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E -#define LOCAL_GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F -#define LOCAL_GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define LOCAL_GL_CONSTANT 0x8576 -#define LOCAL_GL_CONSTANT_ALPHA 0x8003 -#define LOCAL_GL_CONSTANT_ALPHA_EXT 0x8003 -#define LOCAL_GL_CONSTANT_ARB 0x8576 -#define LOCAL_GL_CONSTANT_ATTENUATION 0x1207 -#define LOCAL_GL_CONSTANT_BORDER 0x8151 -#define LOCAL_GL_CONSTANT_BORDER_HP 0x8151 -#define LOCAL_GL_CONSTANT_COLOR 0x8001 -#define LOCAL_GL_CONSTANT_COLOR0_NV 0x852A -#define LOCAL_GL_CONSTANT_COLOR1_NV 0x852B -#define LOCAL_GL_CONSTANT_COLOR_EXT 0x8001 -#define LOCAL_GL_CONSTANT_EXT 0x8576 -#define LOCAL_GL_CONSTANT_NV 0x8576 -#define LOCAL_GL_CONST_EYE_NV 0x86E5 -#define LOCAL_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define LOCAL_GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define LOCAL_GL_CONTEXT_FLAGS 0x821E -#define LOCAL_GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#define LOCAL_GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 -#define LOCAL_GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 -#define LOCAL_GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 -#define LOCAL_GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010 -#define LOCAL_GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 -#define LOCAL_GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define LOCAL_GL_CONTEXT_LOST 0x0507 -#define LOCAL_GL_CONTEXT_LOST_KHR 0x0507 -#define LOCAL_GL_CONTEXT_LOST_WEBGL 0x9242 -#define LOCAL_GL_CONTEXT_PROFILE_MASK 0x9126 -#define LOCAL_GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB -#define LOCAL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC -#define LOCAL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC -#define LOCAL_GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB -#define LOCAL_GL_CONTEXT_ROBUST_ACCESS 0x90F3 -#define LOCAL_GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 -#define LOCAL_GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 -#define LOCAL_GL_CONTINUOUS_AMD 0x9007 -#define LOCAL_GL_CONTRAST_NV 0x92A1 -#define LOCAL_GL_CONVEX_HULL_NV 0x908B -#define LOCAL_GL_CONVOLUTION_1D 0x8010 -#define LOCAL_GL_CONVOLUTION_1D_EXT 0x8010 -#define LOCAL_GL_CONVOLUTION_2D 0x8011 -#define LOCAL_GL_CONVOLUTION_2D_EXT 0x8011 -#define LOCAL_GL_CONVOLUTION_BORDER_COLOR 0x8154 -#define LOCAL_GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#define LOCAL_GL_CONVOLUTION_BORDER_MODE 0x8013 -#define LOCAL_GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define LOCAL_GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define LOCAL_GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define LOCAL_GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define LOCAL_GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define LOCAL_GL_CONVOLUTION_FORMAT 0x8017 -#define LOCAL_GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define LOCAL_GL_CONVOLUTION_HEIGHT 0x8019 -#define LOCAL_GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define LOCAL_GL_CONVOLUTION_HINT_SGIX 0x8316 -#define LOCAL_GL_CONVOLUTION_WIDTH 0x8018 -#define LOCAL_GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define LOCAL_GL_CON_0_ATI 0x8941 -#define LOCAL_GL_CON_10_ATI 0x894B -#define LOCAL_GL_CON_11_ATI 0x894C -#define LOCAL_GL_CON_12_ATI 0x894D -#define LOCAL_GL_CON_13_ATI 0x894E -#define LOCAL_GL_CON_14_ATI 0x894F -#define LOCAL_GL_CON_15_ATI 0x8950 -#define LOCAL_GL_CON_16_ATI 0x8951 -#define LOCAL_GL_CON_17_ATI 0x8952 -#define LOCAL_GL_CON_18_ATI 0x8953 -#define LOCAL_GL_CON_19_ATI 0x8954 -#define LOCAL_GL_CON_1_ATI 0x8942 -#define LOCAL_GL_CON_20_ATI 0x8955 -#define LOCAL_GL_CON_21_ATI 0x8956 -#define LOCAL_GL_CON_22_ATI 0x8957 -#define LOCAL_GL_CON_23_ATI 0x8958 -#define LOCAL_GL_CON_24_ATI 0x8959 -#define LOCAL_GL_CON_25_ATI 0x895A -#define LOCAL_GL_CON_26_ATI 0x895B -#define LOCAL_GL_CON_27_ATI 0x895C -#define LOCAL_GL_CON_28_ATI 0x895D -#define LOCAL_GL_CON_29_ATI 0x895E -#define LOCAL_GL_CON_2_ATI 0x8943 -#define LOCAL_GL_CON_30_ATI 0x895F -#define LOCAL_GL_CON_31_ATI 0x8960 -#define LOCAL_GL_CON_3_ATI 0x8944 -#define LOCAL_GL_CON_4_ATI 0x8945 -#define LOCAL_GL_CON_5_ATI 0x8946 -#define LOCAL_GL_CON_6_ATI 0x8947 -#define LOCAL_GL_CON_7_ATI 0x8948 -#define LOCAL_GL_CON_8_ATI 0x8949 -#define LOCAL_GL_CON_9_ATI 0x894A -#define LOCAL_GL_COORD_REPLACE 0x8862 -#define LOCAL_GL_COORD_REPLACE_ARB 0x8862 -#define LOCAL_GL_COORD_REPLACE_NV 0x8862 -#define LOCAL_GL_COORD_REPLACE_OES 0x8862 -#define LOCAL_GL_COPY 0x1503 -#define LOCAL_GL_COPY_INVERTED 0x150C -#define LOCAL_GL_COPY_PIXEL_TOKEN 0x0706 -#define LOCAL_GL_COPY_READ_BUFFER 0x8F36 -#define LOCAL_GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define LOCAL_GL_COPY_READ_BUFFER_NV 0x8F36 -#define LOCAL_GL_COPY_WRITE_BUFFER 0x8F37 -#define LOCAL_GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define LOCAL_GL_COPY_WRITE_BUFFER_NV 0x8F37 -#define LOCAL_GL_COUNTER_RANGE_AMD 0x8BC1 -#define LOCAL_GL_COUNTER_TYPE_AMD 0x8BC0 -#define LOCAL_GL_COUNT_DOWN_NV 0x9089 -#define LOCAL_GL_COUNT_UP_NV 0x9088 -#define LOCAL_GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 -#define LOCAL_GL_COVERAGE_ATTACHMENT_NV 0x8ED2 -#define LOCAL_GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define LOCAL_GL_COVERAGE_BUFFERS_NV 0x8ED3 -#define LOCAL_GL_COVERAGE_BUFFER_BIT_NV 0x00008000 -#define LOCAL_GL_COVERAGE_COMPONENT4_NV 0x8ED1 -#define LOCAL_GL_COVERAGE_COMPONENT_NV 0x8ED0 -#define LOCAL_GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 -#define LOCAL_GL_COVERAGE_MODULATION_NV 0x9332 -#define LOCAL_GL_COVERAGE_MODULATION_TABLE_NV 0x9331 -#define LOCAL_GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 -#define LOCAL_GL_COVERAGE_SAMPLES_NV 0x8ED4 -#define LOCAL_GL_CPU_OPTIMIZED_QCOM 0x8FB1 -#define LOCAL_GL_CUBIC_CURVE_TO_NV 0x0C -#define LOCAL_GL_CUBIC_EXT 0x8334 -#define LOCAL_GL_CUBIC_HP 0x815F -#define LOCAL_GL_CUBIC_IMG 0x9139 -#define LOCAL_GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B -#define LOCAL_GL_CUBIC_MIPMAP_NEAREST_IMG 0x913A -#define LOCAL_GL_CULL_FACE 0x0B44 -#define LOCAL_GL_CULL_FACE_MODE 0x0B45 -#define LOCAL_GL_CULL_FRAGMENT_NV 0x86E7 -#define LOCAL_GL_CULL_MODES_NV 0x86E0 -#define LOCAL_GL_CULL_VERTEX_EXT 0x81AA -#define LOCAL_GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define LOCAL_GL_CULL_VERTEX_IBM 103050 -#define LOCAL_GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#define LOCAL_GL_CURRENT_ATTRIB_NV 0x8626 -#define LOCAL_GL_CURRENT_BINORMAL_EXT 0x843C -#define LOCAL_GL_CURRENT_BIT 0x00000001 -#define LOCAL_GL_CURRENT_COLOR 0x0B00 -#define LOCAL_GL_CURRENT_FOG_COORD 0x8453 -#define LOCAL_GL_CURRENT_FOG_COORDINATE 0x8453 -#define LOCAL_GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define LOCAL_GL_CURRENT_INDEX 0x0B01 -#define LOCAL_GL_CURRENT_MATRIX_ARB 0x8641 -#define LOCAL_GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define LOCAL_GL_CURRENT_MATRIX_NV 0x8641 -#define LOCAL_GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define LOCAL_GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define LOCAL_GL_CURRENT_NORMAL 0x0B02 -#define LOCAL_GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define LOCAL_GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define LOCAL_GL_CURRENT_PALETTE_MATRIX_OES 0x8843 -#define LOCAL_GL_CURRENT_PROGRAM 0x8B8D -#define LOCAL_GL_CURRENT_QUERY 0x8865 -#define LOCAL_GL_CURRENT_QUERY_ARB 0x8865 -#define LOCAL_GL_CURRENT_QUERY_EXT 0x8865 -#define LOCAL_GL_CURRENT_RASTER_COLOR 0x0B04 -#define LOCAL_GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define LOCAL_GL_CURRENT_RASTER_INDEX 0x0B05 -#define LOCAL_GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define LOCAL_GL_CURRENT_RASTER_POSITION 0x0B07 -#define LOCAL_GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define LOCAL_GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define LOCAL_GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define LOCAL_GL_CURRENT_SECONDARY_COLOR 0x8459 -#define LOCAL_GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define LOCAL_GL_CURRENT_TANGENT_EXT 0x843B -#define LOCAL_GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define LOCAL_GL_CURRENT_TIME_NV 0x8E28 -#define LOCAL_GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define LOCAL_GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define LOCAL_GL_CURRENT_VERTEX_EXT 0x87E2 -#define LOCAL_GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define LOCAL_GL_CURRENT_WEIGHT_ARB 0x86A8 -#define LOCAL_GL_CW 0x0900 -#define LOCAL_GL_D3D12_FENCE_VALUE_EXT 0x9595 -#define LOCAL_GL_DARKEN 0x9297 -#define LOCAL_GL_DARKEN_KHR 0x9297 -#define LOCAL_GL_DARKEN_NV 0x9297 -#define LOCAL_GL_DATA_BUFFER_AMD 0x9151 -#define LOCAL_GL_DEBUG_ASSERT_MESA 0x875B -#define LOCAL_GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#define LOCAL_GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define LOCAL_GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 -#define LOCAL_GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#define LOCAL_GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define LOCAL_GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 -#define LOCAL_GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define LOCAL_GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define LOCAL_GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define LOCAL_GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#define LOCAL_GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define LOCAL_GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define LOCAL_GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define LOCAL_GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define LOCAL_GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#define LOCAL_GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D -#define LOCAL_GL_DEBUG_LOGGED_MESSAGES 0x9145 -#define LOCAL_GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define LOCAL_GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define LOCAL_GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 -#define LOCAL_GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#define LOCAL_GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define LOCAL_GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 -#define LOCAL_GL_DEBUG_OBJECT_MESA 0x8759 -#define LOCAL_GL_DEBUG_OUTPUT 0x92E0 -#define LOCAL_GL_DEBUG_OUTPUT_KHR 0x92E0 -#define LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 -#define LOCAL_GL_DEBUG_PRINT_MESA 0x875A -#define LOCAL_GL_DEBUG_SEVERITY_HIGH 0x9146 -#define LOCAL_GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define LOCAL_GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define LOCAL_GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 -#define LOCAL_GL_DEBUG_SEVERITY_LOW 0x9148 -#define LOCAL_GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define LOCAL_GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#define LOCAL_GL_DEBUG_SEVERITY_LOW_KHR 0x9148 -#define LOCAL_GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define LOCAL_GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define LOCAL_GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define LOCAL_GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 -#define LOCAL_GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define LOCAL_GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B -#define LOCAL_GL_DEBUG_SOURCE_API 0x8246 -#define LOCAL_GL_DEBUG_SOURCE_API_ARB 0x8246 -#define LOCAL_GL_DEBUG_SOURCE_API_KHR 0x8246 -#define LOCAL_GL_DEBUG_SOURCE_APPLICATION 0x824A -#define LOCAL_GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define LOCAL_GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A -#define LOCAL_GL_DEBUG_SOURCE_OTHER 0x824B -#define LOCAL_GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define LOCAL_GL_DEBUG_SOURCE_OTHER_KHR 0x824B -#define LOCAL_GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define LOCAL_GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define LOCAL_GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 -#define LOCAL_GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define LOCAL_GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define LOCAL_GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 -#define LOCAL_GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define LOCAL_GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define LOCAL_GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 -#define LOCAL_GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define LOCAL_GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define LOCAL_GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D -#define LOCAL_GL_DEBUG_TYPE_ERROR 0x824C -#define LOCAL_GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define LOCAL_GL_DEBUG_TYPE_ERROR_KHR 0x824C -#define LOCAL_GL_DEBUG_TYPE_MARKER 0x8268 -#define LOCAL_GL_DEBUG_TYPE_MARKER_KHR 0x8268 -#define LOCAL_GL_DEBUG_TYPE_OTHER 0x8251 -#define LOCAL_GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define LOCAL_GL_DEBUG_TYPE_OTHER_KHR 0x8251 -#define LOCAL_GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define LOCAL_GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define LOCAL_GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 -#define LOCAL_GL_DEBUG_TYPE_POP_GROUP 0x826A -#define LOCAL_GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A -#define LOCAL_GL_DEBUG_TYPE_PORTABILITY 0x824F -#define LOCAL_GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define LOCAL_GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F -#define LOCAL_GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#define LOCAL_GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 -#define LOCAL_GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define LOCAL_GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define LOCAL_GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E -#define LOCAL_GL_DECAL 0x2101 -#define LOCAL_GL_DECODE_EXT 0x8A49 -#define LOCAL_GL_DECR 0x1E03 -#define LOCAL_GL_DECR_WRAP 0x8508 -#define LOCAL_GL_DECR_WRAP_EXT 0x8508 -#define LOCAL_GL_DECR_WRAP_OES 0x8508 -#define LOCAL_GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 -#define LOCAL_GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define LOCAL_GL_DELETE_STATUS 0x8B80 -#define LOCAL_GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define LOCAL_GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define LOCAL_GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define LOCAL_GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define LOCAL_GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define LOCAL_GL_DEPTH 0x1801 -#define LOCAL_GL_DEPTH24_STENCIL8 0x88F0 -#define LOCAL_GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define LOCAL_GL_DEPTH24_STENCIL8_OES 0x88F0 -#define LOCAL_GL_DEPTH32F_STENCIL8 0x8CAD -#define LOCAL_GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define LOCAL_GL_DEPTH_ATTACHMENT 0x8D00 -#define LOCAL_GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define LOCAL_GL_DEPTH_ATTACHMENT_OES 0x8D00 -#define LOCAL_GL_DEPTH_BIAS 0x0D1F -#define LOCAL_GL_DEPTH_BITS 0x0D56 -#define LOCAL_GL_DEPTH_BOUNDS_EXT 0x8891 -#define LOCAL_GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define LOCAL_GL_DEPTH_BUFFER_BIT 0x00000100 -#define LOCAL_GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define LOCAL_GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define LOCAL_GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define LOCAL_GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define LOCAL_GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define LOCAL_GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define LOCAL_GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define LOCAL_GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define LOCAL_GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#define LOCAL_GL_DEPTH_CLAMP 0x864F -#define LOCAL_GL_DEPTH_CLAMP_FAR_AMD 0x901F -#define LOCAL_GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define LOCAL_GL_DEPTH_CLAMP_NV 0x864F -#define LOCAL_GL_DEPTH_CLEAR_VALUE 0x0B73 -#define LOCAL_GL_DEPTH_COMPONENT 0x1902 -#define LOCAL_GL_DEPTH_COMPONENT16 0x81A5 -#define LOCAL_GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define LOCAL_GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C -#define LOCAL_GL_DEPTH_COMPONENT16_OES 0x81A5 -#define LOCAL_GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define LOCAL_GL_DEPTH_COMPONENT24 0x81A6 -#define LOCAL_GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define LOCAL_GL_DEPTH_COMPONENT24_OES 0x81A6 -#define LOCAL_GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define LOCAL_GL_DEPTH_COMPONENT32 0x81A7 -#define LOCAL_GL_DEPTH_COMPONENT32F 0x8CAC -#define LOCAL_GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define LOCAL_GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define LOCAL_GL_DEPTH_COMPONENT32_OES 0x81A7 -#define LOCAL_GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#define LOCAL_GL_DEPTH_COMPONENTS 0x8284 -#define LOCAL_GL_DEPTH_EXT 0x1801 -#define LOCAL_GL_DEPTH_FUNC 0x0B74 -#define LOCAL_GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define LOCAL_GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#define LOCAL_GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define LOCAL_GL_DEPTH_RANGE 0x0B70 -#define LOCAL_GL_DEPTH_RENDERABLE 0x8287 -#define LOCAL_GL_DEPTH_SAMPLES_NV 0x932D -#define LOCAL_GL_DEPTH_SCALE 0x0D1E -#define LOCAL_GL_DEPTH_STENCIL 0x84F9 -#define LOCAL_GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define LOCAL_GL_DEPTH_STENCIL_EXT 0x84F9 -#define LOCAL_GL_DEPTH_STENCIL_MESA 0x8750 -#define LOCAL_GL_DEPTH_STENCIL_NV 0x84F9 -#define LOCAL_GL_DEPTH_STENCIL_OES 0x84F9 -#define LOCAL_GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA -#define LOCAL_GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#define LOCAL_GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define LOCAL_GL_DEPTH_TEST 0x0B71 -#define LOCAL_GL_DEPTH_TEXTURE_MODE 0x884B -#define LOCAL_GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#define LOCAL_GL_DEPTH_WRITEMASK 0x0B72 -#define LOCAL_GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define LOCAL_GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define LOCAL_GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#define LOCAL_GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define LOCAL_GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define LOCAL_GL_DEVICE_LUID_EXT 0x9599 -#define LOCAL_GL_DEVICE_NODE_MASK_EXT 0x959A -#define LOCAL_GL_DEVICE_UUID_EXT 0x9597 -#define LOCAL_GL_DIFFERENCE 0x929E -#define LOCAL_GL_DIFFERENCE_KHR 0x929E -#define LOCAL_GL_DIFFERENCE_NV 0x929E -#define LOCAL_GL_DIFFUSE 0x1201 -#define LOCAL_GL_DISCARD_ATI 0x8763 -#define LOCAL_GL_DISCARD_NV 0x8530 -#define LOCAL_GL_DISCRETE_AMD 0x9006 -#define LOCAL_GL_DISJOINT_NV 0x9283 -#define LOCAL_GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define LOCAL_GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define LOCAL_GL_DISPLAY_LIST 0x82E7 -#define LOCAL_GL_DISTANCE_ATTENUATION_EXT 0x8129 -#define LOCAL_GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#define LOCAL_GL_DITHER 0x0BD0 -#define LOCAL_GL_DMP_PROGRAM_BINARY_DMP 0x9253 -#define LOCAL_GL_DOMAIN 0x0A02 -#define LOCAL_GL_DONT_CARE 0x1100 -#define LOCAL_GL_DOT2_ADD_ATI 0x896C -#define LOCAL_GL_DOT3_ATI 0x8966 -#define LOCAL_GL_DOT3_RGB 0x86AE -#define LOCAL_GL_DOT3_RGBA 0x86AF -#define LOCAL_GL_DOT3_RGBA_ARB 0x86AF -#define LOCAL_GL_DOT3_RGBA_EXT 0x8741 -#define LOCAL_GL_DOT3_RGBA_IMG 0x86AF -#define LOCAL_GL_DOT3_RGB_ARB 0x86AE -#define LOCAL_GL_DOT3_RGB_EXT 0x8740 -#define LOCAL_GL_DOT4_ATI 0x8967 -#define LOCAL_GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define LOCAL_GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define LOCAL_GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define LOCAL_GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define LOCAL_GL_DOT_PRODUCT_NV 0x86EC -#define LOCAL_GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define LOCAL_GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define LOCAL_GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define LOCAL_GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define LOCAL_GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#define LOCAL_GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define LOCAL_GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define LOCAL_GL_DOUBLE 0x140A -#define LOCAL_GL_DOUBLEBUFFER 0x0C32 -#define LOCAL_GL_DOUBLE_EXT 0x140A -#define LOCAL_GL_DOUBLE_MAT2 0x8F46 -#define LOCAL_GL_DOUBLE_MAT2_EXT 0x8F46 -#define LOCAL_GL_DOUBLE_MAT2x3 0x8F49 -#define LOCAL_GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define LOCAL_GL_DOUBLE_MAT2x4 0x8F4A -#define LOCAL_GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define LOCAL_GL_DOUBLE_MAT3 0x8F47 -#define LOCAL_GL_DOUBLE_MAT3_EXT 0x8F47 -#define LOCAL_GL_DOUBLE_MAT3x2 0x8F4B -#define LOCAL_GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define LOCAL_GL_DOUBLE_MAT3x4 0x8F4C -#define LOCAL_GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define LOCAL_GL_DOUBLE_MAT4 0x8F48 -#define LOCAL_GL_DOUBLE_MAT4_EXT 0x8F48 -#define LOCAL_GL_DOUBLE_MAT4x2 0x8F4D -#define LOCAL_GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define LOCAL_GL_DOUBLE_MAT4x3 0x8F4E -#define LOCAL_GL_DOUBLE_MAT4x3_EXT 0x8F4E -#define LOCAL_GL_DOUBLE_VEC2 0x8FFC -#define LOCAL_GL_DOUBLE_VEC2_EXT 0x8FFC -#define LOCAL_GL_DOUBLE_VEC3 0x8FFD -#define LOCAL_GL_DOUBLE_VEC3_EXT 0x8FFD -#define LOCAL_GL_DOUBLE_VEC4 0x8FFE -#define LOCAL_GL_DOUBLE_VEC4_EXT 0x8FFE -#define LOCAL_GL_DOWNSAMPLE_SCALES_IMG 0x913E -#define LOCAL_GL_DRAW_ARRAYS_COMMAND_NV 0x0003 -#define LOCAL_GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 -#define LOCAL_GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 -#define LOCAL_GL_DRAW_BUFFER 0x0C01 -#define LOCAL_GL_DRAW_BUFFER0 0x8825 -#define LOCAL_GL_DRAW_BUFFER0_ARB 0x8825 -#define LOCAL_GL_DRAW_BUFFER0_ATI 0x8825 -#define LOCAL_GL_DRAW_BUFFER0_EXT 0x8825 -#define LOCAL_GL_DRAW_BUFFER0_NV 0x8825 -#define LOCAL_GL_DRAW_BUFFER1 0x8826 -#define LOCAL_GL_DRAW_BUFFER10 0x882F -#define LOCAL_GL_DRAW_BUFFER10_ARB 0x882F -#define LOCAL_GL_DRAW_BUFFER10_ATI 0x882F -#define LOCAL_GL_DRAW_BUFFER10_EXT 0x882F -#define LOCAL_GL_DRAW_BUFFER10_NV 0x882F -#define LOCAL_GL_DRAW_BUFFER11 0x8830 -#define LOCAL_GL_DRAW_BUFFER11_ARB 0x8830 -#define LOCAL_GL_DRAW_BUFFER11_ATI 0x8830 -#define LOCAL_GL_DRAW_BUFFER11_EXT 0x8830 -#define LOCAL_GL_DRAW_BUFFER11_NV 0x8830 -#define LOCAL_GL_DRAW_BUFFER12 0x8831 -#define LOCAL_GL_DRAW_BUFFER12_ARB 0x8831 -#define LOCAL_GL_DRAW_BUFFER12_ATI 0x8831 -#define LOCAL_GL_DRAW_BUFFER12_EXT 0x8831 -#define LOCAL_GL_DRAW_BUFFER12_NV 0x8831 -#define LOCAL_GL_DRAW_BUFFER13 0x8832 -#define LOCAL_GL_DRAW_BUFFER13_ARB 0x8832 -#define LOCAL_GL_DRAW_BUFFER13_ATI 0x8832 -#define LOCAL_GL_DRAW_BUFFER13_EXT 0x8832 -#define LOCAL_GL_DRAW_BUFFER13_NV 0x8832 -#define LOCAL_GL_DRAW_BUFFER14 0x8833 -#define LOCAL_GL_DRAW_BUFFER14_ARB 0x8833 -#define LOCAL_GL_DRAW_BUFFER14_ATI 0x8833 -#define LOCAL_GL_DRAW_BUFFER14_EXT 0x8833 -#define LOCAL_GL_DRAW_BUFFER14_NV 0x8833 -#define LOCAL_GL_DRAW_BUFFER15 0x8834 -#define LOCAL_GL_DRAW_BUFFER15_ARB 0x8834 -#define LOCAL_GL_DRAW_BUFFER15_ATI 0x8834 -#define LOCAL_GL_DRAW_BUFFER15_EXT 0x8834 -#define LOCAL_GL_DRAW_BUFFER15_NV 0x8834 -#define LOCAL_GL_DRAW_BUFFER1_ARB 0x8826 -#define LOCAL_GL_DRAW_BUFFER1_ATI 0x8826 -#define LOCAL_GL_DRAW_BUFFER1_EXT 0x8826 -#define LOCAL_GL_DRAW_BUFFER1_NV 0x8826 -#define LOCAL_GL_DRAW_BUFFER2 0x8827 -#define LOCAL_GL_DRAW_BUFFER2_ARB 0x8827 -#define LOCAL_GL_DRAW_BUFFER2_ATI 0x8827 -#define LOCAL_GL_DRAW_BUFFER2_EXT 0x8827 -#define LOCAL_GL_DRAW_BUFFER2_NV 0x8827 -#define LOCAL_GL_DRAW_BUFFER3 0x8828 -#define LOCAL_GL_DRAW_BUFFER3_ARB 0x8828 -#define LOCAL_GL_DRAW_BUFFER3_ATI 0x8828 -#define LOCAL_GL_DRAW_BUFFER3_EXT 0x8828 -#define LOCAL_GL_DRAW_BUFFER3_NV 0x8828 -#define LOCAL_GL_DRAW_BUFFER4 0x8829 -#define LOCAL_GL_DRAW_BUFFER4_ARB 0x8829 -#define LOCAL_GL_DRAW_BUFFER4_ATI 0x8829 -#define LOCAL_GL_DRAW_BUFFER4_EXT 0x8829 -#define LOCAL_GL_DRAW_BUFFER4_NV 0x8829 -#define LOCAL_GL_DRAW_BUFFER5 0x882A -#define LOCAL_GL_DRAW_BUFFER5_ARB 0x882A -#define LOCAL_GL_DRAW_BUFFER5_ATI 0x882A -#define LOCAL_GL_DRAW_BUFFER5_EXT 0x882A -#define LOCAL_GL_DRAW_BUFFER5_NV 0x882A -#define LOCAL_GL_DRAW_BUFFER6 0x882B -#define LOCAL_GL_DRAW_BUFFER6_ARB 0x882B -#define LOCAL_GL_DRAW_BUFFER6_ATI 0x882B -#define LOCAL_GL_DRAW_BUFFER6_EXT 0x882B -#define LOCAL_GL_DRAW_BUFFER6_NV 0x882B -#define LOCAL_GL_DRAW_BUFFER7 0x882C -#define LOCAL_GL_DRAW_BUFFER7_ARB 0x882C -#define LOCAL_GL_DRAW_BUFFER7_ATI 0x882C -#define LOCAL_GL_DRAW_BUFFER7_EXT 0x882C -#define LOCAL_GL_DRAW_BUFFER7_NV 0x882C -#define LOCAL_GL_DRAW_BUFFER8 0x882D -#define LOCAL_GL_DRAW_BUFFER8_ARB 0x882D -#define LOCAL_GL_DRAW_BUFFER8_ATI 0x882D -#define LOCAL_GL_DRAW_BUFFER8_EXT 0x882D -#define LOCAL_GL_DRAW_BUFFER8_NV 0x882D -#define LOCAL_GL_DRAW_BUFFER9 0x882E -#define LOCAL_GL_DRAW_BUFFER9_ARB 0x882E -#define LOCAL_GL_DRAW_BUFFER9_ATI 0x882E -#define LOCAL_GL_DRAW_BUFFER9_EXT 0x882E -#define LOCAL_GL_DRAW_BUFFER9_NV 0x882E -#define LOCAL_GL_DRAW_BUFFER_EXT 0x0C01 -#define LOCAL_GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 -#define LOCAL_GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 -#define LOCAL_GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 -#define LOCAL_GL_DRAW_FRAMEBUFFER 0x8CA9 -#define LOCAL_GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define LOCAL_GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define LOCAL_GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 -#define LOCAL_GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define LOCAL_GL_DRAW_FRAMEBUFFER_NV 0x8CA9 -#define LOCAL_GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define LOCAL_GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define LOCAL_GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#define LOCAL_GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#define LOCAL_GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define LOCAL_GL_DRAW_PIXELS_APPLE 0x8A0A -#define LOCAL_GL_DRAW_PIXEL_TOKEN 0x0705 -#define LOCAL_GL_DRIVER_UUID_EXT 0x9598 -#define LOCAL_GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define LOCAL_GL_DSDT8_MAG8_NV 0x870A -#define LOCAL_GL_DSDT8_NV 0x8709 -#define LOCAL_GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define LOCAL_GL_DSDT_MAG_NV 0x86F6 -#define LOCAL_GL_DSDT_MAG_VIB_NV 0x86F7 -#define LOCAL_GL_DSDT_NV 0x86F5 -#define LOCAL_GL_DST_ALPHA 0x0304 -#define LOCAL_GL_DST_ATOP_NV 0x928F -#define LOCAL_GL_DST_COLOR 0x0306 -#define LOCAL_GL_DST_IN_NV 0x928B -#define LOCAL_GL_DST_NV 0x9287 -#define LOCAL_GL_DST_OUT_NV 0x928D -#define LOCAL_GL_DST_OVER_NV 0x9289 -#define LOCAL_GL_DS_BIAS_NV 0x8716 -#define LOCAL_GL_DS_SCALE_NV 0x8710 -#define LOCAL_GL_DT_BIAS_NV 0x8717 -#define LOCAL_GL_DT_SCALE_NV 0x8711 -#define LOCAL_GL_DU8DV8_ATI 0x877A -#define LOCAL_GL_DUAL_ALPHA12_SGIS 0x8112 -#define LOCAL_GL_DUAL_ALPHA16_SGIS 0x8113 -#define LOCAL_GL_DUAL_ALPHA4_SGIS 0x8110 -#define LOCAL_GL_DUAL_ALPHA8_SGIS 0x8111 -#define LOCAL_GL_DUAL_INTENSITY12_SGIS 0x811A -#define LOCAL_GL_DUAL_INTENSITY16_SGIS 0x811B -#define LOCAL_GL_DUAL_INTENSITY4_SGIS 0x8118 -#define LOCAL_GL_DUAL_INTENSITY8_SGIS 0x8119 -#define LOCAL_GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define LOCAL_GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define LOCAL_GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define LOCAL_GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define LOCAL_GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define LOCAL_GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define LOCAL_GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define LOCAL_GL_DUDV_ATI 0x8779 -#define LOCAL_GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define LOCAL_GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define LOCAL_GL_DYNAMIC_ATI 0x8761 -#define LOCAL_GL_DYNAMIC_COPY 0x88EA -#define LOCAL_GL_DYNAMIC_COPY_ARB 0x88EA -#define LOCAL_GL_DYNAMIC_DRAW 0x88E8 -#define LOCAL_GL_DYNAMIC_DRAW_ARB 0x88E8 -#define LOCAL_GL_DYNAMIC_READ 0x88E9 -#define LOCAL_GL_DYNAMIC_READ_ARB 0x88E9 -#define LOCAL_GL_DYNAMIC_STORAGE_BIT 0x0100 -#define LOCAL_GL_DYNAMIC_STORAGE_BIT_EXT 0x0100 -#define LOCAL_GL_EDGEFLAG_BIT_PGI 0x00040000 -#define LOCAL_GL_EDGE_FLAG 0x0B43 -#define LOCAL_GL_EDGE_FLAG_ARRAY 0x8079 -#define LOCAL_GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define LOCAL_GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define LOCAL_GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define LOCAL_GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define LOCAL_GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define LOCAL_GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define LOCAL_GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define LOCAL_GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define LOCAL_GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#define LOCAL_GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#define LOCAL_GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define LOCAL_GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define LOCAL_GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C -#define LOCAL_GL_EIGHTH_BIT_ATI 0x00000020 -#define LOCAL_GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 -#define LOCAL_GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define LOCAL_GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define LOCAL_GL_ELEMENT_ARRAY_ATI 0x8768 -#define LOCAL_GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define LOCAL_GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define LOCAL_GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define LOCAL_GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define LOCAL_GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define LOCAL_GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define LOCAL_GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define LOCAL_GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -#define LOCAL_GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#define LOCAL_GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define LOCAL_GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define LOCAL_GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define LOCAL_GL_EMBOSS_CONSTANT_NV 0x855E -#define LOCAL_GL_EMBOSS_LIGHT_NV 0x855D -#define LOCAL_GL_EMBOSS_MAP_NV 0x855F -#define LOCAL_GL_EMISSION 0x1600 -#define LOCAL_GL_ENABLE_BIT 0x00002000 -#define LOCAL_GL_EQUAL 0x0202 -#define LOCAL_GL_EQUIV 0x1509 -#define LOCAL_GL_ETC1_RGB8_OES 0x8D64 -#define LOCAL_GL_ETC1_SRGB8_NV 0x88EE -#define LOCAL_GL_EVAL_2D_NV 0x86C0 -#define LOCAL_GL_EVAL_BIT 0x00010000 -#define LOCAL_GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define LOCAL_GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define LOCAL_GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define LOCAL_GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define LOCAL_GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define LOCAL_GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define LOCAL_GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define LOCAL_GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define LOCAL_GL_EXCLUSION 0x92A0 -#define LOCAL_GL_EXCLUSION_KHR 0x92A0 -#define LOCAL_GL_EXCLUSION_NV 0x92A0 -#define LOCAL_GL_EXCLUSIVE_EXT 0x8F11 -#define LOCAL_GL_EXP 0x0800 -#define LOCAL_GL_EXP2 0x0801 -#define LOCAL_GL_EXPAND_NEGATE_NV 0x8539 -#define LOCAL_GL_EXPAND_NORMAL_NV 0x8538 -#define LOCAL_GL_EXTENSIONS 0x1F03 -#define LOCAL_GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#define LOCAL_GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define LOCAL_GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define LOCAL_GL_EYE_LINEAR 0x2400 -#define LOCAL_GL_EYE_LINEAR_NV 0x2400 -#define LOCAL_GL_EYE_LINE_SGIS 0x81F6 -#define LOCAL_GL_EYE_PLANE 0x2502 -#define LOCAL_GL_EYE_PLANE_ABSOLUTE_NV 0x855C -#define LOCAL_GL_EYE_POINT_SGIS 0x81F4 -#define LOCAL_GL_EYE_RADIAL_NV 0x855B -#define LOCAL_GL_E_TIMES_F_NV 0x8531 -#define LOCAL_GL_FACTOR_ALPHA_MODULATE_IMG 0x8C07 -#define LOCAL_GL_FACTOR_MAX_AMD 0x901D -#define LOCAL_GL_FACTOR_MIN_AMD 0x901C -#define LOCAL_GL_FAILURE_NV 0x9030 -#define LOCAL_GL_FALSE 0 -#define LOCAL_GL_FASTEST 0x1101 -#define LOCAL_GL_FEEDBACK 0x1C01 -#define LOCAL_GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define LOCAL_GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define LOCAL_GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define LOCAL_GL_FENCE_APPLE 0x8A0B -#define LOCAL_GL_FENCE_CONDITION_NV 0x84F4 -#define LOCAL_GL_FENCE_STATUS_NV 0x84F3 -#define LOCAL_GL_FETCH_PER_SAMPLE_ARM 0x8F65 -#define LOCAL_GL_FIELDS_NV 0x8E27 -#define LOCAL_GL_FIELD_LOWER_NV 0x9023 -#define LOCAL_GL_FIELD_UPPER_NV 0x9022 -#define LOCAL_GL_FILE_NAME_NV 0x9074 -#define LOCAL_GL_FILL 0x1B02 -#define LOCAL_GL_FILL_NV 0x1B02 -#define LOCAL_GL_FILL_RECTANGLE_NV 0x933C -#define LOCAL_GL_FILTER 0x829A -#define LOCAL_GL_FILTER4_SGIS 0x8146 -#define LOCAL_GL_FIRST_TO_REST_NV 0x90AF -#define LOCAL_GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define LOCAL_GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define LOCAL_GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D -#define LOCAL_GL_FIXED 0x140C -#define LOCAL_GL_FIXED_OES 0x140C -#define LOCAL_GL_FIXED_ONLY 0x891D -#define LOCAL_GL_FIXED_ONLY_ARB 0x891D -#define LOCAL_GL_FLAT 0x1D00 -#define LOCAL_GL_FLOAT 0x1406 -#define LOCAL_GL_FLOAT16_MAT2_AMD 0x91C5 -#define LOCAL_GL_FLOAT16_MAT2x3_AMD 0x91C8 -#define LOCAL_GL_FLOAT16_MAT2x4_AMD 0x91C9 -#define LOCAL_GL_FLOAT16_MAT3_AMD 0x91C6 -#define LOCAL_GL_FLOAT16_MAT3x2_AMD 0x91CA -#define LOCAL_GL_FLOAT16_MAT3x4_AMD 0x91CB -#define LOCAL_GL_FLOAT16_MAT4_AMD 0x91C7 -#define LOCAL_GL_FLOAT16_MAT4x2_AMD 0x91CC -#define LOCAL_GL_FLOAT16_MAT4x3_AMD 0x91CD -#define LOCAL_GL_FLOAT16_NV 0x8FF8 -#define LOCAL_GL_FLOAT16_VEC2_NV 0x8FF9 -#define LOCAL_GL_FLOAT16_VEC3_NV 0x8FFA -#define LOCAL_GL_FLOAT16_VEC4_NV 0x8FFB -#define LOCAL_GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#define LOCAL_GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define LOCAL_GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define LOCAL_GL_FLOAT_MAT2 0x8B5A -#define LOCAL_GL_FLOAT_MAT2_ARB 0x8B5A -#define LOCAL_GL_FLOAT_MAT2x3 0x8B65 -#define LOCAL_GL_FLOAT_MAT2x3_NV 0x8B65 -#define LOCAL_GL_FLOAT_MAT2x4 0x8B66 -#define LOCAL_GL_FLOAT_MAT2x4_NV 0x8B66 -#define LOCAL_GL_FLOAT_MAT3 0x8B5B -#define LOCAL_GL_FLOAT_MAT3_ARB 0x8B5B -#define LOCAL_GL_FLOAT_MAT3x2 0x8B67 -#define LOCAL_GL_FLOAT_MAT3x2_NV 0x8B67 -#define LOCAL_GL_FLOAT_MAT3x4 0x8B68 -#define LOCAL_GL_FLOAT_MAT3x4_NV 0x8B68 -#define LOCAL_GL_FLOAT_MAT4 0x8B5C -#define LOCAL_GL_FLOAT_MAT4_ARB 0x8B5C -#define LOCAL_GL_FLOAT_MAT4x2 0x8B69 -#define LOCAL_GL_FLOAT_MAT4x2_NV 0x8B69 -#define LOCAL_GL_FLOAT_MAT4x3 0x8B6A -#define LOCAL_GL_FLOAT_MAT4x3_NV 0x8B6A -#define LOCAL_GL_FLOAT_R16_NV 0x8884 -#define LOCAL_GL_FLOAT_R32_NV 0x8885 -#define LOCAL_GL_FLOAT_RG16_NV 0x8886 -#define LOCAL_GL_FLOAT_RG32_NV 0x8887 -#define LOCAL_GL_FLOAT_RGB16_NV 0x8888 -#define LOCAL_GL_FLOAT_RGB32_NV 0x8889 -#define LOCAL_GL_FLOAT_RGBA16_NV 0x888A -#define LOCAL_GL_FLOAT_RGBA32_NV 0x888B -#define LOCAL_GL_FLOAT_RGBA_MODE_NV 0x888E -#define LOCAL_GL_FLOAT_RGBA_NV 0x8883 -#define LOCAL_GL_FLOAT_RGB_NV 0x8882 -#define LOCAL_GL_FLOAT_RG_NV 0x8881 -#define LOCAL_GL_FLOAT_R_NV 0x8880 -#define LOCAL_GL_FLOAT_VEC2 0x8B50 -#define LOCAL_GL_FLOAT_VEC2_ARB 0x8B50 -#define LOCAL_GL_FLOAT_VEC3 0x8B51 -#define LOCAL_GL_FLOAT_VEC3_ARB 0x8B51 -#define LOCAL_GL_FLOAT_VEC4 0x8B52 -#define LOCAL_GL_FLOAT_VEC4_ARB 0x8B52 -#define LOCAL_GL_FOG 0x0B60 -#define LOCAL_GL_FOG_BIT 0x00000080 -#define LOCAL_GL_FOG_COLOR 0x0B66 -#define LOCAL_GL_FOG_COORD 0x8451 -#define LOCAL_GL_FOG_COORDINATE 0x8451 -#define LOCAL_GL_FOG_COORDINATE_ARRAY 0x8457 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define LOCAL_GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define LOCAL_GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define LOCAL_GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define LOCAL_GL_FOG_COORDINATE_EXT 0x8451 -#define LOCAL_GL_FOG_COORDINATE_SOURCE 0x8450 -#define LOCAL_GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define LOCAL_GL_FOG_COORD_ARRAY 0x8457 -#define LOCAL_GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define LOCAL_GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define LOCAL_GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define LOCAL_GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define LOCAL_GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define LOCAL_GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define LOCAL_GL_FOG_COORD_SRC 0x8450 -#define LOCAL_GL_FOG_DENSITY 0x0B62 -#define LOCAL_GL_FOG_DISTANCE_MODE_NV 0x855A -#define LOCAL_GL_FOG_END 0x0B64 -#define LOCAL_GL_FOG_FUNC_POINTS_SGIS 0x812B -#define LOCAL_GL_FOG_FUNC_SGIS 0x812A -#define LOCAL_GL_FOG_HINT 0x0C54 -#define LOCAL_GL_FOG_INDEX 0x0B61 -#define LOCAL_GL_FOG_MODE 0x0B65 -#define LOCAL_GL_FOG_OFFSET_SGIX 0x8198 -#define LOCAL_GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#define LOCAL_GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#define LOCAL_GL_FOG_START 0x0B63 -#define LOCAL_GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define LOCAL_GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define LOCAL_GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 -#define LOCAL_GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -#define LOCAL_GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define LOCAL_GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define LOCAL_GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define LOCAL_GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 -#define LOCAL_GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 -#define LOCAL_GL_FONT_UNAVAILABLE_NV 0x936A -#define LOCAL_GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define LOCAL_GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define LOCAL_GL_FONT_UNINTELLIGIBLE_NV 0x936B -#define LOCAL_GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define LOCAL_GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define LOCAL_GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define LOCAL_GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define LOCAL_GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define LOCAL_GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#define LOCAL_GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#define LOCAL_GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define LOCAL_GL_FOVEATION_ENABLE_BIT_QCOM 0x00000001 -#define LOCAL_GL_FOVEATION_SCALED_BIN_METHOD_BIT_QCOM 0x00000002 -#define LOCAL_GL_FRACTIONAL_EVEN 0x8E7C -#define LOCAL_GL_FRACTIONAL_EVEN_EXT 0x8E7C -#define LOCAL_GL_FRACTIONAL_EVEN_OES 0x8E7C -#define LOCAL_GL_FRACTIONAL_ODD 0x8E7B -#define LOCAL_GL_FRACTIONAL_ODD_EXT 0x8E7B -#define LOCAL_GL_FRACTIONAL_ODD_OES 0x8E7B -#define LOCAL_GL_FRAGMENTS_INSTRUMENT_COUNTERS_SGIX 0x8314 -#define LOCAL_GL_FRAGMENTS_INSTRUMENT_MAX_SGIX 0x8315 -#define LOCAL_GL_FRAGMENTS_INSTRUMENT_SGIX 0x8313 -#define LOCAL_GL_FRAGMENT_ALPHA_MODULATE_IMG 0x8C08 -#define LOCAL_GL_FRAGMENT_COLOR_EXT 0x834C -#define LOCAL_GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define LOCAL_GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define LOCAL_GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define LOCAL_GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE -#define LOCAL_GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD -#define LOCAL_GL_FRAGMENT_DEPTH 0x8452 -#define LOCAL_GL_FRAGMENT_DEPTH_EXT 0x8452 -#define LOCAL_GL_FRAGMENT_INPUT_NV 0x936D -#define LOCAL_GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -#define LOCAL_GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D -#define LOCAL_GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define LOCAL_GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define LOCAL_GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define LOCAL_GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define LOCAL_GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define LOCAL_GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define LOCAL_GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define LOCAL_GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#define LOCAL_GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define LOCAL_GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define LOCAL_GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define LOCAL_GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define LOCAL_GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define LOCAL_GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define LOCAL_GL_FRAGMENT_NORMAL_EXT 0x834A -#define LOCAL_GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define LOCAL_GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define LOCAL_GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8BB3 -#define LOCAL_GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8BB2 -#define LOCAL_GL_FRAGMENT_PROGRAM_CALLBACK_MESA 0x8BB1 -#define LOCAL_GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define LOCAL_GL_FRAGMENT_PROGRAM_NV 0x8870 -#define LOCAL_GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#define LOCAL_GL_FRAGMENT_PROGRAM_POSITION_MESA 0x8BB0 -#define LOCAL_GL_FRAGMENT_SHADER 0x8B30 -#define LOCAL_GL_FRAGMENT_SHADER_ARB 0x8B30 -#define LOCAL_GL_FRAGMENT_SHADER_ATI 0x8920 -#define LOCAL_GL_FRAGMENT_SHADER_BIT 0x00000002 -#define LOCAL_GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 -#define LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#define LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#define LOCAL_GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 -#define LOCAL_GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 -#define LOCAL_GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 -#define LOCAL_GL_FRAGMENT_SUBROUTINE 0x92EC -#define LOCAL_GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#define LOCAL_GL_FRAGMENT_TEXTURE 0x829F -#define LOCAL_GL_FRAMEBUFFER 0x8D40 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES 0x8CD1 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES 0x8CD0 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES 0x8CD3 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES 0x8CD2 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#define LOCAL_GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SCALE_IMG 0x913F -#define LOCAL_GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define LOCAL_GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define LOCAL_GL_FRAMEBUFFER_BINDING 0x8CA6 -#define LOCAL_GL_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define LOCAL_GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define LOCAL_GL_FRAMEBUFFER_BINDING_OES 0x8CA6 -#define LOCAL_GL_FRAMEBUFFER_BLEND 0x828B -#define LOCAL_GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define LOCAL_GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define LOCAL_GL_FRAMEBUFFER_COMPLETE_OES 0x8CD5 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT 0x8218 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 -#define LOCAL_GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define LOCAL_GL_FRAMEBUFFER_EXT 0x8D40 -#define LOCAL_GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM 0x96A2 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES 0x8CD6 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES 0x8CD9 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES 0x8CDB -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES 0x8CDA -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES 0x8CD7 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_AND_DOWNSAMPLE_IMG 0x913C -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES 0x8CDC -#define LOCAL_GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 -#define LOCAL_GL_FRAMEBUFFER_OES 0x8D40 -#define LOCAL_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 -#define LOCAL_GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 -#define LOCAL_GL_FRAMEBUFFER_RENDERABLE 0x8289 -#define LOCAL_GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A -#define LOCAL_GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 -#define LOCAL_GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 -#define LOCAL_GL_FRAMEBUFFER_SRGB 0x8DB9 -#define LOCAL_GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#define LOCAL_GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define LOCAL_GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define LOCAL_GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 -#define LOCAL_GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define LOCAL_GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define LOCAL_GL_FRAMEBUFFER_UNSUPPORTED_OES 0x8CDD -#define LOCAL_GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define LOCAL_GL_FRAMEZOOM_SGIX 0x818B -#define LOCAL_GL_FRAME_NV 0x8E26 -#define LOCAL_GL_FRONT 0x0404 -#define LOCAL_GL_FRONT_AND_BACK 0x0408 -#define LOCAL_GL_FRONT_FACE 0x0B46 -#define LOCAL_GL_FRONT_FACE_COMMAND_NV 0x0012 -#define LOCAL_GL_FRONT_LEFT 0x0400 -#define LOCAL_GL_FRONT_RIGHT 0x0401 -#define LOCAL_GL_FULL_RANGE_EXT 0x87E1 -#define LOCAL_GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define LOCAL_GL_FULL_SUPPORT 0x82B7 -#define LOCAL_GL_FUNC_ADD 0x8006 -#define LOCAL_GL_FUNC_ADD_EXT 0x8006 -#define LOCAL_GL_FUNC_ADD_OES 0x8006 -#define LOCAL_GL_FUNC_REVERSE_SUBTRACT 0x800B -#define LOCAL_GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#define LOCAL_GL_FUNC_REVERSE_SUBTRACT_OES 0x800B -#define LOCAL_GL_FUNC_SUBTRACT 0x800A -#define LOCAL_GL_FUNC_SUBTRACT_EXT 0x800A -#define LOCAL_GL_FUNC_SUBTRACT_OES 0x800A -#define LOCAL_GL_GCCSO_SHADER_BINARY_FJ 0x9260 -#define LOCAL_GL_GENERATE_MIPMAP 0x8191 -#define LOCAL_GL_GENERATE_MIPMAP_HINT 0x8192 -#define LOCAL_GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#define LOCAL_GL_GENERATE_MIPMAP_SGIS 0x8191 -#define LOCAL_GL_GENERIC_ATTRIB_NV 0x8C7D -#define LOCAL_GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#define LOCAL_GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define LOCAL_GL_GEOMETRY_INPUT_TYPE 0x8917 -#define LOCAL_GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define LOCAL_GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define LOCAL_GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917 -#define LOCAL_GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917 -#define LOCAL_GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918 -#define LOCAL_GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918 -#define LOCAL_GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916 -#define LOCAL_GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916 -#define LOCAL_GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define LOCAL_GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define LOCAL_GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define LOCAL_GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define LOCAL_GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define LOCAL_GL_GEOMETRY_SHADER 0x8DD9 -#define LOCAL_GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define LOCAL_GL_GEOMETRY_SHADER_BIT 0x00000004 -#define LOCAL_GL_GEOMETRY_SHADER_BIT_EXT 0x00000004 -#define LOCAL_GL_GEOMETRY_SHADER_BIT_OES 0x00000004 -#define LOCAL_GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define LOCAL_GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define LOCAL_GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F -#define LOCAL_GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F -#define LOCAL_GL_GEOMETRY_SHADER_OES 0x8DD9 -#define LOCAL_GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 -#define LOCAL_GL_GEOMETRY_SUBROUTINE 0x92EB -#define LOCAL_GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#define LOCAL_GL_GEOMETRY_TEXTURE 0x829E -#define LOCAL_GL_GEOMETRY_VERTICES_OUT 0x8916 -#define LOCAL_GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define LOCAL_GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define LOCAL_GL_GEQUAL 0x0206 -#define LOCAL_GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 -#define LOCAL_GL_GET_TEXTURE_IMAGE_TYPE 0x8292 -#define LOCAL_GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#define LOCAL_GL_GLOBAL_ALPHA_SUN 0x81D9 -#define LOCAL_GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define LOCAL_GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define LOCAL_GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define LOCAL_GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define LOCAL_GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define LOCAL_GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define LOCAL_GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define LOCAL_GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define LOCAL_GL_GLYPH_WIDTH_BIT_NV 0x01 -#define LOCAL_GL_GPU_ADDRESS_NV 0x8F34 -#define LOCAL_GL_GPU_DISJOINT_EXT 0x8FBB -#define LOCAL_GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 -#define LOCAL_GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 -#define LOCAL_GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B -#define LOCAL_GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A -#define LOCAL_GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 -#define LOCAL_GL_GPU_OPTIMIZED_QCOM 0x8FB2 -#define LOCAL_GL_GREATER 0x0204 -#define LOCAL_GL_GREEN 0x1904 -#define LOCAL_GL_GREEN_BIAS 0x0D19 -#define LOCAL_GL_GREEN_BITS 0x0D53 -#define LOCAL_GL_GREEN_BIT_ATI 0x00000002 -#define LOCAL_GL_GREEN_INTEGER 0x8D95 -#define LOCAL_GL_GREEN_INTEGER_EXT 0x8D95 -#define LOCAL_GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define LOCAL_GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define LOCAL_GL_GREEN_NV 0x1904 -#define LOCAL_GL_GREEN_SCALE 0x0D18 -#define LOCAL_GL_GS_PROGRAM_BINARY_MTK 0x9641 -#define LOCAL_GL_GS_SHADER_BINARY_MTK 0x9640 -#define LOCAL_GL_GUILTY_CONTEXT_RESET 0x8253 -#define LOCAL_GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define LOCAL_GL_GUILTY_CONTEXT_RESET_EXT 0x8253 -#define LOCAL_GL_GUILTY_CONTEXT_RESET_KHR 0x8253 -#define LOCAL_GL_HALF_APPLE 0x140B -#define LOCAL_GL_HALF_BIAS_NEGATE_NV 0x853B -#define LOCAL_GL_HALF_BIAS_NORMAL_NV 0x853A -#define LOCAL_GL_HALF_BIT_ATI 0x00000008 -#define LOCAL_GL_HALF_FLOAT 0x140B -#define LOCAL_GL_HALF_FLOAT_ARB 0x140B -#define LOCAL_GL_HALF_FLOAT_NV 0x140B -#define LOCAL_GL_HALF_FLOAT_OES 0x8D61 -#define LOCAL_GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B -#define LOCAL_GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C -#define LOCAL_GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 -#define LOCAL_GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A -#define LOCAL_GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 -#define LOCAL_GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 -#define LOCAL_GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 -#define LOCAL_GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 -#define LOCAL_GL_HARDLIGHT 0x929B -#define LOCAL_GL_HARDLIGHT_KHR 0x929B -#define LOCAL_GL_HARDLIGHT_NV 0x929B -#define LOCAL_GL_HARDMIX_NV 0x92A9 -#define LOCAL_GL_HIGH_FLOAT 0x8DF2 -#define LOCAL_GL_HIGH_INT 0x8DF5 -#define LOCAL_GL_HILO16_NV 0x86F8 -#define LOCAL_GL_HILO8_NV 0x885E -#define LOCAL_GL_HILO_NV 0x86F4 -#define LOCAL_GL_HINT_BIT 0x00008000 -#define LOCAL_GL_HISTOGRAM 0x8024 -#define LOCAL_GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define LOCAL_GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define LOCAL_GL_HISTOGRAM_BLUE_SIZE 0x802A -#define LOCAL_GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define LOCAL_GL_HISTOGRAM_EXT 0x8024 -#define LOCAL_GL_HISTOGRAM_FORMAT 0x8027 -#define LOCAL_GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define LOCAL_GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define LOCAL_GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define LOCAL_GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define LOCAL_GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define LOCAL_GL_HISTOGRAM_RED_SIZE 0x8028 -#define LOCAL_GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define LOCAL_GL_HISTOGRAM_SINK 0x802D -#define LOCAL_GL_HISTOGRAM_SINK_EXT 0x802D -#define LOCAL_GL_HISTOGRAM_WIDTH 0x8026 -#define LOCAL_GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define LOCAL_GL_HI_BIAS_NV 0x8714 -#define LOCAL_GL_HI_SCALE_NV 0x870E -#define LOCAL_GL_HORIZONTAL_LINE_TO_NV 0x06 -#define LOCAL_GL_HSL_COLOR 0x92AF -#define LOCAL_GL_HSL_COLOR_KHR 0x92AF -#define LOCAL_GL_HSL_COLOR_NV 0x92AF -#define LOCAL_GL_HSL_HUE 0x92AD -#define LOCAL_GL_HSL_HUE_KHR 0x92AD -#define LOCAL_GL_HSL_HUE_NV 0x92AD -#define LOCAL_GL_HSL_LUMINOSITY 0x92B0 -#define LOCAL_GL_HSL_LUMINOSITY_KHR 0x92B0 -#define LOCAL_GL_HSL_LUMINOSITY_NV 0x92B0 -#define LOCAL_GL_HSL_SATURATION 0x92AE -#define LOCAL_GL_HSL_SATURATION_KHR 0x92AE -#define LOCAL_GL_HSL_SATURATION_NV 0x92AE -#define LOCAL_GL_IDENTITY_NV 0x862A -#define LOCAL_GL_IGNORE_BORDER_HP 0x8150 -#define LOCAL_GL_IMAGE_1D 0x904C -#define LOCAL_GL_IMAGE_1D_ARRAY 0x9052 -#define LOCAL_GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define LOCAL_GL_IMAGE_1D_EXT 0x904C -#define LOCAL_GL_IMAGE_2D 0x904D -#define LOCAL_GL_IMAGE_2D_ARRAY 0x9053 -#define LOCAL_GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define LOCAL_GL_IMAGE_2D_EXT 0x904D -#define LOCAL_GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define LOCAL_GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define LOCAL_GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define LOCAL_GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define LOCAL_GL_IMAGE_2D_RECT 0x904F -#define LOCAL_GL_IMAGE_2D_RECT_EXT 0x904F -#define LOCAL_GL_IMAGE_3D 0x904E -#define LOCAL_GL_IMAGE_3D_EXT 0x904E -#define LOCAL_GL_IMAGE_BINDING_ACCESS 0x8F3E -#define LOCAL_GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define LOCAL_GL_IMAGE_BINDING_FORMAT 0x906E -#define LOCAL_GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define LOCAL_GL_IMAGE_BINDING_LAYER 0x8F3D -#define LOCAL_GL_IMAGE_BINDING_LAYERED 0x8F3C -#define LOCAL_GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define LOCAL_GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define LOCAL_GL_IMAGE_BINDING_LEVEL 0x8F3B -#define LOCAL_GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define LOCAL_GL_IMAGE_BINDING_NAME 0x8F3A -#define LOCAL_GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define LOCAL_GL_IMAGE_BUFFER 0x9051 -#define LOCAL_GL_IMAGE_BUFFER_EXT 0x9051 -#define LOCAL_GL_IMAGE_BUFFER_OES 0x9051 -#define LOCAL_GL_IMAGE_CLASS_10_10_10_2 0x82C3 -#define LOCAL_GL_IMAGE_CLASS_11_11_10 0x82C2 -#define LOCAL_GL_IMAGE_CLASS_1_X_16 0x82BE -#define LOCAL_GL_IMAGE_CLASS_1_X_32 0x82BB -#define LOCAL_GL_IMAGE_CLASS_1_X_8 0x82C1 -#define LOCAL_GL_IMAGE_CLASS_2_X_16 0x82BD -#define LOCAL_GL_IMAGE_CLASS_2_X_32 0x82BA -#define LOCAL_GL_IMAGE_CLASS_2_X_8 0x82C0 -#define LOCAL_GL_IMAGE_CLASS_4_X_16 0x82BC -#define LOCAL_GL_IMAGE_CLASS_4_X_32 0x82B9 -#define LOCAL_GL_IMAGE_CLASS_4_X_8 0x82BF -#define LOCAL_GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 -#define LOCAL_GL_IMAGE_CUBE 0x9050 -#define LOCAL_GL_IMAGE_CUBE_EXT 0x9050 -#define LOCAL_GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define LOCAL_GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define LOCAL_GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054 -#define LOCAL_GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define LOCAL_GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define LOCAL_GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define LOCAL_GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define LOCAL_GL_IMAGE_MAG_FILTER_HP 0x815C -#define LOCAL_GL_IMAGE_MIN_FILTER_HP 0x815D -#define LOCAL_GL_IMAGE_PIXEL_FORMAT 0x82A9 -#define LOCAL_GL_IMAGE_PIXEL_TYPE 0x82AA -#define LOCAL_GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define LOCAL_GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define LOCAL_GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define LOCAL_GL_IMAGE_SCALE_X_HP 0x8155 -#define LOCAL_GL_IMAGE_SCALE_Y_HP 0x8156 -#define LOCAL_GL_IMAGE_TEXEL_SIZE 0x82A7 -#define LOCAL_GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define LOCAL_GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define LOCAL_GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define LOCAL_GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#define LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define LOCAL_GL_INCLUSIVE_EXT 0x8F10 -#define LOCAL_GL_INCR 0x1E02 -#define LOCAL_GL_INCR_WRAP 0x8507 -#define LOCAL_GL_INCR_WRAP_EXT 0x8507 -#define LOCAL_GL_INCR_WRAP_OES 0x8507 -#define LOCAL_GL_INDEX 0x8222 -#define LOCAL_GL_INDEX_ARRAY 0x8077 -#define LOCAL_GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define LOCAL_GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define LOCAL_GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define LOCAL_GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define LOCAL_GL_INDEX_ARRAY_EXT 0x8077 -#define LOCAL_GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define LOCAL_GL_INDEX_ARRAY_LIST_IBM 103073 -#define LOCAL_GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define LOCAL_GL_INDEX_ARRAY_POINTER 0x8091 -#define LOCAL_GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define LOCAL_GL_INDEX_ARRAY_STRIDE 0x8086 -#define LOCAL_GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define LOCAL_GL_INDEX_ARRAY_TYPE 0x8085 -#define LOCAL_GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define LOCAL_GL_INDEX_BITS 0x0D51 -#define LOCAL_GL_INDEX_BIT_PGI 0x00080000 -#define LOCAL_GL_INDEX_CLEAR_VALUE 0x0C20 -#define LOCAL_GL_INDEX_LOGIC_OP 0x0BF1 -#define LOCAL_GL_INDEX_MATERIAL_EXT 0x81B8 -#define LOCAL_GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#define LOCAL_GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define LOCAL_GL_INDEX_MODE 0x0C30 -#define LOCAL_GL_INDEX_OFFSET 0x0D13 -#define LOCAL_GL_INDEX_SHIFT 0x0D12 -#define LOCAL_GL_INDEX_TEST_EXT 0x81B5 -#define LOCAL_GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define LOCAL_GL_INDEX_TEST_REF_EXT 0x81B7 -#define LOCAL_GL_INDEX_WRITEMASK 0x0C21 -#define LOCAL_GL_INFO_LOG_LENGTH 0x8B84 -#define LOCAL_GL_INNOCENT_CONTEXT_RESET 0x8254 -#define LOCAL_GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define LOCAL_GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 -#define LOCAL_GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 -#define LOCAL_GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define LOCAL_GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#define LOCAL_GL_INT 0x1404 -#define LOCAL_GL_INT16_NV 0x8FE4 -#define LOCAL_GL_INT16_VEC2_NV 0x8FE5 -#define LOCAL_GL_INT16_VEC3_NV 0x8FE6 -#define LOCAL_GL_INT16_VEC4_NV 0x8FE7 -#define LOCAL_GL_INT64_ARB 0x140E -#define LOCAL_GL_INT64_NV 0x140E -#define LOCAL_GL_INT64_VEC2_ARB 0x8FE9 -#define LOCAL_GL_INT64_VEC2_NV 0x8FE9 -#define LOCAL_GL_INT64_VEC3_ARB 0x8FEA -#define LOCAL_GL_INT64_VEC3_NV 0x8FEA -#define LOCAL_GL_INT64_VEC4_ARB 0x8FEB -#define LOCAL_GL_INT64_VEC4_NV 0x8FEB -#define LOCAL_GL_INT8_NV 0x8FE0 -#define LOCAL_GL_INT8_VEC2_NV 0x8FE1 -#define LOCAL_GL_INT8_VEC3_NV 0x8FE2 -#define LOCAL_GL_INT8_VEC4_NV 0x8FE3 -#define LOCAL_GL_INTENSITY 0x8049 -#define LOCAL_GL_INTENSITY12 0x804C -#define LOCAL_GL_INTENSITY12_EXT 0x804C -#define LOCAL_GL_INTENSITY16 0x804D -#define LOCAL_GL_INTENSITY16F_ARB 0x881D -#define LOCAL_GL_INTENSITY16I_EXT 0x8D8B -#define LOCAL_GL_INTENSITY16UI_EXT 0x8D79 -#define LOCAL_GL_INTENSITY16_EXT 0x804D -#define LOCAL_GL_INTENSITY16_SNORM 0x901B -#define LOCAL_GL_INTENSITY32F_ARB 0x8817 -#define LOCAL_GL_INTENSITY32I_EXT 0x8D85 -#define LOCAL_GL_INTENSITY32UI_EXT 0x8D73 -#define LOCAL_GL_INTENSITY4 0x804A -#define LOCAL_GL_INTENSITY4_EXT 0x804A -#define LOCAL_GL_INTENSITY8 0x804B -#define LOCAL_GL_INTENSITY8I_EXT 0x8D91 -#define LOCAL_GL_INTENSITY8UI_EXT 0x8D7F -#define LOCAL_GL_INTENSITY8_EXT 0x804B -#define LOCAL_GL_INTENSITY8_SNORM 0x9017 -#define LOCAL_GL_INTENSITY_EXT 0x8049 -#define LOCAL_GL_INTENSITY_FLOAT16_APPLE 0x881D -#define LOCAL_GL_INTENSITY_FLOAT16_ATI 0x881D -#define LOCAL_GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define LOCAL_GL_INTENSITY_FLOAT32_ATI 0x8817 -#define LOCAL_GL_INTENSITY_SNORM 0x9013 -#define LOCAL_GL_INTERLACE_OML 0x8980 -#define LOCAL_GL_INTERLACE_READ_INGR 0x8568 -#define LOCAL_GL_INTERLACE_READ_OML 0x8981 -#define LOCAL_GL_INTERLACE_SGIX 0x8094 -#define LOCAL_GL_INTERLEAVED_ATTRIBS 0x8C8C -#define LOCAL_GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define LOCAL_GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define LOCAL_GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 -#define LOCAL_GL_INTERNALFORMAT_ALPHA_TYPE 0x827B -#define LOCAL_GL_INTERNALFORMAT_BLUE_SIZE 0x8273 -#define LOCAL_GL_INTERNALFORMAT_BLUE_TYPE 0x827A -#define LOCAL_GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 -#define LOCAL_GL_INTERNALFORMAT_DEPTH_TYPE 0x827C -#define LOCAL_GL_INTERNALFORMAT_GREEN_SIZE 0x8272 -#define LOCAL_GL_INTERNALFORMAT_GREEN_TYPE 0x8279 -#define LOCAL_GL_INTERNALFORMAT_PREFERRED 0x8270 -#define LOCAL_GL_INTERNALFORMAT_RED_SIZE 0x8271 -#define LOCAL_GL_INTERNALFORMAT_RED_TYPE 0x8278 -#define LOCAL_GL_INTERNALFORMAT_SHARED_SIZE 0x8277 -#define LOCAL_GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 -#define LOCAL_GL_INTERNALFORMAT_STENCIL_TYPE 0x827D -#define LOCAL_GL_INTERNALFORMAT_SUPPORTED 0x826F -#define LOCAL_GL_INTERPOLATE 0x8575 -#define LOCAL_GL_INTERPOLATE_ARB 0x8575 -#define LOCAL_GL_INTERPOLATE_EXT 0x8575 -#define LOCAL_GL_INT_10_10_10_2_OES 0x8DF7 -#define LOCAL_GL_INT_2_10_10_10_REV 0x8D9F -#define LOCAL_GL_INT_IMAGE_1D 0x9057 -#define LOCAL_GL_INT_IMAGE_1D_ARRAY 0x905D -#define LOCAL_GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define LOCAL_GL_INT_IMAGE_1D_EXT 0x9057 -#define LOCAL_GL_INT_IMAGE_2D 0x9058 -#define LOCAL_GL_INT_IMAGE_2D_ARRAY 0x905E -#define LOCAL_GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define LOCAL_GL_INT_IMAGE_2D_EXT 0x9058 -#define LOCAL_GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define LOCAL_GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define LOCAL_GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define LOCAL_GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define LOCAL_GL_INT_IMAGE_2D_RECT 0x905A -#define LOCAL_GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define LOCAL_GL_INT_IMAGE_3D 0x9059 -#define LOCAL_GL_INT_IMAGE_3D_EXT 0x9059 -#define LOCAL_GL_INT_IMAGE_BUFFER 0x905C -#define LOCAL_GL_INT_IMAGE_BUFFER_EXT 0x905C -#define LOCAL_GL_INT_IMAGE_BUFFER_OES 0x905C -#define LOCAL_GL_INT_IMAGE_CUBE 0x905B -#define LOCAL_GL_INT_IMAGE_CUBE_EXT 0x905B -#define LOCAL_GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define LOCAL_GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define LOCAL_GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F -#define LOCAL_GL_INT_SAMPLER_1D 0x8DC9 -#define LOCAL_GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define LOCAL_GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define LOCAL_GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define LOCAL_GL_INT_SAMPLER_2D 0x8DCA -#define LOCAL_GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define LOCAL_GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define LOCAL_GL_INT_SAMPLER_2D_EXT 0x8DCA -#define LOCAL_GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define LOCAL_GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define LOCAL_GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C -#define LOCAL_GL_INT_SAMPLER_2D_RECT 0x8DCD -#define LOCAL_GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define LOCAL_GL_INT_SAMPLER_3D 0x8DCB -#define LOCAL_GL_INT_SAMPLER_3D_EXT 0x8DCB -#define LOCAL_GL_INT_SAMPLER_BUFFER 0x8DD0 -#define LOCAL_GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define LOCAL_GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define LOCAL_GL_INT_SAMPLER_BUFFER_OES 0x8DD0 -#define LOCAL_GL_INT_SAMPLER_CUBE 0x8DCC -#define LOCAL_GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define LOCAL_GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define LOCAL_GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define LOCAL_GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E -#define LOCAL_GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E -#define LOCAL_GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define LOCAL_GL_INT_VEC2 0x8B53 -#define LOCAL_GL_INT_VEC2_ARB 0x8B53 -#define LOCAL_GL_INT_VEC3 0x8B54 -#define LOCAL_GL_INT_VEC3_ARB 0x8B54 -#define LOCAL_GL_INT_VEC4 0x8B55 -#define LOCAL_GL_INT_VEC4_ARB 0x8B55 -#define LOCAL_GL_INVALID_ENUM 0x0500 -#define LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION_OES 0x0506 -#define LOCAL_GL_INVALID_INDEX 0xFFFFFFFF -#define LOCAL_GL_INVALID_OPERATION 0x0502 -#define LOCAL_GL_INVALID_VALUE 0x0501 -#define LOCAL_GL_INVARIANT_DATATYPE_EXT 0x87EB -#define LOCAL_GL_INVARIANT_EXT 0x87C2 -#define LOCAL_GL_INVARIANT_VALUE_EXT 0x87EA -#define LOCAL_GL_INVERSE_NV 0x862B -#define LOCAL_GL_INVERSE_TRANSPOSE_NV 0x862D -#define LOCAL_GL_INVERT 0x150A -#define LOCAL_GL_INVERTED_SCREEN_W_REND 0x8491 -#define LOCAL_GL_INVERT_OVG_NV 0x92B4 -#define LOCAL_GL_INVERT_RGB_NV 0x92A3 -#define LOCAL_GL_IR_INSTRUMENT1_SGIX 0x817F -#define LOCAL_GL_ISOLINES 0x8E7A -#define LOCAL_GL_ISOLINES_EXT 0x8E7A -#define LOCAL_GL_ISOLINES_OES 0x8E7A -#define LOCAL_GL_IS_PER_PATCH 0x92E7 -#define LOCAL_GL_IS_PER_PATCH_EXT 0x92E7 -#define LOCAL_GL_IS_PER_PATCH_OES 0x92E7 -#define LOCAL_GL_IS_ROW_MAJOR 0x9300 -#define LOCAL_GL_ITALIC_BIT_NV 0x02 -#define LOCAL_GL_IUI_N3F_V2F_EXT 0x81AF -#define LOCAL_GL_IUI_N3F_V3F_EXT 0x81B0 -#define LOCAL_GL_IUI_V2F_EXT 0x81AD -#define LOCAL_GL_IUI_V3F_EXT 0x81AE -#define LOCAL_GL_KEEP 0x1E00 -#define LOCAL_GL_LARGE_CCW_ARC_TO_NV 0x16 -#define LOCAL_GL_LARGE_CW_ARC_TO_NV 0x18 -#define LOCAL_GL_LAST_VERTEX_CONVENTION 0x8E4E -#define LOCAL_GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define LOCAL_GL_LAST_VERTEX_CONVENTION_OES 0x8E4E -#define LOCAL_GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define LOCAL_GL_LAYER_NV 0x8DAA -#define LOCAL_GL_LAYER_PROVOKING_VERTEX 0x825E -#define LOCAL_GL_LAYER_PROVOKING_VERTEX_EXT 0x825E -#define LOCAL_GL_LAYER_PROVOKING_VERTEX_OES 0x825E -#define LOCAL_GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E -#define LOCAL_GL_LAYOUT_DEFAULT_INTEL 0 -#define LOCAL_GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F -#define LOCAL_GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 -#define LOCAL_GL_LAYOUT_GENERAL_EXT 0x958D -#define LOCAL_GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 -#define LOCAL_GL_LAYOUT_LINEAR_INTEL 1 -#define LOCAL_GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 -#define LOCAL_GL_LAYOUT_TRANSFER_DST_EXT 0x9593 -#define LOCAL_GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 -#define LOCAL_GL_LEFT 0x0406 -#define LOCAL_GL_LEQUAL 0x0203 -#define LOCAL_GL_LERP_ATI 0x8969 -#define LOCAL_GL_LESS 0x0201 -#define LOCAL_GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 -#define LOCAL_GL_LIGHT0 0x4000 -#define LOCAL_GL_LIGHT1 0x4001 -#define LOCAL_GL_LIGHT2 0x4002 -#define LOCAL_GL_LIGHT3 0x4003 -#define LOCAL_GL_LIGHT4 0x4004 -#define LOCAL_GL_LIGHT5 0x4005 -#define LOCAL_GL_LIGHT6 0x4006 -#define LOCAL_GL_LIGHT7 0x4007 -#define LOCAL_GL_LIGHTEN 0x9298 -#define LOCAL_GL_LIGHTEN_KHR 0x9298 -#define LOCAL_GL_LIGHTEN_NV 0x9298 -#define LOCAL_GL_LIGHTING 0x0B50 -#define LOCAL_GL_LIGHTING_BIT 0x00000040 -#define LOCAL_GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define LOCAL_GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define LOCAL_GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define LOCAL_GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define LOCAL_GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define LOCAL_GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#define LOCAL_GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define LOCAL_GL_LINE 0x1B01 -#define LOCAL_GL_LINEAR 0x2601 -#define LOCAL_GL_LINEARBURN_NV 0x92A5 -#define LOCAL_GL_LINEARDODGE_NV 0x92A4 -#define LOCAL_GL_LINEARLIGHT_NV 0x92A7 -#define LOCAL_GL_LINEAR_ATTENUATION 0x1208 -#define LOCAL_GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define LOCAL_GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#define LOCAL_GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define LOCAL_GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define LOCAL_GL_LINEAR_DETAIL_SGIS 0x8097 -#define LOCAL_GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define LOCAL_GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define LOCAL_GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define LOCAL_GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define LOCAL_GL_LINEAR_SHARPEN_SGIS 0x80AD -#define LOCAL_GL_LINEAR_TILING_EXT 0x9585 -#define LOCAL_GL_LINES 0x0001 -#define LOCAL_GL_LINES_ADJACENCY 0x000A -#define LOCAL_GL_LINES_ADJACENCY_ARB 0x000A -#define LOCAL_GL_LINES_ADJACENCY_EXT 0x000A -#define LOCAL_GL_LINES_ADJACENCY_OES 0x000A -#define LOCAL_GL_LINE_BIT 0x00000004 -#define LOCAL_GL_LINE_LOOP 0x0002 -#define LOCAL_GL_LINE_NV 0x1B01 -#define LOCAL_GL_LINE_QUALITY_HINT_SGIX 0x835B -#define LOCAL_GL_LINE_RESET_TOKEN 0x0707 -#define LOCAL_GL_LINE_SMOOTH 0x0B20 -#define LOCAL_GL_LINE_SMOOTH_HINT 0x0C52 -#define LOCAL_GL_LINE_STIPPLE 0x0B24 -#define LOCAL_GL_LINE_STIPPLE_PATTERN 0x0B25 -#define LOCAL_GL_LINE_STIPPLE_REPEAT 0x0B26 -#define LOCAL_GL_LINE_STRIP 0x0003 -#define LOCAL_GL_LINE_STRIP_ADJACENCY 0x000B -#define LOCAL_GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define LOCAL_GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define LOCAL_GL_LINE_STRIP_ADJACENCY_OES 0x000B -#define LOCAL_GL_LINE_TOKEN 0x0702 -#define LOCAL_GL_LINE_TO_NV 0x04 -#define LOCAL_GL_LINE_WIDTH 0x0B21 -#define LOCAL_GL_LINE_WIDTH_COMMAND_NV 0x000D -#define LOCAL_GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define LOCAL_GL_LINE_WIDTH_RANGE 0x0B22 -#define LOCAL_GL_LINK_STATUS 0x8B82 -#define LOCAL_GL_LIST_BASE 0x0B32 -#define LOCAL_GL_LIST_BIT 0x00020000 -#define LOCAL_GL_LIST_INDEX 0x0B33 -#define LOCAL_GL_LIST_MODE 0x0B30 -#define LOCAL_GL_LIST_PRIORITY_SGIX 0x8182 -#define LOCAL_GL_LOAD 0x0101 -#define LOCAL_GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#define LOCAL_GL_LOCAL_CONSTANT_EXT 0x87C3 -#define LOCAL_GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define LOCAL_GL_LOCAL_EXT 0x87C4 -#define LOCAL_GL_LOCATION 0x930E -#define LOCAL_GL_LOCATION_COMPONENT 0x934A -#define LOCAL_GL_LOCATION_INDEX 0x930F -#define LOCAL_GL_LOCATION_INDEX_EXT 0x930F -#define LOCAL_GL_LOGIC_OP 0x0BF1 -#define LOCAL_GL_LOGIC_OP_MODE 0x0BF0 -#define LOCAL_GL_LOSE_CONTEXT_ON_RESET 0x8252 -#define LOCAL_GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define LOCAL_GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 -#define LOCAL_GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 -#define LOCAL_GL_LOWER_LEFT 0x8CA1 -#define LOCAL_GL_LOW_FLOAT 0x8DF0 -#define LOCAL_GL_LOW_INT 0x8DF3 -#define LOCAL_GL_LO_BIAS_NV 0x8715 -#define LOCAL_GL_LO_SCALE_NV 0x870F -#define LOCAL_GL_LUID_SIZE_EXT 8 -#define LOCAL_GL_LUMINANCE 0x1909 -#define LOCAL_GL_LUMINANCE12 0x8041 -#define LOCAL_GL_LUMINANCE12_ALPHA12 0x8047 -#define LOCAL_GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define LOCAL_GL_LUMINANCE12_ALPHA4 0x8046 -#define LOCAL_GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define LOCAL_GL_LUMINANCE12_EXT 0x8041 -#define LOCAL_GL_LUMINANCE16 0x8042 -#define LOCAL_GL_LUMINANCE16F_ARB 0x881E -#define LOCAL_GL_LUMINANCE16F_EXT 0x881E -#define LOCAL_GL_LUMINANCE16I_EXT 0x8D8C -#define LOCAL_GL_LUMINANCE16UI_EXT 0x8D7A -#define LOCAL_GL_LUMINANCE16_ALPHA16 0x8048 -#define LOCAL_GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define LOCAL_GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define LOCAL_GL_LUMINANCE16_EXT 0x8042 -#define LOCAL_GL_LUMINANCE16_SNORM 0x9019 -#define LOCAL_GL_LUMINANCE32F_ARB 0x8818 -#define LOCAL_GL_LUMINANCE32F_EXT 0x8818 -#define LOCAL_GL_LUMINANCE32I_EXT 0x8D86 -#define LOCAL_GL_LUMINANCE32UI_EXT 0x8D74 -#define LOCAL_GL_LUMINANCE4 0x803F -#define LOCAL_GL_LUMINANCE4_ALPHA4 0x8043 -#define LOCAL_GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define LOCAL_GL_LUMINANCE4_ALPHA4_OES 0x8043 -#define LOCAL_GL_LUMINANCE4_EXT 0x803F -#define LOCAL_GL_LUMINANCE6_ALPHA2 0x8044 -#define LOCAL_GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define LOCAL_GL_LUMINANCE8 0x8040 -#define LOCAL_GL_LUMINANCE8I_EXT 0x8D92 -#define LOCAL_GL_LUMINANCE8UI_EXT 0x8D80 -#define LOCAL_GL_LUMINANCE8_ALPHA8 0x8045 -#define LOCAL_GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define LOCAL_GL_LUMINANCE8_ALPHA8_OES 0x8045 -#define LOCAL_GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define LOCAL_GL_LUMINANCE8_EXT 0x8040 -#define LOCAL_GL_LUMINANCE8_OES 0x8040 -#define LOCAL_GL_LUMINANCE8_SNORM 0x9015 -#define LOCAL_GL_LUMINANCE_ALPHA 0x190A -#define LOCAL_GL_LUMINANCE_ALPHA16F_ARB 0x881F -#define LOCAL_GL_LUMINANCE_ALPHA16F_EXT 0x881F -#define LOCAL_GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define LOCAL_GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define LOCAL_GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define LOCAL_GL_LUMINANCE_ALPHA32F_EXT 0x8819 -#define LOCAL_GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define LOCAL_GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define LOCAL_GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define LOCAL_GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define LOCAL_GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define LOCAL_GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#define LOCAL_GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define LOCAL_GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define LOCAL_GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define LOCAL_GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define LOCAL_GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define LOCAL_GL_LUMINANCE_FLOAT16_ATI 0x881E -#define LOCAL_GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define LOCAL_GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define LOCAL_GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define LOCAL_GL_LUMINANCE_SNORM 0x9011 -#define LOCAL_GL_MAD_ATI 0x8968 -#define LOCAL_GL_MAGNITUDE_BIAS_NV 0x8718 -#define LOCAL_GL_MAGNITUDE_SCALE_NV 0x8712 -#define LOCAL_GL_MAJOR_VERSION 0x821B -#define LOCAL_GL_MALI_PROGRAM_BINARY_ARM 0x8F61 -#define LOCAL_GL_MALI_SHADER_BINARY_ARM 0x8F60 -#define LOCAL_GL_MANUAL_GENERATE_MIPMAP 0x8294 -#define LOCAL_GL_MAP1_BINORMAL_EXT 0x8446 -#define LOCAL_GL_MAP1_COLOR_4 0x0D90 -#define LOCAL_GL_MAP1_GRID_DOMAIN 0x0DD0 -#define LOCAL_GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define LOCAL_GL_MAP1_INDEX 0x0D91 -#define LOCAL_GL_MAP1_NORMAL 0x0D92 -#define LOCAL_GL_MAP1_TANGENT_EXT 0x8444 -#define LOCAL_GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define LOCAL_GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define LOCAL_GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define LOCAL_GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define LOCAL_GL_MAP1_VERTEX_3 0x0D97 -#define LOCAL_GL_MAP1_VERTEX_4 0x0D98 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define LOCAL_GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define LOCAL_GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define LOCAL_GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define LOCAL_GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define LOCAL_GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define LOCAL_GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define LOCAL_GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define LOCAL_GL_MAP2_BINORMAL_EXT 0x8447 -#define LOCAL_GL_MAP2_COLOR_4 0x0DB0 -#define LOCAL_GL_MAP2_GRID_DOMAIN 0x0DD2 -#define LOCAL_GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define LOCAL_GL_MAP2_INDEX 0x0DB1 -#define LOCAL_GL_MAP2_NORMAL 0x0DB2 -#define LOCAL_GL_MAP2_TANGENT_EXT 0x8445 -#define LOCAL_GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define LOCAL_GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define LOCAL_GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define LOCAL_GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define LOCAL_GL_MAP2_VERTEX_3 0x0DB7 -#define LOCAL_GL_MAP2_VERTEX_4 0x0DB8 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define LOCAL_GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define LOCAL_GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define LOCAL_GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define LOCAL_GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define LOCAL_GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#define LOCAL_GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define LOCAL_GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define LOCAL_GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define LOCAL_GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define LOCAL_GL_MAP_COHERENT_BIT 0x0080 -#define LOCAL_GL_MAP_COHERENT_BIT_EXT 0x0080 -#define LOCAL_GL_MAP_COLOR 0x0D10 -#define LOCAL_GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define LOCAL_GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 -#define LOCAL_GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define LOCAL_GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 -#define LOCAL_GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define LOCAL_GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 -#define LOCAL_GL_MAP_PERSISTENT_BIT 0x0040 -#define LOCAL_GL_MAP_PERSISTENT_BIT_EXT 0x0040 -#define LOCAL_GL_MAP_READ_BIT 0x0001 -#define LOCAL_GL_MAP_READ_BIT_EXT 0x0001 -#define LOCAL_GL_MAP_STENCIL 0x0D11 -#define LOCAL_GL_MAP_TESSELLATION_NV 0x86C2 -#define LOCAL_GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#define LOCAL_GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 -#define LOCAL_GL_MAP_WRITE_BIT 0x0002 -#define LOCAL_GL_MAP_WRITE_BIT_EXT 0x0002 -#define LOCAL_GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define LOCAL_GL_MATRIX0_ARB 0x88C0 -#define LOCAL_GL_MATRIX0_NV 0x8630 -#define LOCAL_GL_MATRIX10_ARB 0x88CA -#define LOCAL_GL_MATRIX11_ARB 0x88CB -#define LOCAL_GL_MATRIX12_ARB 0x88CC -#define LOCAL_GL_MATRIX13_ARB 0x88CD -#define LOCAL_GL_MATRIX14_ARB 0x88CE -#define LOCAL_GL_MATRIX15_ARB 0x88CF -#define LOCAL_GL_MATRIX16_ARB 0x88D0 -#define LOCAL_GL_MATRIX17_ARB 0x88D1 -#define LOCAL_GL_MATRIX18_ARB 0x88D2 -#define LOCAL_GL_MATRIX19_ARB 0x88D3 -#define LOCAL_GL_MATRIX1_ARB 0x88C1 -#define LOCAL_GL_MATRIX1_NV 0x8631 -#define LOCAL_GL_MATRIX20_ARB 0x88D4 -#define LOCAL_GL_MATRIX21_ARB 0x88D5 -#define LOCAL_GL_MATRIX22_ARB 0x88D6 -#define LOCAL_GL_MATRIX23_ARB 0x88D7 -#define LOCAL_GL_MATRIX24_ARB 0x88D8 -#define LOCAL_GL_MATRIX25_ARB 0x88D9 -#define LOCAL_GL_MATRIX26_ARB 0x88DA -#define LOCAL_GL_MATRIX27_ARB 0x88DB -#define LOCAL_GL_MATRIX28_ARB 0x88DC -#define LOCAL_GL_MATRIX29_ARB 0x88DD -#define LOCAL_GL_MATRIX2_ARB 0x88C2 -#define LOCAL_GL_MATRIX2_NV 0x8632 -#define LOCAL_GL_MATRIX30_ARB 0x88DE -#define LOCAL_GL_MATRIX31_ARB 0x88DF -#define LOCAL_GL_MATRIX3_ARB 0x88C3 -#define LOCAL_GL_MATRIX3_NV 0x8633 -#define LOCAL_GL_MATRIX4_ARB 0x88C4 -#define LOCAL_GL_MATRIX4_NV 0x8634 -#define LOCAL_GL_MATRIX5_ARB 0x88C5 -#define LOCAL_GL_MATRIX5_NV 0x8635 -#define LOCAL_GL_MATRIX6_ARB 0x88C6 -#define LOCAL_GL_MATRIX6_NV 0x8636 -#define LOCAL_GL_MATRIX7_ARB 0x88C7 -#define LOCAL_GL_MATRIX7_NV 0x8637 -#define LOCAL_GL_MATRIX8_ARB 0x88C8 -#define LOCAL_GL_MATRIX9_ARB 0x88C9 -#define LOCAL_GL_MATRIX_EXT 0x87C0 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES 0x8B9E -#define LOCAL_GL_MATRIX_INDEX_ARRAY_OES 0x8844 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_POINTER_OES 0x8849 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_SIZE_OES 0x8846 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_STRIDE_OES 0x8848 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define LOCAL_GL_MATRIX_INDEX_ARRAY_TYPE_OES 0x8847 -#define LOCAL_GL_MATRIX_MODE 0x0BA0 -#define LOCAL_GL_MATRIX_PALETTE_ARB 0x8840 -#define LOCAL_GL_MATRIX_PALETTE_OES 0x8840 -#define LOCAL_GL_MATRIX_STRIDE 0x92FF -#define LOCAL_GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define LOCAL_GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define LOCAL_GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define LOCAL_GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define LOCAL_GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define LOCAL_GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define LOCAL_GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define LOCAL_GL_MAX 0x8008 -#define LOCAL_GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define LOCAL_GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#define LOCAL_GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 -#define LOCAL_GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define LOCAL_GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define LOCAL_GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define LOCAL_GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define LOCAL_GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define LOCAL_GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#define LOCAL_GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#define LOCAL_GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define LOCAL_GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define LOCAL_GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define LOCAL_GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define LOCAL_GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define LOCAL_GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define LOCAL_GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define LOCAL_GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define LOCAL_GL_MAX_CLIP_DISTANCES 0x0D32 -#define LOCAL_GL_MAX_CLIP_DISTANCES_APPLE 0x0D32 -#define LOCAL_GL_MAX_CLIP_DISTANCES_EXT 0x0D32 -#define LOCAL_GL_MAX_CLIP_PLANES 0x0D32 -#define LOCAL_GL_MAX_CLIP_PLANES_IMG 0x0D32 -#define LOCAL_GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define LOCAL_GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define LOCAL_GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF -#define LOCAL_GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define LOCAL_GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define LOCAL_GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define LOCAL_GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define LOCAL_GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define LOCAL_GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA -#define LOCAL_GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA -#define LOCAL_GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define LOCAL_GL_MAX_COMBINED_DIMENSIONS 0x8282 -#define LOCAL_GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define LOCAL_GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define LOCAL_GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32 -#define LOCAL_GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32 -#define LOCAL_GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#define LOCAL_GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define LOCAL_GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define LOCAL_GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -#define LOCAL_GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#define LOCAL_GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define LOCAL_GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E -#define LOCAL_GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E -#define LOCAL_GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define LOCAL_GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F -#define LOCAL_GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F -#define LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define LOCAL_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define LOCAL_GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define LOCAL_GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define LOCAL_GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define LOCAL_GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define LOCAL_GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB -#define LOCAL_GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF -#define LOCAL_GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define LOCAL_GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#define LOCAL_GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define LOCAL_GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define LOCAL_GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define LOCAL_GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define LOCAL_GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 -#define LOCAL_GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 -#define LOCAL_GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define LOCAL_GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB -#define LOCAL_GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF -#define LOCAL_GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define LOCAL_GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define LOCAL_GL_MAX_CONVOLUTION_WIDTH 0x801A -#define LOCAL_GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#define LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#define LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES 0x851C -#define LOCAL_GL_MAX_CULL_DISTANCES 0x82F9 -#define LOCAL_GL_MAX_CULL_DISTANCES_EXT 0x82F9 -#define LOCAL_GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#define LOCAL_GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C -#define LOCAL_GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#define LOCAL_GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define LOCAL_GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define LOCAL_GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 -#define LOCAL_GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#define LOCAL_GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 -#define LOCAL_GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define LOCAL_GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 -#define LOCAL_GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 -#define LOCAL_GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 -#define LOCAL_GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#define LOCAL_GL_MAX_DEPTH 0x8280 -#define LOCAL_GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define LOCAL_GL_MAX_DRAW_BUFFERS 0x8824 -#define LOCAL_GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define LOCAL_GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define LOCAL_GL_MAX_DRAW_BUFFERS_EXT 0x8824 -#define LOCAL_GL_MAX_DRAW_BUFFERS_NV 0x8824 -#define LOCAL_GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#define LOCAL_GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC -#define LOCAL_GL_MAX_ELEMENTS_INDICES 0x80E9 -#define LOCAL_GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#define LOCAL_GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define LOCAL_GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define LOCAL_GL_MAX_ELEMENT_INDEX 0x8D6B -#define LOCAL_GL_MAX_EVAL_ORDER 0x0D30 -#define LOCAL_GL_MAX_EXT 0x8008 -#define LOCAL_GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#define LOCAL_GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define LOCAL_GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define LOCAL_GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define LOCAL_GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define LOCAL_GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define LOCAL_GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define LOCAL_GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define LOCAL_GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C -#define LOCAL_GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define LOCAL_GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define LOCAL_GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#define LOCAL_GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define LOCAL_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define LOCAL_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define LOCAL_GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define LOCAL_GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 -#define LOCAL_GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define LOCAL_GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317 -#define LOCAL_GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317 -#define LOCAL_GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 -#define LOCAL_GL_MAX_FRAMEBUFFER_WIDTH 0x9315 -#define LOCAL_GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#define LOCAL_GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define LOCAL_GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define LOCAL_GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5 -#define LOCAL_GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5 -#define LOCAL_GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define LOCAL_GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF -#define LOCAL_GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF -#define LOCAL_GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define LOCAL_GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define LOCAL_GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD -#define LOCAL_GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD -#define LOCAL_GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define LOCAL_GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123 -#define LOCAL_GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define LOCAL_GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0 -#define LOCAL_GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define LOCAL_GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define LOCAL_GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A -#define LOCAL_GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A -#define LOCAL_GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define LOCAL_GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7 -#define LOCAL_GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7 -#define LOCAL_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define LOCAL_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define LOCAL_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define LOCAL_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29 -#define LOCAL_GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define LOCAL_GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -#define LOCAL_GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -#define LOCAL_GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1 -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define LOCAL_GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF -#define LOCAL_GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define LOCAL_GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define LOCAL_GL_MAX_HEIGHT 0x827F -#define LOCAL_GL_MAX_IMAGE_SAMPLES 0x906D -#define LOCAL_GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define LOCAL_GL_MAX_IMAGE_UNITS 0x8F38 -#define LOCAL_GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define LOCAL_GL_MAX_INTEGER_SAMPLES 0x9110 -#define LOCAL_GL_MAX_LABEL_LENGTH 0x82E8 -#define LOCAL_GL_MAX_LABEL_LENGTH_KHR 0x82E8 -#define LOCAL_GL_MAX_LAYERS 0x8281 -#define LOCAL_GL_MAX_LGPU_GPUS_NVX 0x92BA -#define LOCAL_GL_MAX_LIGHTS 0x0D31 -#define LOCAL_GL_MAX_LIST_NESTING 0x0B31 -#define LOCAL_GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define LOCAL_GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define LOCAL_GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define LOCAL_GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define LOCAL_GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 -#define LOCAL_GL_MAX_NAME_LENGTH 0x92F6 -#define LOCAL_GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define LOCAL_GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#define LOCAL_GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#define LOCAL_GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define LOCAL_GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define LOCAL_GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define LOCAL_GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define LOCAL_GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define LOCAL_GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define LOCAL_GL_MAX_PALETTE_MATRICES_OES 0x8842 -#define LOCAL_GL_MAX_PATCH_VERTICES 0x8E7D -#define LOCAL_GL_MAX_PATCH_VERTICES_EXT 0x8E7D -#define LOCAL_GL_MAX_PATCH_VERTICES_OES 0x8E7D -#define LOCAL_GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define LOCAL_GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define LOCAL_GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define LOCAL_GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define LOCAL_GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define LOCAL_GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define LOCAL_GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define LOCAL_GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define LOCAL_GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define LOCAL_GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define LOCAL_GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define LOCAL_GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#define LOCAL_GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define LOCAL_GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define LOCAL_GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define LOCAL_GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#define LOCAL_GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define LOCAL_GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define LOCAL_GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define LOCAL_GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define LOCAL_GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define LOCAL_GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define LOCAL_GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define LOCAL_GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define LOCAL_GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define LOCAL_GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define LOCAL_GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define LOCAL_GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define LOCAL_GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define LOCAL_GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define LOCAL_GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define LOCAL_GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define LOCAL_GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define LOCAL_GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -#define LOCAL_GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define LOCAL_GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define LOCAL_GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define LOCAL_GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 -#define LOCAL_GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define LOCAL_GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F -#define LOCAL_GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define LOCAL_GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define LOCAL_GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define LOCAL_GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define LOCAL_GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define LOCAL_GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define LOCAL_GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define LOCAL_GL_MAX_RASTER_SAMPLES_EXT 0x9329 -#define LOCAL_GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#define LOCAL_GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define LOCAL_GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define LOCAL_GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#define LOCAL_GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define LOCAL_GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define LOCAL_GL_MAX_RENDERBUFFER_SIZE_OES 0x84E8 -#define LOCAL_GL_MAX_SAMPLES 0x8D57 -#define LOCAL_GL_MAX_SAMPLES_ANGLE 0x8D57 -#define LOCAL_GL_MAX_SAMPLES_APPLE 0x8D57 -#define LOCAL_GL_MAX_SAMPLES_EXT 0x8D57 -#define LOCAL_GL_MAX_SAMPLES_IMG 0x9135 -#define LOCAL_GL_MAX_SAMPLES_NV 0x8D57 -#define LOCAL_GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define LOCAL_GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#define LOCAL_GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define LOCAL_GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 -#define LOCAL_GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#define LOCAL_GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650 -#define LOCAL_GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651 -#define LOCAL_GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 -#define LOCAL_GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 -#define LOCAL_GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67 -#define LOCAL_GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#define LOCAL_GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#define LOCAL_GL_MAX_SHININESS_NV 0x8504 -#define LOCAL_GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 -#define LOCAL_GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 -#define LOCAL_GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199 -#define LOCAL_GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A -#define LOCAL_GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A -#define LOCAL_GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A -#define LOCAL_GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 -#define LOCAL_GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 -#define LOCAL_GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198 -#define LOCAL_GL_MAX_SPOT_EXPONENT_NV 0x8505 -#define LOCAL_GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 -#define LOCAL_GL_MAX_SUBROUTINES 0x8DE7 -#define LOCAL_GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define LOCAL_GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define LOCAL_GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3 -#define LOCAL_GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3 -#define LOCAL_GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define LOCAL_GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD -#define LOCAL_GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD -#define LOCAL_GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define LOCAL_GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB -#define LOCAL_GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB -#define LOCAL_GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define LOCAL_GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C -#define LOCAL_GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C -#define LOCAL_GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define LOCAL_GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83 -#define LOCAL_GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83 -#define LOCAL_GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define LOCAL_GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8 -#define LOCAL_GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8 -#define LOCAL_GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define LOCAL_GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81 -#define LOCAL_GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81 -#define LOCAL_GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define LOCAL_GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85 -#define LOCAL_GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85 -#define LOCAL_GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define LOCAL_GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89 -#define LOCAL_GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89 -#define LOCAL_GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define LOCAL_GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F -#define LOCAL_GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F -#define LOCAL_GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define LOCAL_GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4 -#define LOCAL_GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4 -#define LOCAL_GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define LOCAL_GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE -#define LOCAL_GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE -#define LOCAL_GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define LOCAL_GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC -#define LOCAL_GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC -#define LOCAL_GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define LOCAL_GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D -#define LOCAL_GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D -#define LOCAL_GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define LOCAL_GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86 -#define LOCAL_GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86 -#define LOCAL_GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define LOCAL_GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9 -#define LOCAL_GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9 -#define LOCAL_GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define LOCAL_GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82 -#define LOCAL_GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82 -#define LOCAL_GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define LOCAL_GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A -#define LOCAL_GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A -#define LOCAL_GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define LOCAL_GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80 -#define LOCAL_GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80 -#define LOCAL_GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define LOCAL_GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E -#define LOCAL_GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E -#define LOCAL_GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define LOCAL_GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84 -#define LOCAL_GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84 -#define LOCAL_GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define LOCAL_GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define LOCAL_GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define LOCAL_GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B -#define LOCAL_GL_MAX_TEXTURE_COORDS 0x8871 -#define LOCAL_GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define LOCAL_GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#define LOCAL_GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define LOCAL_GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define LOCAL_GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define LOCAL_GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#define LOCAL_GL_MAX_TEXTURE_SIZE 0x0D33 -#define LOCAL_GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define LOCAL_GL_MAX_TEXTURE_UNITS 0x84E2 -#define LOCAL_GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#define LOCAL_GL_MAX_TRACK_MATRICES_NV 0x862F -#define LOCAL_GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define LOCAL_GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define LOCAL_GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define LOCAL_GL_MAX_UNIFORM_LOCATIONS 0x826E -#define LOCAL_GL_MAX_VARYING_COMPONENTS 0x8B4B -#define LOCAL_GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define LOCAL_GL_MAX_VARYING_FLOATS 0x8B4B -#define LOCAL_GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define LOCAL_GL_MAX_VARYING_VECTORS 0x8DFC -#define LOCAL_GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define LOCAL_GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define LOCAL_GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define LOCAL_GL_MAX_VERTEX_ATTRIBS 0x8869 -#define LOCAL_GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define LOCAL_GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define LOCAL_GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define LOCAL_GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -#define LOCAL_GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define LOCAL_GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define LOCAL_GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define LOCAL_GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define LOCAL_GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define LOCAL_GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define LOCAL_GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define LOCAL_GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define LOCAL_GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#define LOCAL_GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define LOCAL_GL_MAX_VERTEX_STREAMS 0x8E71 -#define LOCAL_GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define LOCAL_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define LOCAL_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define LOCAL_GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define LOCAL_GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define LOCAL_GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define LOCAL_GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define LOCAL_GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define LOCAL_GL_MAX_VERTEX_UNITS_OES 0x86A4 -#define LOCAL_GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define LOCAL_GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define LOCAL_GL_MAX_VIEWPORTS 0x825B -#define LOCAL_GL_MAX_VIEWPORTS_NV 0x825B -#define LOCAL_GL_MAX_VIEWPORTS_OES 0x825B -#define LOCAL_GL_MAX_VIEWPORT_DIMS 0x0D3A -#define LOCAL_GL_MAX_VIEWS_OVR 0x9631 -#define LOCAL_GL_MAX_WIDTH 0x827E -#define LOCAL_GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 -#define LOCAL_GL_MEDIUM_FLOAT 0x8DF1 -#define LOCAL_GL_MEDIUM_INT 0x8DF4 -#define LOCAL_GL_MIN 0x8007 -#define LOCAL_GL_MINMAX 0x802E -#define LOCAL_GL_MINMAX_EXT 0x802E -#define LOCAL_GL_MINMAX_FORMAT 0x802F -#define LOCAL_GL_MINMAX_FORMAT_EXT 0x802F -#define LOCAL_GL_MINMAX_SINK 0x8030 -#define LOCAL_GL_MINMAX_SINK_EXT 0x8030 -#define LOCAL_GL_MINOR_VERSION 0x821C -#define LOCAL_GL_MINUS_CLAMPED_NV 0x92B3 -#define LOCAL_GL_MINUS_NV 0x929F -#define LOCAL_GL_MIN_EXT 0x8007 -#define LOCAL_GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define LOCAL_GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define LOCAL_GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B -#define LOCAL_GL_MIN_LOD_WARNING_AMD 0x919C -#define LOCAL_GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#define LOCAL_GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define LOCAL_GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 -#define LOCAL_GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define LOCAL_GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define LOCAL_GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define LOCAL_GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define LOCAL_GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define LOCAL_GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#define LOCAL_GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37 -#define LOCAL_GL_MIN_SPARSE_LEVEL_AMD 0x919B -#define LOCAL_GL_MIPMAP 0x8293 -#define LOCAL_GL_MIRRORED_REPEAT 0x8370 -#define LOCAL_GL_MIRRORED_REPEAT_ARB 0x8370 -#define LOCAL_GL_MIRRORED_REPEAT_IBM 0x8370 -#define LOCAL_GL_MIRRORED_REPEAT_OES 0x8370 -#define LOCAL_GL_MIRROR_CLAMP_ATI 0x8742 -#define LOCAL_GL_MIRROR_CLAMP_EXT 0x8742 -#define LOCAL_GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#define LOCAL_GL_MIRROR_CLAMP_TO_EDGE 0x8743 -#define LOCAL_GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#define LOCAL_GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define LOCAL_GL_MITER_REVERT_NV 0x90A7 -#define LOCAL_GL_MITER_TRUNCATE_NV 0x90A8 -#define LOCAL_GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F -#define LOCAL_GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 -#define LOCAL_GL_MODELVIEW 0x1700 -#define LOCAL_GL_MODELVIEW0_ARB 0x1700 -#define LOCAL_GL_MODELVIEW0_EXT 0x1700 -#define LOCAL_GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define LOCAL_GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define LOCAL_GL_MODELVIEW10_ARB 0x872A -#define LOCAL_GL_MODELVIEW11_ARB 0x872B -#define LOCAL_GL_MODELVIEW12_ARB 0x872C -#define LOCAL_GL_MODELVIEW13_ARB 0x872D -#define LOCAL_GL_MODELVIEW14_ARB 0x872E -#define LOCAL_GL_MODELVIEW15_ARB 0x872F -#define LOCAL_GL_MODELVIEW16_ARB 0x8730 -#define LOCAL_GL_MODELVIEW17_ARB 0x8731 -#define LOCAL_GL_MODELVIEW18_ARB 0x8732 -#define LOCAL_GL_MODELVIEW19_ARB 0x8733 -#define LOCAL_GL_MODELVIEW1_ARB 0x850A -#define LOCAL_GL_MODELVIEW1_EXT 0x850A -#define LOCAL_GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define LOCAL_GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define LOCAL_GL_MODELVIEW20_ARB 0x8734 -#define LOCAL_GL_MODELVIEW21_ARB 0x8735 -#define LOCAL_GL_MODELVIEW22_ARB 0x8736 -#define LOCAL_GL_MODELVIEW23_ARB 0x8737 -#define LOCAL_GL_MODELVIEW24_ARB 0x8738 -#define LOCAL_GL_MODELVIEW25_ARB 0x8739 -#define LOCAL_GL_MODELVIEW26_ARB 0x873A -#define LOCAL_GL_MODELVIEW27_ARB 0x873B -#define LOCAL_GL_MODELVIEW28_ARB 0x873C -#define LOCAL_GL_MODELVIEW29_ARB 0x873D -#define LOCAL_GL_MODELVIEW2_ARB 0x8722 -#define LOCAL_GL_MODELVIEW30_ARB 0x873E -#define LOCAL_GL_MODELVIEW31_ARB 0x873F -#define LOCAL_GL_MODELVIEW3_ARB 0x8723 -#define LOCAL_GL_MODELVIEW4_ARB 0x8724 -#define LOCAL_GL_MODELVIEW5_ARB 0x8725 -#define LOCAL_GL_MODELVIEW6_ARB 0x8726 -#define LOCAL_GL_MODELVIEW7_ARB 0x8727 -#define LOCAL_GL_MODELVIEW8_ARB 0x8728 -#define LOCAL_GL_MODELVIEW9_ARB 0x8729 -#define LOCAL_GL_MODELVIEW_MATRIX 0x0BA6 -#define LOCAL_GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D -#define LOCAL_GL_MODELVIEW_PROJECTION_NV 0x8629 -#define LOCAL_GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define LOCAL_GL_MODULATE 0x2100 -#define LOCAL_GL_MODULATE_ADD_ATI 0x8744 -#define LOCAL_GL_MODULATE_COLOR_IMG 0x8C04 -#define LOCAL_GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define LOCAL_GL_MODULATE_SUBTRACT_ATI 0x8746 -#define LOCAL_GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define LOCAL_GL_MOVE_TO_NV 0x02 -#define LOCAL_GL_MOVE_TO_RESETS_NV 0x90B5 -#define LOCAL_GL_MOV_ATI 0x8961 -#define LOCAL_GL_MULT 0x0103 -#define LOCAL_GL_MULTICAST_GPUS_NV 0x92BA -#define LOCAL_GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 -#define LOCAL_GL_MULTIPLY 0x9294 -#define LOCAL_GL_MULTIPLY_KHR 0x9294 -#define LOCAL_GL_MULTIPLY_NV 0x9294 -#define LOCAL_GL_MULTISAMPLE 0x809D -#define LOCAL_GL_MULTISAMPLES_NV 0x9371 -#define LOCAL_GL_MULTISAMPLE_3DFX 0x86B2 -#define LOCAL_GL_MULTISAMPLE_ARB 0x809D -#define LOCAL_GL_MULTISAMPLE_BIT 0x20000000 -#define LOCAL_GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#define LOCAL_GL_MULTISAMPLE_BIT_ARB 0x20000000 -#define LOCAL_GL_MULTISAMPLE_BIT_EXT 0x20000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define LOCAL_GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -#define LOCAL_GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#define LOCAL_GL_MULTISAMPLE_EXT 0x809D -#define LOCAL_GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#define LOCAL_GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY 0x9382 -#define LOCAL_GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 -#define LOCAL_GL_MULTISAMPLE_LINE_WIDTH_RANGE 0x9381 -#define LOCAL_GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 -#define LOCAL_GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B -#define LOCAL_GL_MULTISAMPLE_SGIS 0x809D -#define LOCAL_GL_MULTIVIEW_EXT 0x90F1 -#define LOCAL_GL_MUL_ATI 0x8964 -#define LOCAL_GL_MVP_MATRIX_EXT 0x87E3 -#define LOCAL_GL_N3F_V3F 0x2A25 -#define LOCAL_GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define LOCAL_GL_NAMED_STRING_TYPE_ARB 0x8DEA -#define LOCAL_GL_NAME_LENGTH 0x92F9 -#define LOCAL_GL_NAME_STACK_DEPTH 0x0D70 -#define LOCAL_GL_NAND 0x150E -#define LOCAL_GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define LOCAL_GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define LOCAL_GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define LOCAL_GL_NEAREST 0x2600 -#define LOCAL_GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define LOCAL_GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define LOCAL_GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define LOCAL_GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define LOCAL_GL_NEGATE_BIT_ATI 0x00000004 -#define LOCAL_GL_NEGATIVE_ONE_EXT 0x87DF -#define LOCAL_GL_NEGATIVE_ONE_TO_ONE 0x935E -#define LOCAL_GL_NEGATIVE_W_EXT 0x87DC -#define LOCAL_GL_NEGATIVE_X_EXT 0x87D9 -#define LOCAL_GL_NEGATIVE_Y_EXT 0x87DA -#define LOCAL_GL_NEGATIVE_Z_EXT 0x87DB -#define LOCAL_GL_NEVER 0x0200 -#define LOCAL_GL_NEXT_BUFFER_NV -2 -#define LOCAL_GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define LOCAL_GL_NICEST 0x1102 -#define LOCAL_GL_NONE 0 -#define LOCAL_GL_NONE_OES 0 -#define LOCAL_GL_NOOP 0x1505 -#define LOCAL_GL_NOP_COMMAND_NV 0x0001 -#define LOCAL_GL_NOR 0x1508 -#define LOCAL_GL_NORMALIZE 0x0BA1 -#define LOCAL_GL_NORMALIZED_RANGE_EXT 0x87E0 -#define LOCAL_GL_NORMAL_ARRAY 0x8075 -#define LOCAL_GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define LOCAL_GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define LOCAL_GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define LOCAL_GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define LOCAL_GL_NORMAL_ARRAY_EXT 0x8075 -#define LOCAL_GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define LOCAL_GL_NORMAL_ARRAY_LIST_IBM 103071 -#define LOCAL_GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define LOCAL_GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define LOCAL_GL_NORMAL_ARRAY_POINTER 0x808F -#define LOCAL_GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define LOCAL_GL_NORMAL_ARRAY_STRIDE 0x807F -#define LOCAL_GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define LOCAL_GL_NORMAL_ARRAY_TYPE 0x807E -#define LOCAL_GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define LOCAL_GL_NORMAL_BIT_PGI 0x08000000 -#define LOCAL_GL_NORMAL_MAP 0x8511 -#define LOCAL_GL_NORMAL_MAP_ARB 0x8511 -#define LOCAL_GL_NORMAL_MAP_EXT 0x8511 -#define LOCAL_GL_NORMAL_MAP_NV 0x8511 -#define LOCAL_GL_NORMAL_MAP_OES 0x8511 -#define LOCAL_GL_NOTEQUAL 0x0205 -#define LOCAL_GL_NO_ERROR 0 -#define LOCAL_GL_NO_RESET_NOTIFICATION 0x8261 -#define LOCAL_GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#define LOCAL_GL_NO_RESET_NOTIFICATION_EXT 0x8261 -#define LOCAL_GL_NO_RESET_NOTIFICATION_KHR 0x8261 -#define LOCAL_GL_NUM_ACTIVE_VARIABLES 0x9304 -#define LOCAL_GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define LOCAL_GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define LOCAL_GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define LOCAL_GL_NUM_DEVICE_UUIDS_EXT 0x9596 -#define LOCAL_GL_NUM_DOWNSAMPLE_SCALES_IMG 0x913D -#define LOCAL_GL_NUM_EXTENSIONS 0x821D -#define LOCAL_GL_NUM_FILL_STREAMS_NV 0x8E29 -#define LOCAL_GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define LOCAL_GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define LOCAL_GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define LOCAL_GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define LOCAL_GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define LOCAL_GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define LOCAL_GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define LOCAL_GL_NUM_PASSES_ATI 0x8970 -#define LOCAL_GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define LOCAL_GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define LOCAL_GL_NUM_SAMPLE_COUNTS 0x9380 -#define LOCAL_GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define LOCAL_GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 -#define LOCAL_GL_NUM_SPARSE_LEVELS_ARB 0x91AA -#define LOCAL_GL_NUM_SPARSE_LEVELS_EXT 0x91AA -#define LOCAL_GL_NUM_TILING_TYPES_EXT 0x9582 -#define LOCAL_GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define LOCAL_GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 -#define LOCAL_GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8 -#define LOCAL_GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 -#define LOCAL_GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define LOCAL_GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#define LOCAL_GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define LOCAL_GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define LOCAL_GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define LOCAL_GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define LOCAL_GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define LOCAL_GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define LOCAL_GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define LOCAL_GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define LOCAL_GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define LOCAL_GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define LOCAL_GL_OBJECT_LINEAR 0x2401 -#define LOCAL_GL_OBJECT_LINEAR_NV 0x2401 -#define LOCAL_GL_OBJECT_LINE_SGIS 0x81F7 -#define LOCAL_GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define LOCAL_GL_OBJECT_PLANE 0x2501 -#define LOCAL_GL_OBJECT_POINT_SGIS 0x81F5 -#define LOCAL_GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#define LOCAL_GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define LOCAL_GL_OBJECT_TYPE 0x9112 -#define LOCAL_GL_OBJECT_TYPE_APPLE 0x9112 -#define LOCAL_GL_OBJECT_TYPE_ARB 0x8B4E -#define LOCAL_GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define LOCAL_GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F -#define LOCAL_GL_OCCLUSION_TEST_HP 0x8165 -#define LOCAL_GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#define LOCAL_GL_OFFSET 0x92FC -#define LOCAL_GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define LOCAL_GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define LOCAL_GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define LOCAL_GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define LOCAL_GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define LOCAL_GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define LOCAL_GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define LOCAL_GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define LOCAL_GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define LOCAL_GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define LOCAL_GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define LOCAL_GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define LOCAL_GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define LOCAL_GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define LOCAL_GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define LOCAL_GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define LOCAL_GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define LOCAL_GL_ONE 1 -#define LOCAL_GL_ONE_EXT 0x87DE -#define LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define LOCAL_GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define LOCAL_GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define LOCAL_GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define LOCAL_GL_ONE_MINUS_DST_ALPHA 0x0305 -#define LOCAL_GL_ONE_MINUS_DST_COLOR 0x0307 -#define LOCAL_GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define LOCAL_GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB -#define LOCAL_GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define LOCAL_GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA -#define LOCAL_GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define LOCAL_GL_ONE_MINUS_SRC_COLOR 0x0301 -#define LOCAL_GL_OPERAND0_ALPHA 0x8598 -#define LOCAL_GL_OPERAND0_ALPHA_ARB 0x8598 -#define LOCAL_GL_OPERAND0_ALPHA_EXT 0x8598 -#define LOCAL_GL_OPERAND0_RGB 0x8590 -#define LOCAL_GL_OPERAND0_RGB_ARB 0x8590 -#define LOCAL_GL_OPERAND0_RGB_EXT 0x8590 -#define LOCAL_GL_OPERAND1_ALPHA 0x8599 -#define LOCAL_GL_OPERAND1_ALPHA_ARB 0x8599 -#define LOCAL_GL_OPERAND1_ALPHA_EXT 0x8599 -#define LOCAL_GL_OPERAND1_RGB 0x8591 -#define LOCAL_GL_OPERAND1_RGB_ARB 0x8591 -#define LOCAL_GL_OPERAND1_RGB_EXT 0x8591 -#define LOCAL_GL_OPERAND2_ALPHA 0x859A -#define LOCAL_GL_OPERAND2_ALPHA_ARB 0x859A -#define LOCAL_GL_OPERAND2_ALPHA_EXT 0x859A -#define LOCAL_GL_OPERAND2_RGB 0x8592 -#define LOCAL_GL_OPERAND2_RGB_ARB 0x8592 -#define LOCAL_GL_OPERAND2_RGB_EXT 0x8592 -#define LOCAL_GL_OPERAND3_ALPHA_NV 0x859B -#define LOCAL_GL_OPERAND3_RGB_NV 0x8593 -#define LOCAL_GL_OPTIMAL_TILING_EXT 0x9584 -#define LOCAL_GL_OP_ADD_EXT 0x8787 -#define LOCAL_GL_OP_CLAMP_EXT 0x878E -#define LOCAL_GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define LOCAL_GL_OP_DOT3_EXT 0x8784 -#define LOCAL_GL_OP_DOT4_EXT 0x8785 -#define LOCAL_GL_OP_EXP_BASE_2_EXT 0x8791 -#define LOCAL_GL_OP_FLOOR_EXT 0x878F -#define LOCAL_GL_OP_FRAC_EXT 0x8789 -#define LOCAL_GL_OP_INDEX_EXT 0x8782 -#define LOCAL_GL_OP_LOG_BASE_2_EXT 0x8792 -#define LOCAL_GL_OP_MADD_EXT 0x8788 -#define LOCAL_GL_OP_MAX_EXT 0x878A -#define LOCAL_GL_OP_MIN_EXT 0x878B -#define LOCAL_GL_OP_MOV_EXT 0x8799 -#define LOCAL_GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define LOCAL_GL_OP_MUL_EXT 0x8786 -#define LOCAL_GL_OP_NEGATE_EXT 0x8783 -#define LOCAL_GL_OP_POWER_EXT 0x8793 -#define LOCAL_GL_OP_RECIP_EXT 0x8794 -#define LOCAL_GL_OP_RECIP_SQRT_EXT 0x8795 -#define LOCAL_GL_OP_ROUND_EXT 0x8790 -#define LOCAL_GL_OP_SET_GE_EXT 0x878C -#define LOCAL_GL_OP_SET_LT_EXT 0x878D -#define LOCAL_GL_OP_SUB_EXT 0x8796 -#define LOCAL_GL_OR 0x1507 -#define LOCAL_GL_ORDER 0x0A01 -#define LOCAL_GL_OR_INVERTED 0x150D -#define LOCAL_GL_OR_REVERSE 0x150B -#define LOCAL_GL_OUTPUT_COLOR0_EXT 0x879B -#define LOCAL_GL_OUTPUT_COLOR1_EXT 0x879C -#define LOCAL_GL_OUTPUT_FOG_EXT 0x87BD -#define LOCAL_GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define LOCAL_GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define LOCAL_GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define LOCAL_GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define LOCAL_GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define LOCAL_GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define LOCAL_GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define LOCAL_GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define LOCAL_GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define LOCAL_GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define LOCAL_GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define LOCAL_GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define LOCAL_GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define LOCAL_GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define LOCAL_GL_OUTPUT_VERTEX_EXT 0x879A -#define LOCAL_GL_OUT_OF_MEMORY 0x0505 -#define LOCAL_GL_OVERLAY 0x9296 -#define LOCAL_GL_OVERLAY_KHR 0x9296 -#define LOCAL_GL_OVERLAY_NV 0x9296 -#define LOCAL_GL_PACK_ALIGNMENT 0x0D05 -#define LOCAL_GL_PACK_CMYK_HINT_EXT 0x800E -#define LOCAL_GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define LOCAL_GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define LOCAL_GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#define LOCAL_GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define LOCAL_GL_PACK_COMPRESSED_SIZE_SGIX 0x831C -#define LOCAL_GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define LOCAL_GL_PACK_IMAGE_HEIGHT 0x806C -#define LOCAL_GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define LOCAL_GL_PACK_INVERT_MESA 0x8758 -#define LOCAL_GL_PACK_LSB_FIRST 0x0D01 -#define LOCAL_GL_PACK_MAX_COMPRESSED_SIZE_SGIX 0x831B -#define LOCAL_GL_PACK_RESAMPLE_OML 0x8984 -#define LOCAL_GL_PACK_RESAMPLE_SGIX 0x842E -#define LOCAL_GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 -#define LOCAL_GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define LOCAL_GL_PACK_ROW_LENGTH 0x0D02 -#define LOCAL_GL_PACK_SKIP_IMAGES 0x806B -#define LOCAL_GL_PACK_SKIP_IMAGES_EXT 0x806B -#define LOCAL_GL_PACK_SKIP_PIXELS 0x0D04 -#define LOCAL_GL_PACK_SKIP_ROWS 0x0D03 -#define LOCAL_GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define LOCAL_GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define LOCAL_GL_PACK_SWAP_BYTES 0x0D00 -#define LOCAL_GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define LOCAL_GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define LOCAL_GL_PALETTE4_RGB8_OES 0x8B90 -#define LOCAL_GL_PALETTE4_RGBA4_OES 0x8B93 -#define LOCAL_GL_PALETTE4_RGBA8_OES 0x8B91 -#define LOCAL_GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define LOCAL_GL_PALETTE8_RGB5_A1_OES 0x8B99 -#define LOCAL_GL_PALETTE8_RGB8_OES 0x8B95 -#define LOCAL_GL_PALETTE8_RGBA4_OES 0x8B98 -#define LOCAL_GL_PALETTE8_RGBA8_OES 0x8B96 -#define LOCAL_GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define LOCAL_GL_PARAMETER_BUFFER_ARB 0x80EE -#define LOCAL_GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -#define LOCAL_GL_PARTIAL_SUCCESS_NV 0x902E -#define LOCAL_GL_PASS_THROUGH_NV 0x86E6 -#define LOCAL_GL_PASS_THROUGH_TOKEN 0x0700 -#define LOCAL_GL_PATCHES 0x000E -#define LOCAL_GL_PATCHES_EXT 0x000E -#define LOCAL_GL_PATCHES_OES 0x000E -#define LOCAL_GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define LOCAL_GL_PATCH_DEFAULT_INNER_LEVEL_EXT 0x8E73 -#define LOCAL_GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define LOCAL_GL_PATCH_DEFAULT_OUTER_LEVEL_EXT 0x8E74 -#define LOCAL_GL_PATCH_VERTICES 0x8E72 -#define LOCAL_GL_PATCH_VERTICES_EXT 0x8E72 -#define LOCAL_GL_PATCH_VERTICES_OES 0x8E72 -#define LOCAL_GL_PATH_CLIENT_LENGTH_NV 0x907F -#define LOCAL_GL_PATH_COMMAND_COUNT_NV 0x909D -#define LOCAL_GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define LOCAL_GL_PATH_COORD_COUNT_NV 0x909E -#define LOCAL_GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define LOCAL_GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define LOCAL_GL_PATH_DASH_CAPS_NV 0x907B -#define LOCAL_GL_PATH_DASH_OFFSET_NV 0x907E -#define LOCAL_GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define LOCAL_GL_PATH_END_CAPS_NV 0x9076 -#define LOCAL_GL_PATH_ERROR_POSITION_NV 0x90AB -#define LOCAL_GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define LOCAL_GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define LOCAL_GL_PATH_FILL_MASK_NV 0x9081 -#define LOCAL_GL_PATH_FILL_MODE_NV 0x9080 -#define LOCAL_GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define LOCAL_GL_PATH_FORMAT_PS_NV 0x9071 -#define LOCAL_GL_PATH_FORMAT_SVG_NV 0x9070 -#define LOCAL_GL_PATH_GEN_COEFF_NV 0x90B1 -#define LOCAL_GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define LOCAL_GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define LOCAL_GL_PATH_GEN_MODE_NV 0x90B0 -#define LOCAL_GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define LOCAL_GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define LOCAL_GL_PATH_JOIN_STYLE_NV 0x9079 -#define LOCAL_GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 -#define LOCAL_GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 -#define LOCAL_GL_PATH_MITER_LIMIT_NV 0x907A -#define LOCAL_GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 -#define LOCAL_GL_PATH_MODELVIEW_NV 0x1700 -#define LOCAL_GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 -#define LOCAL_GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define LOCAL_GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 -#define LOCAL_GL_PATH_PROJECTION_NV 0x1701 -#define LOCAL_GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 -#define LOCAL_GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define LOCAL_GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define LOCAL_GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define LOCAL_GL_PATH_STENCIL_REF_NV 0x90B8 -#define LOCAL_GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define LOCAL_GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define LOCAL_GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define LOCAL_GL_PATH_STROKE_MASK_NV 0x9084 -#define LOCAL_GL_PATH_STROKE_WIDTH_NV 0x9075 -#define LOCAL_GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define LOCAL_GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define LOCAL_GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 -#define LOCAL_GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 -#define LOCAL_GL_PERCENTAGE_AMD 0x8BC3 -#define LOCAL_GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#define LOCAL_GL_PERFMON_RESULT_AMD 0x8BC6 -#define LOCAL_GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define LOCAL_GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define LOCAL_GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define LOCAL_GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC -#define LOCAL_GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB -#define LOCAL_GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA -#define LOCAL_GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 -#define LOCAL_GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 -#define LOCAL_GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF -#define LOCAL_GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 -#define LOCAL_GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 -#define LOCAL_GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 -#define LOCAL_GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE -#define LOCAL_GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 -#define LOCAL_GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 -#define LOCAL_GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 -#define LOCAL_GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 -#define LOCAL_GL_PERFQUERY_FLUSH_INTEL 0x83FA -#define LOCAL_GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 -#define LOCAL_GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 -#define LOCAL_GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD -#define LOCAL_GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 -#define LOCAL_GL_PERFQUERY_WAIT_INTEL 0x83FB -#define LOCAL_GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define LOCAL_GL_PERTURB_EXT 0x85AE -#define LOCAL_GL_PER_GPU_STORAGE_BIT_NV 0x0800 -#define LOCAL_GL_PER_GPU_STORAGE_NV 0x9548 -#define LOCAL_GL_PER_STAGE_CONSTANTS_NV 0x8535 -#define LOCAL_GL_PHONG_HINT_WIN 0x80EB -#define LOCAL_GL_PHONG_WIN 0x80EA -#define LOCAL_GL_PINLIGHT_NV 0x92A8 -#define LOCAL_GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE -#define LOCAL_GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF -#define LOCAL_GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define LOCAL_GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define LOCAL_GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define LOCAL_GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#define LOCAL_GL_PIXEL_COUNT_NV 0x8866 -#define LOCAL_GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define LOCAL_GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define LOCAL_GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define LOCAL_GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#define LOCAL_GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define LOCAL_GL_PIXEL_MAP_A_TO_A 0x0C79 -#define LOCAL_GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define LOCAL_GL_PIXEL_MAP_B_TO_B 0x0C78 -#define LOCAL_GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define LOCAL_GL_PIXEL_MAP_G_TO_G 0x0C77 -#define LOCAL_GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define LOCAL_GL_PIXEL_MAP_I_TO_A 0x0C75 -#define LOCAL_GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define LOCAL_GL_PIXEL_MAP_I_TO_B 0x0C74 -#define LOCAL_GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define LOCAL_GL_PIXEL_MAP_I_TO_G 0x0C73 -#define LOCAL_GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define LOCAL_GL_PIXEL_MAP_I_TO_I 0x0C70 -#define LOCAL_GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define LOCAL_GL_PIXEL_MAP_I_TO_R 0x0C72 -#define LOCAL_GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define LOCAL_GL_PIXEL_MAP_R_TO_R 0x0C76 -#define LOCAL_GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define LOCAL_GL_PIXEL_MAP_S_TO_S 0x0C71 -#define LOCAL_GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define LOCAL_GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define LOCAL_GL_PIXEL_MODE_BIT 0x00000020 -#define LOCAL_GL_PIXEL_PACK_BUFFER 0x88EB -#define LOCAL_GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define LOCAL_GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define LOCAL_GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define LOCAL_GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define LOCAL_GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define LOCAL_GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define LOCAL_GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#define LOCAL_GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define LOCAL_GL_PIXEL_TEXTURE_SGIS 0x8353 -#define LOCAL_GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define LOCAL_GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#define LOCAL_GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define LOCAL_GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define LOCAL_GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#define LOCAL_GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define LOCAL_GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define LOCAL_GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define LOCAL_GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define LOCAL_GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define LOCAL_GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define LOCAL_GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#define LOCAL_GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define LOCAL_GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define LOCAL_GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define LOCAL_GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define LOCAL_GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define LOCAL_GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define LOCAL_GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#define LOCAL_GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define LOCAL_GL_PIXEL_UNPACK_BUFFER 0x88EC -#define LOCAL_GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define LOCAL_GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define LOCAL_GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#define LOCAL_GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#define LOCAL_GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define LOCAL_GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 -#define LOCAL_GL_PLUS_CLAMPED_NV 0x92B1 -#define LOCAL_GL_PLUS_DARKER_NV 0x9292 -#define LOCAL_GL_PLUS_NV 0x9291 -#define LOCAL_GL_PN_TRIANGLES_ATI 0x87F0 -#define LOCAL_GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define LOCAL_GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define LOCAL_GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#define LOCAL_GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define LOCAL_GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define LOCAL_GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define LOCAL_GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define LOCAL_GL_POINT 0x1B00 -#define LOCAL_GL_POINTS 0x0000 -#define LOCAL_GL_POINT_BIT 0x00000002 -#define LOCAL_GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define LOCAL_GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#define LOCAL_GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define LOCAL_GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define LOCAL_GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define LOCAL_GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define LOCAL_GL_POINT_NV 0x1B00 -#define LOCAL_GL_POINT_SIZE 0x0B11 -#define LOCAL_GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#define LOCAL_GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define LOCAL_GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define LOCAL_GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define LOCAL_GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define LOCAL_GL_POINT_SIZE_GRANULARITY 0x0B13 -#define LOCAL_GL_POINT_SIZE_MAX 0x8127 -#define LOCAL_GL_POINT_SIZE_MAX_ARB 0x8127 -#define LOCAL_GL_POINT_SIZE_MAX_EXT 0x8127 -#define LOCAL_GL_POINT_SIZE_MAX_SGIS 0x8127 -#define LOCAL_GL_POINT_SIZE_MIN 0x8126 -#define LOCAL_GL_POINT_SIZE_MIN_ARB 0x8126 -#define LOCAL_GL_POINT_SIZE_MIN_EXT 0x8126 -#define LOCAL_GL_POINT_SIZE_MIN_SGIS 0x8126 -#define LOCAL_GL_POINT_SIZE_RANGE 0x0B12 -#define LOCAL_GL_POINT_SMOOTH 0x0B10 -#define LOCAL_GL_POINT_SMOOTH_HINT 0x0C51 -#define LOCAL_GL_POINT_SPRITE 0x8861 -#define LOCAL_GL_POINT_SPRITE_ARB 0x8861 -#define LOCAL_GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define LOCAL_GL_POINT_SPRITE_NV 0x8861 -#define LOCAL_GL_POINT_SPRITE_OES 0x8861 -#define LOCAL_GL_POINT_SPRITE_R_MODE_NV 0x8863 -#define LOCAL_GL_POINT_TOKEN 0x0701 -#define LOCAL_GL_POLYGON 0x0009 -#define LOCAL_GL_POLYGON_BIT 0x00000008 -#define LOCAL_GL_POLYGON_MODE 0x0B40 -#define LOCAL_GL_POLYGON_MODE_NV 0x0B40 -#define LOCAL_GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#define LOCAL_GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B -#define LOCAL_GL_POLYGON_OFFSET_COMMAND_NV 0x000E -#define LOCAL_GL_POLYGON_OFFSET_EXT 0x8037 -#define LOCAL_GL_POLYGON_OFFSET_FACTOR 0x8038 -#define LOCAL_GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define LOCAL_GL_POLYGON_OFFSET_FILL 0x8037 -#define LOCAL_GL_POLYGON_OFFSET_LINE 0x2A02 -#define LOCAL_GL_POLYGON_OFFSET_LINE_NV 0x2A02 -#define LOCAL_GL_POLYGON_OFFSET_POINT 0x2A01 -#define LOCAL_GL_POLYGON_OFFSET_POINT_NV 0x2A01 -#define LOCAL_GL_POLYGON_OFFSET_UNITS 0x2A00 -#define LOCAL_GL_POLYGON_SMOOTH 0x0B41 -#define LOCAL_GL_POLYGON_SMOOTH_HINT 0x0C53 -#define LOCAL_GL_POLYGON_STIPPLE 0x0B42 -#define LOCAL_GL_POLYGON_STIPPLE_BIT 0x00000010 -#define LOCAL_GL_POLYGON_TOKEN 0x0703 -#define LOCAL_GL_POSITION 0x1203 -#define LOCAL_GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define LOCAL_GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#define LOCAL_GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define LOCAL_GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define LOCAL_GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define LOCAL_GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define LOCAL_GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define LOCAL_GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define LOCAL_GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define LOCAL_GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define LOCAL_GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define LOCAL_GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define LOCAL_GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define LOCAL_GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define LOCAL_GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define LOCAL_GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define LOCAL_GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define LOCAL_GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define LOCAL_GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define LOCAL_GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#define LOCAL_GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define LOCAL_GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define LOCAL_GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define LOCAL_GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define LOCAL_GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define LOCAL_GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define LOCAL_GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define LOCAL_GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define LOCAL_GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define LOCAL_GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define LOCAL_GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define LOCAL_GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define LOCAL_GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define LOCAL_GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define LOCAL_GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define LOCAL_GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define LOCAL_GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define LOCAL_GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define LOCAL_GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define LOCAL_GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#define LOCAL_GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define LOCAL_GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define LOCAL_GL_PRESENT_DURATION_NV 0x8E2B -#define LOCAL_GL_PRESENT_TIME_NV 0x8E2A -#define LOCAL_GL_PRESERVE_ATI 0x8762 -#define LOCAL_GL_PREVIOUS 0x8578 -#define LOCAL_GL_PREVIOUS_ARB 0x8578 -#define LOCAL_GL_PREVIOUS_EXT 0x8578 -#define LOCAL_GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define LOCAL_GL_PRIMARY_COLOR 0x8577 -#define LOCAL_GL_PRIMARY_COLOR_ARB 0x8577 -#define LOCAL_GL_PRIMARY_COLOR_EXT 0x8577 -#define LOCAL_GL_PRIMARY_COLOR_NV 0x852C -#define LOCAL_GL_PRIMITIVES_GENERATED 0x8C87 -#define LOCAL_GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define LOCAL_GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define LOCAL_GL_PRIMITIVES_GENERATED_OES 0x8C87 -#define LOCAL_GL_PRIMITIVES_SUBMITTED_ARB 0x82EF -#define LOCAL_GL_PRIMITIVE_BOUNDING_BOX 0x92BE -#define LOCAL_GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE -#define LOCAL_GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE -#define LOCAL_GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE -#define LOCAL_GL_PRIMITIVE_ID_NV 0x8C7C -#define LOCAL_GL_PRIMITIVE_RESTART 0x8F9D -#define LOCAL_GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define LOCAL_GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define LOCAL_GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221 -#define LOCAL_GL_PRIMITIVE_RESTART_INDEX 0x8F9E -#define LOCAL_GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#define LOCAL_GL_PRIMITIVE_RESTART_NV 0x8558 -#define LOCAL_GL_PROGRAM 0x82E2 -#define LOCAL_GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 -#define LOCAL_GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 -#define LOCAL_GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 -#define LOCAL_GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 -#define LOCAL_GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define LOCAL_GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define LOCAL_GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define LOCAL_GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define LOCAL_GL_PROGRAM_BINARY_ANGLE 0x93A6 -#define LOCAL_GL_PROGRAM_BINARY_FORMATS 0x87FF -#define LOCAL_GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -#define LOCAL_GL_PROGRAM_BINARY_LENGTH 0x8741 -#define LOCAL_GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define LOCAL_GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define LOCAL_GL_PROGRAM_BINDING_ARB 0x8677 -#define LOCAL_GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define LOCAL_GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define LOCAL_GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define LOCAL_GL_PROGRAM_ERROR_STRING_NV 0x8874 -#define LOCAL_GL_PROGRAM_FORMAT_ARB 0x8876 -#define LOCAL_GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define LOCAL_GL_PROGRAM_INPUT 0x92E3 -#define LOCAL_GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define LOCAL_GL_PROGRAM_KHR 0x82E2 -#define LOCAL_GL_PROGRAM_LENGTH_ARB 0x8627 -#define LOCAL_GL_PROGRAM_LENGTH_NV 0x8627 -#define LOCAL_GL_PROGRAM_MATRIX_EXT 0x8E2D -#define LOCAL_GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#define LOCAL_GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define LOCAL_GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define LOCAL_GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define LOCAL_GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define LOCAL_GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define LOCAL_GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define LOCAL_GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define LOCAL_GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define LOCAL_GL_PROGRAM_OBJECT_ARB 0x8B40 -#define LOCAL_GL_PROGRAM_OBJECT_EXT 0x8B40 -#define LOCAL_GL_PROGRAM_OUTPUT 0x92E4 -#define LOCAL_GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define LOCAL_GL_PROGRAM_PARAMETER_NV 0x8644 -#define LOCAL_GL_PROGRAM_PIPELINE 0x82E4 -#define LOCAL_GL_PROGRAM_PIPELINE_BINDING 0x825A -#define LOCAL_GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A -#define LOCAL_GL_PROGRAM_PIPELINE_KHR 0x82E4 -#define LOCAL_GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define LOCAL_GL_PROGRAM_POINT_SIZE 0x8642 -#define LOCAL_GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define LOCAL_GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#define LOCAL_GL_PROGRAM_RESIDENT_NV 0x8647 -#define LOCAL_GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define LOCAL_GL_PROGRAM_SEPARABLE 0x8258 -#define LOCAL_GL_PROGRAM_SEPARABLE_EXT 0x8258 -#define LOCAL_GL_PROGRAM_STRING_ARB 0x8628 -#define LOCAL_GL_PROGRAM_STRING_NV 0x8628 -#define LOCAL_GL_PROGRAM_TARGET_NV 0x8646 -#define LOCAL_GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define LOCAL_GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define LOCAL_GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define LOCAL_GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define LOCAL_GL_PROJECTION 0x1701 -#define LOCAL_GL_PROJECTION_MATRIX 0x0BA7 -#define LOCAL_GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E -#define LOCAL_GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define LOCAL_GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B -#define LOCAL_GL_PROVOKING_VERTEX 0x8E4F -#define LOCAL_GL_PROVOKING_VERTEX_EXT 0x8E4F -#define LOCAL_GL_PROXY_COLOR_TABLE 0x80D3 -#define LOCAL_GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define LOCAL_GL_PROXY_HISTOGRAM 0x8025 -#define LOCAL_GL_PROXY_HISTOGRAM_EXT 0x8025 -#define LOCAL_GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define LOCAL_GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define LOCAL_GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define LOCAL_GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define LOCAL_GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#define LOCAL_GL_PROXY_TEXTURE_1D 0x8063 -#define LOCAL_GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define LOCAL_GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define LOCAL_GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define LOCAL_GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define LOCAL_GL_PROXY_TEXTURE_2D 0x8064 -#define LOCAL_GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define LOCAL_GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define LOCAL_GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define LOCAL_GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define LOCAL_GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define LOCAL_GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define LOCAL_GL_PROXY_TEXTURE_3D 0x8070 -#define LOCAL_GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define LOCAL_GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define LOCAL_GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#define LOCAL_GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define LOCAL_GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define LOCAL_GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define LOCAL_GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define LOCAL_GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define LOCAL_GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define LOCAL_GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define LOCAL_GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define LOCAL_GL_PURGEABLE_APPLE 0x8A1D -#define LOCAL_GL_PURGED_CONTEXT_RESET_NV 0x92BB -#define LOCAL_GL_Q 0x2003 -#define LOCAL_GL_QUADRATIC_ATTENUATION 0x1209 -#define LOCAL_GL_QUADRATIC_CURVE_TO_NV 0x0A -#define LOCAL_GL_QUADS 0x0007 -#define LOCAL_GL_QUADS_EXT 0x0007 -#define LOCAL_GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define LOCAL_GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define LOCAL_GL_QUADS_OES 0x0007 -#define LOCAL_GL_QUAD_ALPHA4_SGIS 0x811E -#define LOCAL_GL_QUAD_ALPHA8_SGIS 0x811F -#define LOCAL_GL_QUAD_INTENSITY4_SGIS 0x8122 -#define LOCAL_GL_QUAD_INTENSITY8_SGIS 0x8123 -#define LOCAL_GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define LOCAL_GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define LOCAL_GL_QUAD_MESH_SUN 0x8614 -#define LOCAL_GL_QUAD_STRIP 0x0008 -#define LOCAL_GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#define LOCAL_GL_QUARTER_BIT_ATI 0x00000010 -#define LOCAL_GL_QUERY 0x82E3 -#define LOCAL_GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF -#define LOCAL_GL_QUERY_BUFFER 0x9192 -#define LOCAL_GL_QUERY_BUFFER_AMD 0x9192 -#define LOCAL_GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 -#define LOCAL_GL_QUERY_BUFFER_BINDING 0x9193 -#define LOCAL_GL_QUERY_BUFFER_BINDING_AMD 0x9193 -#define LOCAL_GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define LOCAL_GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A -#define LOCAL_GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#define LOCAL_GL_QUERY_BY_REGION_WAIT 0x8E15 -#define LOCAL_GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 -#define LOCAL_GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define LOCAL_GL_QUERY_COUNTER_BITS 0x8864 -#define LOCAL_GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define LOCAL_GL_QUERY_COUNTER_BITS_EXT 0x8864 -#define LOCAL_GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 -#define LOCAL_GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 -#define LOCAL_GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 -#define LOCAL_GL_QUERY_KHR 0x82E3 -#define LOCAL_GL_QUERY_NO_WAIT 0x8E14 -#define LOCAL_GL_QUERY_NO_WAIT_INVERTED 0x8E18 -#define LOCAL_GL_QUERY_NO_WAIT_NV 0x8E14 -#define LOCAL_GL_QUERY_OBJECT_AMD 0x9153 -#define LOCAL_GL_QUERY_OBJECT_EXT 0x9153 -#define LOCAL_GL_QUERY_RESULT 0x8866 -#define LOCAL_GL_QUERY_RESULT_ARB 0x8866 -#define LOCAL_GL_QUERY_RESULT_AVAILABLE 0x8867 -#define LOCAL_GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define LOCAL_GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 -#define LOCAL_GL_QUERY_RESULT_EXT 0x8866 -#define LOCAL_GL_QUERY_RESULT_NO_WAIT 0x9194 -#define LOCAL_GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 -#define LOCAL_GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 -#define LOCAL_GL_QUERY_TARGET 0x82EA -#define LOCAL_GL_QUERY_WAIT 0x8E13 -#define LOCAL_GL_QUERY_WAIT_INVERTED 0x8E17 -#define LOCAL_GL_QUERY_WAIT_NV 0x8E13 -#define LOCAL_GL_R 0x2002 -#define LOCAL_GL_R11F_G11F_B10F 0x8C3A -#define LOCAL_GL_R11F_G11F_B10F_APPLE 0x8C3A -#define LOCAL_GL_R11F_G11F_B10F_EXT 0x8C3A -#define LOCAL_GL_R16 0x822A -#define LOCAL_GL_R16F 0x822D -#define LOCAL_GL_R16F_EXT 0x822D -#define LOCAL_GL_R16I 0x8233 -#define LOCAL_GL_R16UI 0x8234 -#define LOCAL_GL_R16_EXT 0x822A -#define LOCAL_GL_R16_SNORM 0x8F98 -#define LOCAL_GL_R16_SNORM_EXT 0x8F98 -#define LOCAL_GL_R1UI_C3F_V3F_SUN 0x85C6 -#define LOCAL_GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define LOCAL_GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define LOCAL_GL_R1UI_N3F_V3F_SUN 0x85C7 -#define LOCAL_GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#define LOCAL_GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define LOCAL_GL_R1UI_T2F_V3F_SUN 0x85C9 -#define LOCAL_GL_R1UI_V3F_SUN 0x85C4 -#define LOCAL_GL_R32F 0x822E -#define LOCAL_GL_R32F_EXT 0x822E -#define LOCAL_GL_R32I 0x8235 -#define LOCAL_GL_R32UI 0x8236 -#define LOCAL_GL_R3_G3_B2 0x2A10 -#define LOCAL_GL_R8 0x8229 -#define LOCAL_GL_R8I 0x8231 -#define LOCAL_GL_R8UI 0x8232 -#define LOCAL_GL_R8_EXT 0x8229 -#define LOCAL_GL_R8_SNORM 0x8F94 -#define LOCAL_GL_RASTERIZER_DISCARD 0x8C89 -#define LOCAL_GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define LOCAL_GL_RASTERIZER_DISCARD_NV 0x8C89 -#define LOCAL_GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A -#define LOCAL_GL_RASTER_MULTISAMPLE_EXT 0x9327 -#define LOCAL_GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#define LOCAL_GL_RASTER_SAMPLES_EXT 0x9328 -#define LOCAL_GL_READ_BUFFER 0x0C02 -#define LOCAL_GL_READ_BUFFER_EXT 0x0C02 -#define LOCAL_GL_READ_BUFFER_NV 0x0C02 -#define LOCAL_GL_READ_FRAMEBUFFER 0x8CA8 -#define LOCAL_GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define LOCAL_GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define LOCAL_GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define LOCAL_GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -#define LOCAL_GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -#define LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#define LOCAL_GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA -#define LOCAL_GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define LOCAL_GL_READ_FRAMEBUFFER_NV 0x8CA8 -#define LOCAL_GL_READ_ONLY 0x88B8 -#define LOCAL_GL_READ_ONLY_ARB 0x88B8 -#define LOCAL_GL_READ_PIXELS 0x828C -#define LOCAL_GL_READ_PIXELS_FORMAT 0x828D -#define LOCAL_GL_READ_PIXELS_TYPE 0x828E -#define LOCAL_GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define LOCAL_GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define LOCAL_GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#define LOCAL_GL_READ_WRITE 0x88BA -#define LOCAL_GL_READ_WRITE_ARB 0x88BA -#define LOCAL_GL_RECIP_ADD_SIGNED_ALPHA_IMG 0x8C05 -#define LOCAL_GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define LOCAL_GL_RECT_NV 0xF6 -#define LOCAL_GL_RED 0x1903 -#define LOCAL_GL_REDUCE 0x8016 -#define LOCAL_GL_REDUCE_EXT 0x8016 -#define LOCAL_GL_RED_BIAS 0x0D15 -#define LOCAL_GL_RED_BITS 0x0D52 -#define LOCAL_GL_RED_BIT_ATI 0x00000001 -#define LOCAL_GL_RED_EXT 0x1903 -#define LOCAL_GL_RED_INTEGER 0x8D94 -#define LOCAL_GL_RED_INTEGER_EXT 0x8D94 -#define LOCAL_GL_RED_MAX_CLAMP_INGR 0x8564 -#define LOCAL_GL_RED_MIN_CLAMP_INGR 0x8560 -#define LOCAL_GL_RED_NV 0x1903 -#define LOCAL_GL_RED_SCALE 0x0D14 -#define LOCAL_GL_RED_SNORM 0x8F90 -#define LOCAL_GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#define LOCAL_GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#define LOCAL_GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define LOCAL_GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309 -#define LOCAL_GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309 -#define LOCAL_GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define LOCAL_GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307 -#define LOCAL_GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307 -#define LOCAL_GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define LOCAL_GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308 -#define LOCAL_GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308 -#define LOCAL_GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#define LOCAL_GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#define LOCAL_GL_REFERENCE_PLANE_SGIX 0x817D -#define LOCAL_GL_REFLECTION_MAP 0x8512 -#define LOCAL_GL_REFLECTION_MAP_ARB 0x8512 -#define LOCAL_GL_REFLECTION_MAP_EXT 0x8512 -#define LOCAL_GL_REFLECTION_MAP_NV 0x8512 -#define LOCAL_GL_REFLECTION_MAP_OES 0x8512 -#define LOCAL_GL_REGISTER_COMBINERS_NV 0x8522 -#define LOCAL_GL_REG_0_ATI 0x8921 -#define LOCAL_GL_REG_10_ATI 0x892B -#define LOCAL_GL_REG_11_ATI 0x892C -#define LOCAL_GL_REG_12_ATI 0x892D -#define LOCAL_GL_REG_13_ATI 0x892E -#define LOCAL_GL_REG_14_ATI 0x892F -#define LOCAL_GL_REG_15_ATI 0x8930 -#define LOCAL_GL_REG_16_ATI 0x8931 -#define LOCAL_GL_REG_17_ATI 0x8932 -#define LOCAL_GL_REG_18_ATI 0x8933 -#define LOCAL_GL_REG_19_ATI 0x8934 -#define LOCAL_GL_REG_1_ATI 0x8922 -#define LOCAL_GL_REG_20_ATI 0x8935 -#define LOCAL_GL_REG_21_ATI 0x8936 -#define LOCAL_GL_REG_22_ATI 0x8937 -#define LOCAL_GL_REG_23_ATI 0x8938 -#define LOCAL_GL_REG_24_ATI 0x8939 -#define LOCAL_GL_REG_25_ATI 0x893A -#define LOCAL_GL_REG_26_ATI 0x893B -#define LOCAL_GL_REG_27_ATI 0x893C -#define LOCAL_GL_REG_28_ATI 0x893D -#define LOCAL_GL_REG_29_ATI 0x893E -#define LOCAL_GL_REG_2_ATI 0x8923 -#define LOCAL_GL_REG_30_ATI 0x893F -#define LOCAL_GL_REG_31_ATI 0x8940 -#define LOCAL_GL_REG_3_ATI 0x8924 -#define LOCAL_GL_REG_4_ATI 0x8925 -#define LOCAL_GL_REG_5_ATI 0x8926 -#define LOCAL_GL_REG_6_ATI 0x8927 -#define LOCAL_GL_REG_7_ATI 0x8928 -#define LOCAL_GL_REG_8_ATI 0x8929 -#define LOCAL_GL_REG_9_ATI 0x892A -#define LOCAL_GL_RELATIVE_ARC_TO_NV 0xFF -#define LOCAL_GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B -#define LOCAL_GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define LOCAL_GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define LOCAL_GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define LOCAL_GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define LOCAL_GL_RELATIVE_LINE_TO_NV 0x05 -#define LOCAL_GL_RELATIVE_MOVE_TO_NV 0x03 -#define LOCAL_GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define LOCAL_GL_RELATIVE_RECT_NV 0xF7 -#define LOCAL_GL_RELATIVE_ROUNDED_RECT2_NV 0xEB -#define LOCAL_GL_RELATIVE_ROUNDED_RECT4_NV 0xED -#define LOCAL_GL_RELATIVE_ROUNDED_RECT8_NV 0xEF -#define LOCAL_GL_RELATIVE_ROUNDED_RECT_NV 0xE9 -#define LOCAL_GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define LOCAL_GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define LOCAL_GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define LOCAL_GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define LOCAL_GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define LOCAL_GL_RELEASED_APPLE 0x8A19 -#define LOCAL_GL_RENDER 0x1C00 -#define LOCAL_GL_RENDERBUFFER 0x8D41 -#define LOCAL_GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define LOCAL_GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define LOCAL_GL_RENDERBUFFER_ALPHA_SIZE_OES 0x8D53 -#define LOCAL_GL_RENDERBUFFER_BINDING 0x8CA7 -#define LOCAL_GL_RENDERBUFFER_BINDING_ANGLE 0x8CA7 -#define LOCAL_GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define LOCAL_GL_RENDERBUFFER_BINDING_OES 0x8CA7 -#define LOCAL_GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define LOCAL_GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define LOCAL_GL_RENDERBUFFER_BLUE_SIZE_OES 0x8D52 -#define LOCAL_GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define LOCAL_GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define LOCAL_GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define LOCAL_GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define LOCAL_GL_RENDERBUFFER_DEPTH_SIZE_OES 0x8D54 -#define LOCAL_GL_RENDERBUFFER_EXT 0x8D41 -#define LOCAL_GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#define LOCAL_GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define LOCAL_GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define LOCAL_GL_RENDERBUFFER_GREEN_SIZE_OES 0x8D51 -#define LOCAL_GL_RENDERBUFFER_HEIGHT 0x8D43 -#define LOCAL_GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define LOCAL_GL_RENDERBUFFER_HEIGHT_OES 0x8D43 -#define LOCAL_GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define LOCAL_GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define LOCAL_GL_RENDERBUFFER_INTERNAL_FORMAT_OES 0x8D44 -#define LOCAL_GL_RENDERBUFFER_OES 0x8D41 -#define LOCAL_GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define LOCAL_GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define LOCAL_GL_RENDERBUFFER_RED_SIZE_OES 0x8D50 -#define LOCAL_GL_RENDERBUFFER_SAMPLES 0x8CAB -#define LOCAL_GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define LOCAL_GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define LOCAL_GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define LOCAL_GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define LOCAL_GL_RENDERBUFFER_SAMPLES_NV 0x8CAB -#define LOCAL_GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define LOCAL_GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#define LOCAL_GL_RENDERBUFFER_STENCIL_SIZE_OES 0x8D55 -#define LOCAL_GL_RENDERBUFFER_WIDTH 0x8D42 -#define LOCAL_GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define LOCAL_GL_RENDERBUFFER_WIDTH_OES 0x8D42 -#define LOCAL_GL_RENDERER 0x1F01 -#define LOCAL_GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 -#define LOCAL_GL_RENDER_GPU_MASK_NV 0x9558 -#define LOCAL_GL_RENDER_MODE 0x0C40 -#define LOCAL_GL_REPEAT 0x2901 -#define LOCAL_GL_REPLACE 0x1E01 -#define LOCAL_GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define LOCAL_GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define LOCAL_GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define LOCAL_GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define LOCAL_GL_REPLACEMENT_CODE_SUN 0x81D8 -#define LOCAL_GL_REPLACE_EXT 0x8062 -#define LOCAL_GL_REPLACE_MIDDLE_SUN 0x0002 -#define LOCAL_GL_REPLACE_OLDEST_SUN 0x0003 -#define LOCAL_GL_REPLACE_VALUE_AMD 0x874B -#define LOCAL_GL_REPLICATE_BORDER 0x8153 -#define LOCAL_GL_REPLICATE_BORDER_HP 0x8153 -#define LOCAL_GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#define LOCAL_GL_RESAMPLE_AVERAGE_OML 0x8988 -#define LOCAL_GL_RESAMPLE_DECIMATE_OML 0x8989 -#define LOCAL_GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#define LOCAL_GL_RESAMPLE_REPLICATE_OML 0x8986 -#define LOCAL_GL_RESAMPLE_REPLICATE_SGIX 0x8433 -#define LOCAL_GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define LOCAL_GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 -#define LOCAL_GL_RESCALE_NORMAL 0x803A -#define LOCAL_GL_RESCALE_NORMAL_EXT 0x803A -#define LOCAL_GL_RESET_NOTIFICATION_STRATEGY 0x8256 -#define LOCAL_GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define LOCAL_GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 -#define LOCAL_GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 -#define LOCAL_GL_RESTART_PATH_NV 0xF0 -#define LOCAL_GL_RESTART_SUN 0x0001 -#define LOCAL_GL_RETAINED_APPLE 0x8A1B -#define LOCAL_GL_RETURN 0x0102 -#define LOCAL_GL_RG 0x8227 -#define LOCAL_GL_RG16 0x822C -#define LOCAL_GL_RG16F 0x822F -#define LOCAL_GL_RG16F_EXT 0x822F -#define LOCAL_GL_RG16I 0x8239 -#define LOCAL_GL_RG16UI 0x823A -#define LOCAL_GL_RG16_EXT 0x822C -#define LOCAL_GL_RG16_SNORM 0x8F99 -#define LOCAL_GL_RG16_SNORM_EXT 0x8F99 -#define LOCAL_GL_RG32F 0x8230 -#define LOCAL_GL_RG32F_EXT 0x8230 -#define LOCAL_GL_RG32I 0x823B -#define LOCAL_GL_RG32UI 0x823C -#define LOCAL_GL_RG8 0x822B -#define LOCAL_GL_RG8I 0x8237 -#define LOCAL_GL_RG8UI 0x8238 -#define LOCAL_GL_RG8_EXT 0x822B -#define LOCAL_GL_RG8_SNORM 0x8F95 -#define LOCAL_GL_RGB 0x1907 -#define LOCAL_GL_RGB10 0x8052 -#define LOCAL_GL_RGB10_A2 0x8059 -#define LOCAL_GL_RGB10_A2UI 0x906F -#define LOCAL_GL_RGB10_A2_EXT 0x8059 -#define LOCAL_GL_RGB10_EXT 0x8052 -#define LOCAL_GL_RGB12 0x8053 -#define LOCAL_GL_RGB12_EXT 0x8053 -#define LOCAL_GL_RGB16 0x8054 -#define LOCAL_GL_RGB16F 0x881B -#define LOCAL_GL_RGB16F_ARB 0x881B -#define LOCAL_GL_RGB16F_EXT 0x881B -#define LOCAL_GL_RGB16I 0x8D89 -#define LOCAL_GL_RGB16I_EXT 0x8D89 -#define LOCAL_GL_RGB16UI 0x8D77 -#define LOCAL_GL_RGB16UI_EXT 0x8D77 -#define LOCAL_GL_RGB16_EXT 0x8054 -#define LOCAL_GL_RGB16_SNORM 0x8F9A -#define LOCAL_GL_RGB16_SNORM_EXT 0x8F9A -#define LOCAL_GL_RGB2_EXT 0x804E -#define LOCAL_GL_RGB32F 0x8815 -#define LOCAL_GL_RGB32F_ARB 0x8815 -#define LOCAL_GL_RGB32F_EXT 0x8815 -#define LOCAL_GL_RGB32I 0x8D83 -#define LOCAL_GL_RGB32I_EXT 0x8D83 -#define LOCAL_GL_RGB32UI 0x8D71 -#define LOCAL_GL_RGB32UI_EXT 0x8D71 -#define LOCAL_GL_RGB4 0x804F -#define LOCAL_GL_RGB4_EXT 0x804F -#define LOCAL_GL_RGB4_S3TC 0x83A1 -#define LOCAL_GL_RGB5 0x8050 -#define LOCAL_GL_RGB565 0x8D62 -#define LOCAL_GL_RGB565_OES 0x8D62 -#define LOCAL_GL_RGB5_A1 0x8057 -#define LOCAL_GL_RGB5_A1_EXT 0x8057 -#define LOCAL_GL_RGB5_A1_OES 0x8057 -#define LOCAL_GL_RGB5_EXT 0x8050 -#define LOCAL_GL_RGB8 0x8051 -#define LOCAL_GL_RGB8I 0x8D8F -#define LOCAL_GL_RGB8I_EXT 0x8D8F -#define LOCAL_GL_RGB8UI 0x8D7D -#define LOCAL_GL_RGB8UI_EXT 0x8D7D -#define LOCAL_GL_RGB8_EXT 0x8051 -#define LOCAL_GL_RGB8_OES 0x8051 -#define LOCAL_GL_RGB8_SNORM 0x8F96 -#define LOCAL_GL_RGB9_E5 0x8C3D -#define LOCAL_GL_RGB9_E5_APPLE 0x8C3D -#define LOCAL_GL_RGB9_E5_EXT 0x8C3D -#define LOCAL_GL_RGBA 0x1908 -#define LOCAL_GL_RGBA12 0x805A -#define LOCAL_GL_RGBA12_EXT 0x805A -#define LOCAL_GL_RGBA16 0x805B -#define LOCAL_GL_RGBA16F 0x881A -#define LOCAL_GL_RGBA16F_ARB 0x881A -#define LOCAL_GL_RGBA16F_EXT 0x881A -#define LOCAL_GL_RGBA16I 0x8D88 -#define LOCAL_GL_RGBA16I_EXT 0x8D88 -#define LOCAL_GL_RGBA16UI 0x8D76 -#define LOCAL_GL_RGBA16UI_EXT 0x8D76 -#define LOCAL_GL_RGBA16_EXT 0x805B -#define LOCAL_GL_RGBA16_SNORM 0x8F9B -#define LOCAL_GL_RGBA16_SNORM_EXT 0x8F9B -#define LOCAL_GL_RGBA2 0x8055 -#define LOCAL_GL_RGBA2_EXT 0x8055 -#define LOCAL_GL_RGBA32F 0x8814 -#define LOCAL_GL_RGBA32F_ARB 0x8814 -#define LOCAL_GL_RGBA32F_EXT 0x8814 -#define LOCAL_GL_RGBA32I 0x8D82 -#define LOCAL_GL_RGBA32I_EXT 0x8D82 -#define LOCAL_GL_RGBA32UI 0x8D70 -#define LOCAL_GL_RGBA32UI_EXT 0x8D70 -#define LOCAL_GL_RGBA4 0x8056 -#define LOCAL_GL_RGBA4_DXT5_S3TC 0x83A5 -#define LOCAL_GL_RGBA4_EXT 0x8056 -#define LOCAL_GL_RGBA4_OES 0x8056 -#define LOCAL_GL_RGBA4_S3TC 0x83A3 -#define LOCAL_GL_RGBA8 0x8058 -#define LOCAL_GL_RGBA8I 0x8D8E -#define LOCAL_GL_RGBA8I_EXT 0x8D8E -#define LOCAL_GL_RGBA8UI 0x8D7C -#define LOCAL_GL_RGBA8UI_EXT 0x8D7C -#define LOCAL_GL_RGBA8_EXT 0x8058 -#define LOCAL_GL_RGBA8_OES 0x8058 -#define LOCAL_GL_RGBA8_SNORM 0x8F97 -#define LOCAL_GL_RGBA_DXT5_S3TC 0x83A4 -#define LOCAL_GL_RGBA_FLOAT16_APPLE 0x881A -#define LOCAL_GL_RGBA_FLOAT16_ATI 0x881A -#define LOCAL_GL_RGBA_FLOAT32_APPLE 0x8814 -#define LOCAL_GL_RGBA_FLOAT32_ATI 0x8814 -#define LOCAL_GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define LOCAL_GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define LOCAL_GL_RGBA_INTEGER 0x8D99 -#define LOCAL_GL_RGBA_INTEGER_EXT 0x8D99 -#define LOCAL_GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#define LOCAL_GL_RGBA_MODE 0x0C31 -#define LOCAL_GL_RGBA_S3TC 0x83A2 -#define LOCAL_GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#define LOCAL_GL_RGBA_SNORM 0x8F93 -#define LOCAL_GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define LOCAL_GL_RGB_422_APPLE 0x8A1F -#define LOCAL_GL_RGB_FLOAT16_APPLE 0x881B -#define LOCAL_GL_RGB_FLOAT16_ATI 0x881B -#define LOCAL_GL_RGB_FLOAT32_APPLE 0x8815 -#define LOCAL_GL_RGB_FLOAT32_ATI 0x8815 -#define LOCAL_GL_RGB_INTEGER 0x8D98 -#define LOCAL_GL_RGB_INTEGER_EXT 0x8D98 -#define LOCAL_GL_RGB_RAW_422_APPLE 0x8A51 -#define LOCAL_GL_RGB_S3TC 0x83A0 -#define LOCAL_GL_RGB_SCALE 0x8573 -#define LOCAL_GL_RGB_SCALE_ARB 0x8573 -#define LOCAL_GL_RGB_SCALE_EXT 0x8573 -#define LOCAL_GL_RGB_SNORM 0x8F92 -#define LOCAL_GL_RG_EXT 0x8227 -#define LOCAL_GL_RG_INTEGER 0x8228 -#define LOCAL_GL_RG_SNORM 0x8F91 -#define LOCAL_GL_RIGHT 0x0407 -#define LOCAL_GL_ROUNDED_RECT2_NV 0xEA -#define LOCAL_GL_ROUNDED_RECT4_NV 0xEC -#define LOCAL_GL_ROUNDED_RECT8_NV 0xEE -#define LOCAL_GL_ROUNDED_RECT_NV 0xE8 -#define LOCAL_GL_ROUND_NV 0x90A4 -#define LOCAL_GL_S 0x2000 -#define LOCAL_GL_SAMPLER 0x82E6 -#define LOCAL_GL_SAMPLER_1D 0x8B5D -#define LOCAL_GL_SAMPLER_1D_ARB 0x8B5D -#define LOCAL_GL_SAMPLER_1D_ARRAY 0x8DC0 -#define LOCAL_GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define LOCAL_GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define LOCAL_GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define LOCAL_GL_SAMPLER_1D_SHADOW 0x8B61 -#define LOCAL_GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define LOCAL_GL_SAMPLER_2D 0x8B5E -#define LOCAL_GL_SAMPLER_2D_ARB 0x8B5E -#define LOCAL_GL_SAMPLER_2D_ARRAY 0x8DC1 -#define LOCAL_GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define LOCAL_GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define LOCAL_GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define LOCAL_GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 -#define LOCAL_GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define LOCAL_GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define LOCAL_GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B -#define LOCAL_GL_SAMPLER_2D_RECT 0x8B63 -#define LOCAL_GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define LOCAL_GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define LOCAL_GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define LOCAL_GL_SAMPLER_2D_SHADOW 0x8B62 -#define LOCAL_GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define LOCAL_GL_SAMPLER_2D_SHADOW_EXT 0x8B62 -#define LOCAL_GL_SAMPLER_3D 0x8B5F -#define LOCAL_GL_SAMPLER_3D_ARB 0x8B5F -#define LOCAL_GL_SAMPLER_3D_OES 0x8B5F -#define LOCAL_GL_SAMPLER_BINDING 0x8919 -#define LOCAL_GL_SAMPLER_BUFFER 0x8DC2 -#define LOCAL_GL_SAMPLER_BUFFER_AMD 0x9001 -#define LOCAL_GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define LOCAL_GL_SAMPLER_BUFFER_OES 0x8DC2 -#define LOCAL_GL_SAMPLER_CUBE 0x8B60 -#define LOCAL_GL_SAMPLER_CUBE_ARB 0x8B60 -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D -#define LOCAL_GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D -#define LOCAL_GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define LOCAL_GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define LOCAL_GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 -#define LOCAL_GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 -#define LOCAL_GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define LOCAL_GL_SAMPLER_KHR 0x82E6 -#define LOCAL_GL_SAMPLER_OBJECT_AMD 0x9155 -#define LOCAL_GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define LOCAL_GL_SAMPLES 0x80A9 -#define LOCAL_GL_SAMPLES_3DFX 0x86B4 -#define LOCAL_GL_SAMPLES_ARB 0x80A9 -#define LOCAL_GL_SAMPLES_EXT 0x80A9 -#define LOCAL_GL_SAMPLES_PASSED 0x8914 -#define LOCAL_GL_SAMPLES_PASSED_ARB 0x8914 -#define LOCAL_GL_SAMPLES_SGIS 0x80A9 -#define LOCAL_GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define LOCAL_GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define LOCAL_GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define LOCAL_GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define LOCAL_GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define LOCAL_GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define LOCAL_GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define LOCAL_GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define LOCAL_GL_SAMPLE_BUFFERS 0x80A8 -#define LOCAL_GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define LOCAL_GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define LOCAL_GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define LOCAL_GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define LOCAL_GL_SAMPLE_COVERAGE 0x80A0 -#define LOCAL_GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define LOCAL_GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define LOCAL_GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define LOCAL_GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define LOCAL_GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define LOCAL_GL_SAMPLE_LOCATION_ARB 0x8E50 -#define LOCAL_GL_SAMPLE_LOCATION_NV 0x8E50 -#define LOCAL_GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F -#define LOCAL_GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F -#define LOCAL_GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E -#define LOCAL_GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E -#define LOCAL_GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D -#define LOCAL_GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D -#define LOCAL_GL_SAMPLE_MASK 0x8E51 -#define LOCAL_GL_SAMPLE_MASK_EXT 0x80A0 -#define LOCAL_GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define LOCAL_GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define LOCAL_GL_SAMPLE_MASK_NV 0x8E51 -#define LOCAL_GL_SAMPLE_MASK_SGIS 0x80A0 -#define LOCAL_GL_SAMPLE_MASK_VALUE 0x8E52 -#define LOCAL_GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define LOCAL_GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define LOCAL_GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define LOCAL_GL_SAMPLE_PATTERN_EXT 0x80AC -#define LOCAL_GL_SAMPLE_PATTERN_SGIS 0x80AC -#define LOCAL_GL_SAMPLE_POSITION 0x8E50 -#define LOCAL_GL_SAMPLE_POSITION_NV 0x8E50 -#define LOCAL_GL_SAMPLE_SHADING 0x8C36 -#define LOCAL_GL_SAMPLE_SHADING_ARB 0x8C36 -#define LOCAL_GL_SAMPLE_SHADING_OES 0x8C36 -#define LOCAL_GL_SATURATE_BIT_ATI 0x00000040 -#define LOCAL_GL_SCALAR_EXT 0x87BE -#define LOCAL_GL_SCALEBIAS_HINT_SGIX 0x8322 -#define LOCAL_GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define LOCAL_GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#define LOCAL_GL_SCALE_BY_FOUR_NV 0x853F -#define LOCAL_GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define LOCAL_GL_SCALE_BY_TWO_NV 0x853E -#define LOCAL_GL_SCISSOR_BIT 0x00080000 -#define LOCAL_GL_SCISSOR_BOX 0x0C10 -#define LOCAL_GL_SCISSOR_COMMAND_NV 0x0011 -#define LOCAL_GL_SCISSOR_TEST 0x0C11 -#define LOCAL_GL_SCREEN 0x9295 -#define LOCAL_GL_SCREEN_COORDINATES_REND 0x8490 -#define LOCAL_GL_SCREEN_KHR 0x9295 -#define LOCAL_GL_SCREEN_NV 0x9295 -#define LOCAL_GL_SECONDARY_COLOR_ARRAY 0x845E -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define LOCAL_GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define LOCAL_GL_SECONDARY_COLOR_NV 0x852D -#define LOCAL_GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define LOCAL_GL_SELECT 0x1C02 -#define LOCAL_GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define LOCAL_GL_SELECTION_BUFFER_SIZE 0x0DF4 -#define LOCAL_GL_SEPARABLE_2D 0x8012 -#define LOCAL_GL_SEPARABLE_2D_EXT 0x8012 -#define LOCAL_GL_SEPARATE_ATTRIBS 0x8C8D -#define LOCAL_GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define LOCAL_GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define LOCAL_GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define LOCAL_GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#define LOCAL_GL_SET 0x150F -#define LOCAL_GL_SET_AMD 0x874A -#define LOCAL_GL_SGX_BINARY_IMG 0x8C0A -#define LOCAL_GL_SGX_PROGRAM_BINARY_IMG 0x9130 -#define LOCAL_GL_SHADER 0x82E1 -#define LOCAL_GL_SHADER_BINARY_DMP 0x9250 -#define LOCAL_GL_SHADER_BINARY_FORMATS 0x8DF8 -#define LOCAL_GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 -#define LOCAL_GL_SHADER_BINARY_VIV 0x8FC4 -#define LOCAL_GL_SHADER_COMPILER 0x8DFA -#define LOCAL_GL_SHADER_CONSISTENT_NV 0x86DD -#define LOCAL_GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -#define LOCAL_GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define LOCAL_GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define LOCAL_GL_SHADER_IMAGE_ATOMIC 0x82A6 -#define LOCAL_GL_SHADER_IMAGE_LOAD 0x82A4 -#define LOCAL_GL_SHADER_IMAGE_STORE 0x82A5 -#define LOCAL_GL_SHADER_INCLUDE_ARB 0x8DAE -#define LOCAL_GL_SHADER_KHR 0x82E1 -#define LOCAL_GL_SHADER_OBJECT_ARB 0x8B48 -#define LOCAL_GL_SHADER_OBJECT_EXT 0x8B48 -#define LOCAL_GL_SHADER_OPERATION_NV 0x86DF -#define LOCAL_GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 -#define LOCAL_GL_SHADER_SOURCE_LENGTH 0x8B88 -#define LOCAL_GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 -#define LOCAL_GL_SHADER_STORAGE_BLOCK 0x92E6 -#define LOCAL_GL_SHADER_STORAGE_BUFFER 0x90D2 -#define LOCAL_GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#define LOCAL_GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF -#define LOCAL_GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#define LOCAL_GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define LOCAL_GL_SHADER_TYPE 0x8B4F -#define LOCAL_GL_SHADE_MODEL 0x0B54 -#define LOCAL_GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define LOCAL_GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#define LOCAL_GL_SHADOW_AMBIENT_SGIX 0x80BF -#define LOCAL_GL_SHADOW_ATTENUATION_EXT 0x834E -#define LOCAL_GL_SHARED_EDGE_NV 0xC0 -#define LOCAL_GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#define LOCAL_GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#define LOCAL_GL_SHININESS 0x1601 -#define LOCAL_GL_SHORT 0x1402 -#define LOCAL_GL_SIGNALED 0x9119 -#define LOCAL_GL_SIGNALED_APPLE 0x9119 -#define LOCAL_GL_SIGNED_ALPHA8_NV 0x8706 -#define LOCAL_GL_SIGNED_ALPHA_NV 0x8705 -#define LOCAL_GL_SIGNED_HILO16_NV 0x86FA -#define LOCAL_GL_SIGNED_HILO8_NV 0x885F -#define LOCAL_GL_SIGNED_HILO_NV 0x86F9 -#define LOCAL_GL_SIGNED_IDENTITY_NV 0x853C -#define LOCAL_GL_SIGNED_INTENSITY8_NV 0x8708 -#define LOCAL_GL_SIGNED_INTENSITY_NV 0x8707 -#define LOCAL_GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define LOCAL_GL_SIGNED_LUMINANCE8_NV 0x8702 -#define LOCAL_GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define LOCAL_GL_SIGNED_LUMINANCE_NV 0x8701 -#define LOCAL_GL_SIGNED_NEGATE_NV 0x853D -#define LOCAL_GL_SIGNED_NORMALIZED 0x8F9C -#define LOCAL_GL_SIGNED_RGB8_NV 0x86FF -#define LOCAL_GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define LOCAL_GL_SIGNED_RGBA8_NV 0x86FC -#define LOCAL_GL_SIGNED_RGBA_NV 0x86FB -#define LOCAL_GL_SIGNED_RGB_NV 0x86FE -#define LOCAL_GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define LOCAL_GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC -#define LOCAL_GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE -#define LOCAL_GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD -#define LOCAL_GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF -#define LOCAL_GL_SINGLE_COLOR 0x81F9 -#define LOCAL_GL_SINGLE_COLOR_EXT 0x81F9 -#define LOCAL_GL_SKIP_COMPONENTS1_NV -6 -#define LOCAL_GL_SKIP_COMPONENTS2_NV -5 -#define LOCAL_GL_SKIP_COMPONENTS3_NV -4 -#define LOCAL_GL_SKIP_COMPONENTS4_NV -3 -#define LOCAL_GL_SKIP_DECODE_EXT 0x8A4A -#define LOCAL_GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define LOCAL_GL_SLICE_ACCUM_SUN 0x85CC -#define LOCAL_GL_SLIM10U_SGIX 0x831E -#define LOCAL_GL_SLIM12S_SGIX 0x831F -#define LOCAL_GL_SLIM8U_SGIX 0x831D -#define LOCAL_GL_SLUMINANCE 0x8C46 -#define LOCAL_GL_SLUMINANCE8 0x8C47 -#define LOCAL_GL_SLUMINANCE8_ALPHA8 0x8C45 -#define LOCAL_GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define LOCAL_GL_SLUMINANCE8_ALPHA8_NV 0x8C45 -#define LOCAL_GL_SLUMINANCE8_EXT 0x8C47 -#define LOCAL_GL_SLUMINANCE8_NV 0x8C47 -#define LOCAL_GL_SLUMINANCE_ALPHA 0x8C44 -#define LOCAL_GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define LOCAL_GL_SLUMINANCE_ALPHA_NV 0x8C44 -#define LOCAL_GL_SLUMINANCE_EXT 0x8C46 -#define LOCAL_GL_SLUMINANCE_NV 0x8C46 -#define LOCAL_GL_SMALL_CCW_ARC_TO_NV 0x12 -#define LOCAL_GL_SMALL_CW_ARC_TO_NV 0x14 -#define LOCAL_GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 -#define LOCAL_GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252 -#define LOCAL_GL_SMOOTH 0x1D01 -#define LOCAL_GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define LOCAL_GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define LOCAL_GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define LOCAL_GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define LOCAL_GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define LOCAL_GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define LOCAL_GL_SM_COUNT_NV 0x933B -#define LOCAL_GL_SOFTLIGHT 0x929C -#define LOCAL_GL_SOFTLIGHT_KHR 0x929C -#define LOCAL_GL_SOFTLIGHT_NV 0x929C -#define LOCAL_GL_SOURCE0_ALPHA 0x8588 -#define LOCAL_GL_SOURCE0_ALPHA_ARB 0x8588 -#define LOCAL_GL_SOURCE0_ALPHA_EXT 0x8588 -#define LOCAL_GL_SOURCE0_RGB 0x8580 -#define LOCAL_GL_SOURCE0_RGB_ARB 0x8580 -#define LOCAL_GL_SOURCE0_RGB_EXT 0x8580 -#define LOCAL_GL_SOURCE1_ALPHA 0x8589 -#define LOCAL_GL_SOURCE1_ALPHA_ARB 0x8589 -#define LOCAL_GL_SOURCE1_ALPHA_EXT 0x8589 -#define LOCAL_GL_SOURCE1_RGB 0x8581 -#define LOCAL_GL_SOURCE1_RGB_ARB 0x8581 -#define LOCAL_GL_SOURCE1_RGB_EXT 0x8581 -#define LOCAL_GL_SOURCE2_ALPHA 0x858A -#define LOCAL_GL_SOURCE2_ALPHA_ARB 0x858A -#define LOCAL_GL_SOURCE2_ALPHA_EXT 0x858A -#define LOCAL_GL_SOURCE2_RGB 0x8582 -#define LOCAL_GL_SOURCE2_RGB_ARB 0x8582 -#define LOCAL_GL_SOURCE2_RGB_EXT 0x8582 -#define LOCAL_GL_SOURCE3_ALPHA_NV 0x858B -#define LOCAL_GL_SOURCE3_RGB_NV 0x8583 -#define LOCAL_GL_SPARE0_NV 0x852E -#define LOCAL_GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define LOCAL_GL_SPARE1_NV 0x852F -#define LOCAL_GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 -#define LOCAL_GL_SPARSE_STORAGE_BIT_ARB 0x0400 -#define LOCAL_GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -#define LOCAL_GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9 -#define LOCAL_GL_SPECULAR 0x1202 -#define LOCAL_GL_SPHERE_MAP 0x2402 -#define LOCAL_GL_SPIR_V_BINARY_ARB 0x9552 -#define LOCAL_GL_SPOT_CUTOFF 0x1206 -#define LOCAL_GL_SPOT_DIRECTION 0x1204 -#define LOCAL_GL_SPOT_EXPONENT 0x1205 -#define LOCAL_GL_SPRITE_AXIAL_SGIX 0x814C -#define LOCAL_GL_SPRITE_AXIS_SGIX 0x814A -#define LOCAL_GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#define LOCAL_GL_SPRITE_MODE_SGIX 0x8149 -#define LOCAL_GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define LOCAL_GL_SPRITE_SGIX 0x8148 -#define LOCAL_GL_SPRITE_TRANSLATION_SGIX 0x814B -#define LOCAL_GL_SQUARE_NV 0x90A3 -#define LOCAL_GL_SR8_EXT 0x8FBD -#define LOCAL_GL_SRC0_ALPHA 0x8588 -#define LOCAL_GL_SRC0_RGB 0x8580 -#define LOCAL_GL_SRC1_ALPHA 0x8589 -#define LOCAL_GL_SRC1_ALPHA_EXT 0x8589 -#define LOCAL_GL_SRC1_COLOR 0x88F9 -#define LOCAL_GL_SRC1_COLOR_EXT 0x88F9 -#define LOCAL_GL_SRC1_RGB 0x8581 -#define LOCAL_GL_SRC2_ALPHA 0x858A -#define LOCAL_GL_SRC2_RGB 0x8582 -#define LOCAL_GL_SRC_ALPHA 0x0302 -#define LOCAL_GL_SRC_ALPHA_SATURATE 0x0308 -#define LOCAL_GL_SRC_ALPHA_SATURATE_EXT 0x0308 -#define LOCAL_GL_SRC_ATOP_NV 0x928E -#define LOCAL_GL_SRC_COLOR 0x0300 -#define LOCAL_GL_SRC_IN_NV 0x928A -#define LOCAL_GL_SRC_NV 0x9286 -#define LOCAL_GL_SRC_OUT_NV 0x928C -#define LOCAL_GL_SRC_OVER_NV 0x9288 -#define LOCAL_GL_SRG8_EXT 0x8FBE -#define LOCAL_GL_SRGB 0x8C40 -#define LOCAL_GL_SRGB8 0x8C41 -#define LOCAL_GL_SRGB8_ALPHA8 0x8C43 -#define LOCAL_GL_SRGB8_ALPHA8_EXT 0x8C43 -#define LOCAL_GL_SRGB8_EXT 0x8C41 -#define LOCAL_GL_SRGB8_NV 0x8C41 -#define LOCAL_GL_SRGB_ALPHA 0x8C42 -#define LOCAL_GL_SRGB_ALPHA_EXT 0x8C42 -#define LOCAL_GL_SRGB_DECODE_ARB 0x8299 -#define LOCAL_GL_SRGB_EXT 0x8C40 -#define LOCAL_GL_SRGB_READ 0x8297 -#define LOCAL_GL_SRGB_WRITE 0x8298 -#define LOCAL_GL_STACK_OVERFLOW 0x0503 -#define LOCAL_GL_STACK_OVERFLOW_KHR 0x0503 -#define LOCAL_GL_STACK_UNDERFLOW 0x0504 -#define LOCAL_GL_STACK_UNDERFLOW_KHR 0x0504 -#define LOCAL_GL_STANDARD_FONT_FORMAT_NV 0x936C -#define LOCAL_GL_STANDARD_FONT_NAME_NV 0x9072 -#define LOCAL_GL_STATE_RESTORE 0x8BDC -#define LOCAL_GL_STATIC_ATI 0x8760 -#define LOCAL_GL_STATIC_COPY 0x88E6 -#define LOCAL_GL_STATIC_COPY_ARB 0x88E6 -#define LOCAL_GL_STATIC_DRAW 0x88E4 -#define LOCAL_GL_STATIC_DRAW_ARB 0x88E4 -#define LOCAL_GL_STATIC_READ 0x88E5 -#define LOCAL_GL_STATIC_READ_ARB 0x88E5 -#define LOCAL_GL_STATIC_VERTEX_ARRAY_IBM 103061 -#define LOCAL_GL_STENCIL 0x1802 -#define LOCAL_GL_STENCIL_ATTACHMENT 0x8D20 -#define LOCAL_GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define LOCAL_GL_STENCIL_ATTACHMENT_OES 0x8D20 -#define LOCAL_GL_STENCIL_BACK_FAIL 0x8801 -#define LOCAL_GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define LOCAL_GL_STENCIL_BACK_FUNC 0x8800 -#define LOCAL_GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define LOCAL_GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#define LOCAL_GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define LOCAL_GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define LOCAL_GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define LOCAL_GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#define LOCAL_GL_STENCIL_BACK_REF 0x8CA3 -#define LOCAL_GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define LOCAL_GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define LOCAL_GL_STENCIL_BITS 0x0D57 -#define LOCAL_GL_STENCIL_BUFFER_BIT 0x00000400 -#define LOCAL_GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define LOCAL_GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define LOCAL_GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define LOCAL_GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define LOCAL_GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define LOCAL_GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define LOCAL_GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define LOCAL_GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define LOCAL_GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#define LOCAL_GL_STENCIL_CLEAR_VALUE 0x0B91 -#define LOCAL_GL_STENCIL_COMPONENTS 0x8285 -#define LOCAL_GL_STENCIL_EXT 0x1802 -#define LOCAL_GL_STENCIL_FAIL 0x0B94 -#define LOCAL_GL_STENCIL_FUNC 0x0B92 -#define LOCAL_GL_STENCIL_INDEX 0x1901 -#define LOCAL_GL_STENCIL_INDEX1 0x8D46 -#define LOCAL_GL_STENCIL_INDEX16 0x8D49 -#define LOCAL_GL_STENCIL_INDEX16_EXT 0x8D49 -#define LOCAL_GL_STENCIL_INDEX1_EXT 0x8D46 -#define LOCAL_GL_STENCIL_INDEX1_OES 0x8D46 -#define LOCAL_GL_STENCIL_INDEX4 0x8D47 -#define LOCAL_GL_STENCIL_INDEX4_EXT 0x8D47 -#define LOCAL_GL_STENCIL_INDEX4_OES 0x8D47 -#define LOCAL_GL_STENCIL_INDEX8 0x8D48 -#define LOCAL_GL_STENCIL_INDEX8_EXT 0x8D48 -#define LOCAL_GL_STENCIL_INDEX8_OES 0x8D48 -#define LOCAL_GL_STENCIL_INDEX_OES 0x1901 -#define LOCAL_GL_STENCIL_OP_VALUE_AMD 0x874C -#define LOCAL_GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define LOCAL_GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define LOCAL_GL_STENCIL_REF 0x0B97 -#define LOCAL_GL_STENCIL_REF_COMMAND_NV 0x000C -#define LOCAL_GL_STENCIL_RENDERABLE 0x8288 -#define LOCAL_GL_STENCIL_SAMPLES_NV 0x932E -#define LOCAL_GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define LOCAL_GL_STENCIL_TEST 0x0B90 -#define LOCAL_GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define LOCAL_GL_STENCIL_VALUE_MASK 0x0B93 -#define LOCAL_GL_STENCIL_WRITEMASK 0x0B98 -#define LOCAL_GL_STEREO 0x0C33 -#define LOCAL_GL_STORAGE_CACHED_APPLE 0x85BE -#define LOCAL_GL_STORAGE_CLIENT_APPLE 0x85B4 -#define LOCAL_GL_STORAGE_PRIVATE_APPLE 0x85BD -#define LOCAL_GL_STORAGE_SHARED_APPLE 0x85BF -#define LOCAL_GL_STREAM_COPY 0x88E2 -#define LOCAL_GL_STREAM_COPY_ARB 0x88E2 -#define LOCAL_GL_STREAM_DRAW 0x88E0 -#define LOCAL_GL_STREAM_DRAW_ARB 0x88E0 -#define LOCAL_GL_STREAM_RASTERIZATION_AMD 0x91A0 -#define LOCAL_GL_STREAM_READ 0x88E1 -#define LOCAL_GL_STREAM_READ_ARB 0x88E1 -#define LOCAL_GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define LOCAL_GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define LOCAL_GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define LOCAL_GL_SUBPIXEL_BITS 0x0D50 -#define LOCAL_GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 -#define LOCAL_GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 -#define LOCAL_GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#define LOCAL_GL_SUBTRACT 0x84E7 -#define LOCAL_GL_SUBTRACT_ARB 0x84E7 -#define LOCAL_GL_SUB_ATI 0x8965 -#define LOCAL_GL_SUCCESS_NV 0x902F -#define LOCAL_GL_SUPERSAMPLE_SCALE_X_NV 0x9372 -#define LOCAL_GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 -#define LOCAL_GL_SURFACE_MAPPED_NV 0x8700 -#define LOCAL_GL_SURFACE_REGISTERED_NV 0x86FD -#define LOCAL_GL_SURFACE_STATE_NV 0x86EB -#define LOCAL_GL_SWIZZLE_STQ_ATI 0x8977 -#define LOCAL_GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define LOCAL_GL_SWIZZLE_STRQ_ATI 0x897A -#define LOCAL_GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define LOCAL_GL_SWIZZLE_STR_ATI 0x8976 -#define LOCAL_GL_SWIZZLE_STR_DR_ATI 0x8978 -#define LOCAL_GL_SYNC_CL_EVENT_ARB 0x8240 -#define LOCAL_GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#define LOCAL_GL_SYNC_CONDITION 0x9113 -#define LOCAL_GL_SYNC_CONDITION_APPLE 0x9113 -#define LOCAL_GL_SYNC_FENCE 0x9116 -#define LOCAL_GL_SYNC_FENCE_APPLE 0x9116 -#define LOCAL_GL_SYNC_FLAGS 0x9115 -#define LOCAL_GL_SYNC_FLAGS_APPLE 0x9115 -#define LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 -#define LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 -#define LOCAL_GL_SYNC_OBJECT_APPLE 0x8A53 -#define LOCAL_GL_SYNC_STATUS 0x9114 -#define LOCAL_GL_SYNC_STATUS_APPLE 0x9114 -#define LOCAL_GL_SYNC_X11_FENCE_EXT 0x90E1 -#define LOCAL_GL_SYSTEM_FONT_NAME_NV 0x9073 -#define LOCAL_GL_T 0x2001 -#define LOCAL_GL_T2F_C3F_V3F 0x2A2A -#define LOCAL_GL_T2F_C4F_N3F_V3F 0x2A2C -#define LOCAL_GL_T2F_C4UB_V3F 0x2A29 -#define LOCAL_GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define LOCAL_GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#define LOCAL_GL_T2F_IUI_V2F_EXT 0x81B1 -#define LOCAL_GL_T2F_IUI_V3F_EXT 0x81B2 -#define LOCAL_GL_T2F_N3F_V3F 0x2A2B -#define LOCAL_GL_T2F_V3F 0x2A27 -#define LOCAL_GL_T4F_C4F_N3F_V4F 0x2A2D -#define LOCAL_GL_T4F_V4F 0x2A28 -#define LOCAL_GL_TABLE_TOO_LARGE 0x8031 -#define LOCAL_GL_TABLE_TOO_LARGE_EXT 0x8031 -#define LOCAL_GL_TANGENT_ARRAY_EXT 0x8439 -#define LOCAL_GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define LOCAL_GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define LOCAL_GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define LOCAL_GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 -#define LOCAL_GL_TESSELLATION_FACTOR_AMD 0x9005 -#define LOCAL_GL_TESSELLATION_MODE_AMD 0x9004 -#define LOCAL_GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define LOCAL_GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75 -#define LOCAL_GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75 -#define LOCAL_GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define LOCAL_GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define LOCAL_GL_TESS_CONTROL_SHADER 0x8E88 -#define LOCAL_GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define LOCAL_GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008 -#define LOCAL_GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008 -#define LOCAL_GL_TESS_CONTROL_SHADER_EXT 0x8E88 -#define LOCAL_GL_TESS_CONTROL_SHADER_OES 0x8E88 -#define LOCAL_GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 -#define LOCAL_GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#define LOCAL_GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#define LOCAL_GL_TESS_CONTROL_TEXTURE 0x829C -#define LOCAL_GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define LOCAL_GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#define LOCAL_GL_TESS_EVALUATION_SHADER 0x8E87 -#define LOCAL_GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define LOCAL_GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010 -#define LOCAL_GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010 -#define LOCAL_GL_TESS_EVALUATION_SHADER_EXT 0x8E87 -#define LOCAL_GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 -#define LOCAL_GL_TESS_EVALUATION_SHADER_OES 0x8E87 -#define LOCAL_GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#define LOCAL_GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#define LOCAL_GL_TESS_EVALUATION_TEXTURE 0x829D -#define LOCAL_GL_TESS_GEN_MODE 0x8E76 -#define LOCAL_GL_TESS_GEN_MODE_EXT 0x8E76 -#define LOCAL_GL_TESS_GEN_MODE_OES 0x8E76 -#define LOCAL_GL_TESS_GEN_POINT_MODE 0x8E79 -#define LOCAL_GL_TESS_GEN_POINT_MODE_EXT 0x8E79 -#define LOCAL_GL_TESS_GEN_POINT_MODE_OES 0x8E79 -#define LOCAL_GL_TESS_GEN_SPACING 0x8E77 -#define LOCAL_GL_TESS_GEN_SPACING_EXT 0x8E77 -#define LOCAL_GL_TESS_GEN_SPACING_OES 0x8E77 -#define LOCAL_GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define LOCAL_GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78 -#define LOCAL_GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78 -#define LOCAL_GL_TEXCOORD1_BIT_PGI 0x10000000 -#define LOCAL_GL_TEXCOORD2_BIT_PGI 0x20000000 -#define LOCAL_GL_TEXCOORD3_BIT_PGI 0x40000000 -#define LOCAL_GL_TEXCOORD4_BIT_PGI 0x80000000 -#define LOCAL_GL_TEXTURE 0x1702 -#define LOCAL_GL_TEXTURE0 0x84C0 -#define LOCAL_GL_TEXTURE0_ARB 0x84C0 -#define LOCAL_GL_TEXTURE1 0x84C1 -#define LOCAL_GL_TEXTURE10 0x84CA -#define LOCAL_GL_TEXTURE10_ARB 0x84CA -#define LOCAL_GL_TEXTURE11 0x84CB -#define LOCAL_GL_TEXTURE11_ARB 0x84CB -#define LOCAL_GL_TEXTURE12 0x84CC -#define LOCAL_GL_TEXTURE12_ARB 0x84CC -#define LOCAL_GL_TEXTURE13 0x84CD -#define LOCAL_GL_TEXTURE13_ARB 0x84CD -#define LOCAL_GL_TEXTURE14 0x84CE -#define LOCAL_GL_TEXTURE14_ARB 0x84CE -#define LOCAL_GL_TEXTURE15 0x84CF -#define LOCAL_GL_TEXTURE15_ARB 0x84CF -#define LOCAL_GL_TEXTURE16 0x84D0 -#define LOCAL_GL_TEXTURE16_ARB 0x84D0 -#define LOCAL_GL_TEXTURE17 0x84D1 -#define LOCAL_GL_TEXTURE17_ARB 0x84D1 -#define LOCAL_GL_TEXTURE18 0x84D2 -#define LOCAL_GL_TEXTURE18_ARB 0x84D2 -#define LOCAL_GL_TEXTURE19 0x84D3 -#define LOCAL_GL_TEXTURE19_ARB 0x84D3 -#define LOCAL_GL_TEXTURE1_ARB 0x84C1 -#define LOCAL_GL_TEXTURE2 0x84C2 -#define LOCAL_GL_TEXTURE20 0x84D4 -#define LOCAL_GL_TEXTURE20_ARB 0x84D4 -#define LOCAL_GL_TEXTURE21 0x84D5 -#define LOCAL_GL_TEXTURE21_ARB 0x84D5 -#define LOCAL_GL_TEXTURE22 0x84D6 -#define LOCAL_GL_TEXTURE22_ARB 0x84D6 -#define LOCAL_GL_TEXTURE23 0x84D7 -#define LOCAL_GL_TEXTURE23_ARB 0x84D7 -#define LOCAL_GL_TEXTURE24 0x84D8 -#define LOCAL_GL_TEXTURE24_ARB 0x84D8 -#define LOCAL_GL_TEXTURE25 0x84D9 -#define LOCAL_GL_TEXTURE25_ARB 0x84D9 -#define LOCAL_GL_TEXTURE26 0x84DA -#define LOCAL_GL_TEXTURE26_ARB 0x84DA -#define LOCAL_GL_TEXTURE27 0x84DB -#define LOCAL_GL_TEXTURE27_ARB 0x84DB -#define LOCAL_GL_TEXTURE28 0x84DC -#define LOCAL_GL_TEXTURE28_ARB 0x84DC -#define LOCAL_GL_TEXTURE29 0x84DD -#define LOCAL_GL_TEXTURE29_ARB 0x84DD -#define LOCAL_GL_TEXTURE2_ARB 0x84C2 -#define LOCAL_GL_TEXTURE3 0x84C3 -#define LOCAL_GL_TEXTURE30 0x84DE -#define LOCAL_GL_TEXTURE30_ARB 0x84DE -#define LOCAL_GL_TEXTURE31 0x84DF -#define LOCAL_GL_TEXTURE31_ARB 0x84DF -#define LOCAL_GL_TEXTURE3_ARB 0x84C3 -#define LOCAL_GL_TEXTURE4 0x84C4 -#define LOCAL_GL_TEXTURE4_ARB 0x84C4 -#define LOCAL_GL_TEXTURE5 0x84C5 -#define LOCAL_GL_TEXTURE5_ARB 0x84C5 -#define LOCAL_GL_TEXTURE6 0x84C6 -#define LOCAL_GL_TEXTURE6_ARB 0x84C6 -#define LOCAL_GL_TEXTURE7 0x84C7 -#define LOCAL_GL_TEXTURE7_ARB 0x84C7 -#define LOCAL_GL_TEXTURE8 0x84C8 -#define LOCAL_GL_TEXTURE8_ARB 0x84C8 -#define LOCAL_GL_TEXTURE9 0x84C9 -#define LOCAL_GL_TEXTURE9_ARB 0x84C9 -#define LOCAL_GL_TEXTURE_1D 0x0DE0 -#define LOCAL_GL_TEXTURE_1D_ARRAY 0x8C18 -#define LOCAL_GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define LOCAL_GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define LOCAL_GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define LOCAL_GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define LOCAL_GL_TEXTURE_2D 0x0DE1 -#define LOCAL_GL_TEXTURE_2D_ARRAY 0x8C1A -#define LOCAL_GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define LOCAL_GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define LOCAL_GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define LOCAL_GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define LOCAL_GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102 -#define LOCAL_GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#define LOCAL_GL_TEXTURE_2D_STACK_MESAX 0x875A -#define LOCAL_GL_TEXTURE_3D 0x806F -#define LOCAL_GL_TEXTURE_3D_BINDING_EXT 0x806A -#define LOCAL_GL_TEXTURE_3D_BINDING_OES 0x806A -#define LOCAL_GL_TEXTURE_3D_EXT 0x806F -#define LOCAL_GL_TEXTURE_3D_OES 0x806F -#define LOCAL_GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define LOCAL_GL_TEXTURE_4D_BINDING_SGIS 0x814F -#define LOCAL_GL_TEXTURE_4D_SGIS 0x8134 -#define LOCAL_GL_TEXTURE_ALPHA_MODULATE_IMG 0x8C06 -#define LOCAL_GL_TEXTURE_ALPHA_SIZE 0x805F -#define LOCAL_GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define LOCAL_GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define LOCAL_GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define LOCAL_GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define LOCAL_GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69 -#define LOCAL_GL_TEXTURE_BASE_LEVEL 0x813C -#define LOCAL_GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define LOCAL_GL_TEXTURE_BINDING_1D 0x8068 -#define LOCAL_GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define LOCAL_GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define LOCAL_GL_TEXTURE_BINDING_2D 0x8069 -#define LOCAL_GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define LOCAL_GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define LOCAL_GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define LOCAL_GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define LOCAL_GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105 -#define LOCAL_GL_TEXTURE_BINDING_3D 0x806A -#define LOCAL_GL_TEXTURE_BINDING_3D_OES 0x806A -#define LOCAL_GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define LOCAL_GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define LOCAL_GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define LOCAL_GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define LOCAL_GL_TEXTURE_BINDING_CUBE_MAP_OES 0x8514 -#define LOCAL_GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define LOCAL_GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define LOCAL_GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define LOCAL_GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define LOCAL_GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define LOCAL_GL_TEXTURE_BIT 0x00040000 -#define LOCAL_GL_TEXTURE_BLUE_SIZE 0x805E -#define LOCAL_GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define LOCAL_GL_TEXTURE_BLUE_TYPE 0x8C12 -#define LOCAL_GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define LOCAL_GL_TEXTURE_BORDER 0x1005 -#define LOCAL_GL_TEXTURE_BORDER_COLOR 0x1004 -#define LOCAL_GL_TEXTURE_BORDER_COLOR_EXT 0x1004 -#define LOCAL_GL_TEXTURE_BORDER_COLOR_NV 0x1004 -#define LOCAL_GL_TEXTURE_BORDER_COLOR_OES 0x1004 -#define LOCAL_GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define LOCAL_GL_TEXTURE_BUFFER 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_ARB 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_BINDING 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define LOCAL_GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define LOCAL_GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define LOCAL_GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D -#define LOCAL_GL_TEXTURE_BUFFER_EXT 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#define LOCAL_GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#define LOCAL_GL_TEXTURE_BUFFER_OES 0x8C2A -#define LOCAL_GL_TEXTURE_BUFFER_OFFSET 0x919D -#define LOCAL_GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F -#define LOCAL_GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F -#define LOCAL_GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F -#define LOCAL_GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D -#define LOCAL_GL_TEXTURE_BUFFER_OFFSET_OES 0x919D -#define LOCAL_GL_TEXTURE_BUFFER_SIZE 0x919E -#define LOCAL_GL_TEXTURE_BUFFER_SIZE_EXT 0x919E -#define LOCAL_GL_TEXTURE_BUFFER_SIZE_OES 0x919E -#define LOCAL_GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define LOCAL_GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define LOCAL_GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define LOCAL_GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define LOCAL_GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define LOCAL_GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define LOCAL_GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#define LOCAL_GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define LOCAL_GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#define LOCAL_GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#define LOCAL_GL_TEXTURE_COMPARE_FUNC 0x884D -#define LOCAL_GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define LOCAL_GL_TEXTURE_COMPARE_FUNC_EXT 0x884D -#define LOCAL_GL_TEXTURE_COMPARE_MODE 0x884C -#define LOCAL_GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define LOCAL_GL_TEXTURE_COMPARE_MODE_EXT 0x884C -#define LOCAL_GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define LOCAL_GL_TEXTURE_COMPARE_SGIX 0x819A -#define LOCAL_GL_TEXTURE_COMPONENTS 0x1003 -#define LOCAL_GL_TEXTURE_COMPRESSED 0x86A1 -#define LOCAL_GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define LOCAL_GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 -#define LOCAL_GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 -#define LOCAL_GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 -#define LOCAL_GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define LOCAL_GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define LOCAL_GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define LOCAL_GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define LOCAL_GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#define LOCAL_GL_TEXTURE_COORD_ARRAY 0x8078 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define LOCAL_GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define LOCAL_GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define LOCAL_GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define LOCAL_GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define LOCAL_GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define LOCAL_GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define LOCAL_GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define LOCAL_GL_TEXTURE_COORD_NV 0x8C79 -#define LOCAL_GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define LOCAL_GL_TEXTURE_CROP_RECT_OES 0x8B9D -#define LOCAL_GL_TEXTURE_CUBE_MAP 0x8513 -#define LOCAL_GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define LOCAL_GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define LOCAL_GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define LOCAL_GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 -#define LOCAL_GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009 -#define LOCAL_GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES 0x8516 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES 0x8518 -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES 0x851A -#define LOCAL_GL_TEXTURE_CUBE_MAP_OES 0x8513 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES 0x8515 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES 0x8517 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES 0x8519 -#define LOCAL_GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#define LOCAL_GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define LOCAL_GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define LOCAL_GL_TEXTURE_DEPTH 0x8071 -#define LOCAL_GL_TEXTURE_DEPTH_EXT 0x8071 -#define LOCAL_GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define LOCAL_GL_TEXTURE_DEPTH_SIZE 0x884A -#define LOCAL_GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define LOCAL_GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define LOCAL_GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define LOCAL_GL_TEXTURE_DS_SIZE_NV 0x871D -#define LOCAL_GL_TEXTURE_DT_SIZE_NV 0x871E -#define LOCAL_GL_TEXTURE_ENV 0x2300 -#define LOCAL_GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#define LOCAL_GL_TEXTURE_ENV_COLOR 0x2201 -#define LOCAL_GL_TEXTURE_ENV_MODE 0x2200 -#define LOCAL_GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define LOCAL_GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define LOCAL_GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define LOCAL_GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#define LOCAL_GL_TEXTURE_FILTER_CONTROL 0x8500 -#define LOCAL_GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define LOCAL_GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define LOCAL_GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define LOCAL_GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define LOCAL_GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define LOCAL_GL_TEXTURE_GATHER 0x82A2 -#define LOCAL_GL_TEXTURE_GATHER_SHADOW 0x82A3 -#define LOCAL_GL_TEXTURE_GEN_MODE 0x2500 -#define LOCAL_GL_TEXTURE_GEN_MODE_OES 0x2500 -#define LOCAL_GL_TEXTURE_GEN_Q 0x0C63 -#define LOCAL_GL_TEXTURE_GEN_R 0x0C62 -#define LOCAL_GL_TEXTURE_GEN_S 0x0C60 -#define LOCAL_GL_TEXTURE_GEN_STR_OES 0x8D60 -#define LOCAL_GL_TEXTURE_GEN_T 0x0C61 -#define LOCAL_GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#define LOCAL_GL_TEXTURE_GREEN_SIZE 0x805D -#define LOCAL_GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define LOCAL_GL_TEXTURE_GREEN_TYPE 0x8C11 -#define LOCAL_GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define LOCAL_GL_TEXTURE_HEIGHT 0x1001 -#define LOCAL_GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define LOCAL_GL_TEXTURE_HI_SIZE_NV 0x871B -#define LOCAL_GL_TEXTURE_IMAGE_FORMAT 0x828F -#define LOCAL_GL_TEXTURE_IMAGE_TYPE 0x8290 -#define LOCAL_GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define LOCAL_GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#define LOCAL_GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F -#define LOCAL_GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -#define LOCAL_GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#define LOCAL_GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define LOCAL_GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define LOCAL_GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define LOCAL_GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define LOCAL_GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define LOCAL_GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define LOCAL_GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define LOCAL_GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define LOCAL_GL_TEXTURE_LIGHT_EXT 0x8350 -#define LOCAL_GL_TEXTURE_LOD_BIAS 0x8501 -#define LOCAL_GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#define LOCAL_GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#define LOCAL_GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define LOCAL_GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define LOCAL_GL_TEXTURE_LO_SIZE_NV 0x871C -#define LOCAL_GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define LOCAL_GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define LOCAL_GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define LOCAL_GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define LOCAL_GL_TEXTURE_MAG_FILTER 0x2800 -#define LOCAL_GL_TEXTURE_MAG_SIZE_NV 0x871F -#define LOCAL_GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define LOCAL_GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -#define LOCAL_GL_TEXTURE_MATRIX 0x0BA8 -#define LOCAL_GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F -#define LOCAL_GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define LOCAL_GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#define LOCAL_GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define LOCAL_GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define LOCAL_GL_TEXTURE_MAX_LEVEL 0x813D -#define LOCAL_GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#define LOCAL_GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#define LOCAL_GL_TEXTURE_MAX_LOD 0x813B -#define LOCAL_GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define LOCAL_GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF -#define LOCAL_GL_TEXTURE_MIN_FILTER 0x2801 -#define LOCAL_GL_TEXTURE_MIN_LOD 0x813A -#define LOCAL_GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define LOCAL_GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#define LOCAL_GL_TEXTURE_NORMAL_EXT 0x85AF -#define LOCAL_GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define LOCAL_GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define LOCAL_GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define LOCAL_GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#define LOCAL_GL_TEXTURE_PRIORITY 0x8066 -#define LOCAL_GL_TEXTURE_PRIORITY_EXT 0x8066 -#define LOCAL_GL_TEXTURE_PROTECTED_EXT 0x8BFA -#define LOCAL_GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define LOCAL_GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define LOCAL_GL_TEXTURE_RECTANGLE 0x84F5 -#define LOCAL_GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define LOCAL_GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define LOCAL_GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 -#define LOCAL_GL_TEXTURE_RED_SIZE 0x805C -#define LOCAL_GL_TEXTURE_RED_SIZE_EXT 0x805C -#define LOCAL_GL_TEXTURE_RED_TYPE 0x8C10 -#define LOCAL_GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define LOCAL_GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define LOCAL_GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define LOCAL_GL_TEXTURE_RESIDENT 0x8067 -#define LOCAL_GL_TEXTURE_RESIDENT_EXT 0x8067 -#define LOCAL_GL_TEXTURE_SAMPLES 0x9106 -#define LOCAL_GL_TEXTURE_SAMPLES_IMG 0x9136 -#define LOCAL_GL_TEXTURE_SHADER_NV 0x86DE -#define LOCAL_GL_TEXTURE_SHADOW 0x82A1 -#define LOCAL_GL_TEXTURE_SHARED_SIZE 0x8C3F -#define LOCAL_GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#define LOCAL_GL_TEXTURE_SPARSE_ARB 0x91A6 -#define LOCAL_GL_TEXTURE_SPARSE_EXT 0x91A6 -#define LOCAL_GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define LOCAL_GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define LOCAL_GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define LOCAL_GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#define LOCAL_GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define LOCAL_GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 -#define LOCAL_GL_TEXTURE_SWIZZLE_A 0x8E45 -#define LOCAL_GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define LOCAL_GL_TEXTURE_SWIZZLE_B 0x8E44 -#define LOCAL_GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define LOCAL_GL_TEXTURE_SWIZZLE_G 0x8E43 -#define LOCAL_GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define LOCAL_GL_TEXTURE_SWIZZLE_R 0x8E42 -#define LOCAL_GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#define LOCAL_GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#define LOCAL_GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define LOCAL_GL_TEXTURE_TARGET 0x1006 -#define LOCAL_GL_TEXTURE_TARGET_QCOM 0x8BDA -#define LOCAL_GL_TEXTURE_TILING_EXT 0x9580 -#define LOCAL_GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#define LOCAL_GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define LOCAL_GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#define LOCAL_GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define LOCAL_GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define LOCAL_GL_TEXTURE_USAGE_ANGLE 0x93A2 -#define LOCAL_GL_TEXTURE_VIEW 0x82B5 -#define LOCAL_GL_TEXTURE_VIEW_MIN_LAYER 0x82DD -#define LOCAL_GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD -#define LOCAL_GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD -#define LOCAL_GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB -#define LOCAL_GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB -#define LOCAL_GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB -#define LOCAL_GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE -#define LOCAL_GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE -#define LOCAL_GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE -#define LOCAL_GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC -#define LOCAL_GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC -#define LOCAL_GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC -#define LOCAL_GL_TEXTURE_WIDTH 0x1000 -#define LOCAL_GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define LOCAL_GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define LOCAL_GL_TEXTURE_WRAP_R 0x8072 -#define LOCAL_GL_TEXTURE_WRAP_R_EXT 0x8072 -#define LOCAL_GL_TEXTURE_WRAP_R_OES 0x8072 -#define LOCAL_GL_TEXTURE_WRAP_S 0x2802 -#define LOCAL_GL_TEXTURE_WRAP_T 0x2803 -#define LOCAL_GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#define LOCAL_GL_TILING_TYPES_EXT 0x9583 -#define LOCAL_GL_TIMEOUT_EXPIRED 0x911B -#define LOCAL_GL_TIMEOUT_EXPIRED_APPLE 0x911B -#define LOCAL_GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF -#define LOCAL_GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFF -#define LOCAL_GL_TIMESTAMP 0x8E28 -#define LOCAL_GL_TIMESTAMP_EXT 0x8E28 -#define LOCAL_GL_TIME_ELAPSED 0x88BF -#define LOCAL_GL_TIME_ELAPSED_EXT 0x88BF -#define LOCAL_GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#define LOCAL_GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#define LOCAL_GL_TRACE_ALL_BITS_MESA 0xFFFF -#define LOCAL_GL_TRACE_ARRAYS_BIT_MESA 0x0004 -#define LOCAL_GL_TRACE_ERRORS_BIT_MESA 0x0020 -#define LOCAL_GL_TRACE_MASK_MESA 0x8755 -#define LOCAL_GL_TRACE_NAME_MESA 0x8756 -#define LOCAL_GL_TRACE_OPERATIONS_BIT_MESA 0x0001 -#define LOCAL_GL_TRACE_PIXELS_BIT_MESA 0x0010 -#define LOCAL_GL_TRACE_PRIMITIVES_BIT_MESA 0x0002 -#define LOCAL_GL_TRACE_TEXTURES_BIT_MESA 0x0008 -#define LOCAL_GL_TRACK_MATRIX_NV 0x8648 -#define LOCAL_GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define LOCAL_GL_TRANSFORM_BIT 0x00001000 -#define LOCAL_GL_TRANSFORM_FEEDBACK 0x8E22 -#define LOCAL_GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define LOCAL_GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define LOCAL_GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C -#define LOCAL_GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define LOCAL_GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC -#define LOCAL_GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define LOCAL_GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define LOCAL_GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define LOCAL_GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED -#define LOCAL_GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#define LOCAL_GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define LOCAL_GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define LOCAL_GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define LOCAL_GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define LOCAL_GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#define LOCAL_GL_TRANSFORM_HINT_APPLE 0x85B1 -#define LOCAL_GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 -#define LOCAL_GL_TRANSLATE_2D_NV 0x9090 -#define LOCAL_GL_TRANSLATE_3D_NV 0x9091 -#define LOCAL_GL_TRANSLATE_X_NV 0x908E -#define LOCAL_GL_TRANSLATE_Y_NV 0x908F -#define LOCAL_GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define LOCAL_GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define LOCAL_GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define LOCAL_GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#define LOCAL_GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define LOCAL_GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define LOCAL_GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define LOCAL_GL_TRANSPOSE_NV 0x862C -#define LOCAL_GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define LOCAL_GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define LOCAL_GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define LOCAL_GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define LOCAL_GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define LOCAL_GL_TRIANGLES 0x0004 -#define LOCAL_GL_TRIANGLES_ADJACENCY 0x000C -#define LOCAL_GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define LOCAL_GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define LOCAL_GL_TRIANGLES_ADJACENCY_OES 0x000C -#define LOCAL_GL_TRIANGLE_FAN 0x0006 -#define LOCAL_GL_TRIANGLE_LIST_SUN 0x81D7 -#define LOCAL_GL_TRIANGLE_MESH_SUN 0x8615 -#define LOCAL_GL_TRIANGLE_STRIP 0x0005 -#define LOCAL_GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define LOCAL_GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define LOCAL_GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define LOCAL_GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D -#define LOCAL_GL_TRIANGULAR_NV 0x90A5 -#define LOCAL_GL_TRUE 1 -#define LOCAL_GL_TYPE 0x92FA -#define LOCAL_GL_UNCORRELATED_NV 0x9282 -#define LOCAL_GL_UNDEFINED_APPLE 0x8A1C -#define LOCAL_GL_UNDEFINED_VERTEX 0x8260 -#define LOCAL_GL_UNDEFINED_VERTEX_EXT 0x8260 -#define LOCAL_GL_UNDEFINED_VERTEX_OES 0x8260 -#define LOCAL_GL_UNIFORM 0x92E1 -#define LOCAL_GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A -#define LOCAL_GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define LOCAL_GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define LOCAL_GL_UNIFORM_BARRIER_BIT 0x00000004 -#define LOCAL_GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define LOCAL_GL_UNIFORM_BLOCK 0x92E2 -#define LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define LOCAL_GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define LOCAL_GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define LOCAL_GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define LOCAL_GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define LOCAL_GL_UNIFORM_BUFFER 0x8A11 -#define LOCAL_GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F -#define LOCAL_GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define LOCAL_GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#define LOCAL_GL_UNIFORM_BUFFER_EXT 0x8DEE -#define LOCAL_GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 -#define LOCAL_GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define LOCAL_GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define LOCAL_GL_UNIFORM_BUFFER_START 0x8A29 -#define LOCAL_GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E -#define LOCAL_GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define LOCAL_GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define LOCAL_GL_UNIFORM_NAME_LENGTH 0x8A39 -#define LOCAL_GL_UNIFORM_OFFSET 0x8A3B -#define LOCAL_GL_UNIFORM_SIZE 0x8A38 -#define LOCAL_GL_UNIFORM_TYPE 0x8A37 -#define LOCAL_GL_UNKNOWN_CONTEXT_RESET 0x8255 -#define LOCAL_GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define LOCAL_GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 -#define LOCAL_GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 -#define LOCAL_GL_UNPACK_ALIGNMENT 0x0CF5 -#define LOCAL_GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#define LOCAL_GL_UNPACK_CMYK_HINT_EXT 0x800F -#define LOCAL_GL_UNPACK_COLORSPACE_CONVERSION_WEBGL 0x9243 -#define LOCAL_GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define LOCAL_GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define LOCAL_GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define LOCAL_GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define LOCAL_GL_UNPACK_COMPRESSED_SIZE_SGIX 0x831A -#define LOCAL_GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define LOCAL_GL_UNPACK_FLIP_Y_WEBGL 0x9240 -#define LOCAL_GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define LOCAL_GL_UNPACK_IMAGE_HEIGHT 0x806E -#define LOCAL_GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define LOCAL_GL_UNPACK_LSB_FIRST 0x0CF1 -#define LOCAL_GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL 0x9241 -#define LOCAL_GL_UNPACK_RESAMPLE_OML 0x8985 -#define LOCAL_GL_UNPACK_RESAMPLE_SGIX 0x842F -#define LOCAL_GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#define LOCAL_GL_UNPACK_ROW_LENGTH 0x0CF2 -#define LOCAL_GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 -#define LOCAL_GL_UNPACK_SKIP_IMAGES 0x806D -#define LOCAL_GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define LOCAL_GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define LOCAL_GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 -#define LOCAL_GL_UNPACK_SKIP_ROWS 0x0CF3 -#define LOCAL_GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 -#define LOCAL_GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define LOCAL_GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define LOCAL_GL_UNPACK_SWAP_BYTES 0x0CF0 -#define LOCAL_GL_UNSIGNALED 0x9118 -#define LOCAL_GL_UNSIGNALED_APPLE 0x9118 -#define LOCAL_GL_UNSIGNED_BYTE 0x1401 -#define LOCAL_GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define LOCAL_GL_UNSIGNED_BYTE_2_3_3_REV_EXT 0x8362 -#define LOCAL_GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define LOCAL_GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define LOCAL_GL_UNSIGNED_IDENTITY_NV 0x8536 -#define LOCAL_GL_UNSIGNED_INT 0x1405 -#define LOCAL_GL_UNSIGNED_INT16_NV 0x8FF0 -#define LOCAL_GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define LOCAL_GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define LOCAL_GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define LOCAL_GL_UNSIGNED_INT64_AMD 0x8BC2 -#define LOCAL_GL_UNSIGNED_INT64_ARB 0x140F -#define LOCAL_GL_UNSIGNED_INT64_NV 0x140F -#define LOCAL_GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 -#define LOCAL_GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define LOCAL_GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 -#define LOCAL_GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define LOCAL_GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 -#define LOCAL_GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define LOCAL_GL_UNSIGNED_INT8_NV 0x8FEC -#define LOCAL_GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define LOCAL_GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define LOCAL_GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B -#define LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define LOCAL_GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define LOCAL_GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#define LOCAL_GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 -#define LOCAL_GL_UNSIGNED_INT_24_8 0x84FA -#define LOCAL_GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define LOCAL_GL_UNSIGNED_INT_24_8_MESA 0x8751 -#define LOCAL_GL_UNSIGNED_INT_24_8_NV 0x84FA -#define LOCAL_GL_UNSIGNED_INT_24_8_OES 0x84FA -#define LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#define LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E -#define LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define LOCAL_GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 -#define LOCAL_GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define LOCAL_GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV_EXT 0x8367 -#define LOCAL_GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define LOCAL_GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define LOCAL_GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define LOCAL_GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define LOCAL_GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define LOCAL_GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A -#define LOCAL_GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F -#define LOCAL_GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define LOCAL_GL_UNSIGNED_INT_VEC2 0x8DC6 -#define LOCAL_GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define LOCAL_GL_UNSIGNED_INT_VEC3 0x8DC7 -#define LOCAL_GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define LOCAL_GL_UNSIGNED_INT_VEC4 0x8DC8 -#define LOCAL_GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define LOCAL_GL_UNSIGNED_INVERT_NV 0x8537 -#define LOCAL_GL_UNSIGNED_NORMALIZED 0x8C17 -#define LOCAL_GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define LOCAL_GL_UNSIGNED_NORMALIZED_EXT 0x8C17 -#define LOCAL_GL_UNSIGNED_SHORT 0x1403 -#define LOCAL_GL_UNSIGNED_SHORT_15_1_MESA 0x8753 -#define LOCAL_GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 -#define LOCAL_GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define LOCAL_GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#define LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define LOCAL_GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define LOCAL_GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define LOCAL_GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define LOCAL_GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#define LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define LOCAL_GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define LOCAL_GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define LOCAL_GL_UNSIGNED_SHORT_5_6_5_EXT 0x8363 -#define LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV_EXT 0x8364 -#define LOCAL_GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define LOCAL_GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define LOCAL_GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#define LOCAL_GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define LOCAL_GL_UPPER_LEFT 0x8CA2 -#define LOCAL_GL_USE_MISSING_GLYPH_NV 0x90AA -#define LOCAL_GL_UTF16_NV 0x909B -#define LOCAL_GL_UTF8_NV 0x909A -#define LOCAL_GL_UUID_SIZE_EXT 16 -#define LOCAL_GL_V2F 0x2A20 -#define LOCAL_GL_V3F 0x2A21 -#define LOCAL_GL_VALIDATE_STATUS 0x8B83 -#define LOCAL_GL_VARIABLE_A_NV 0x8523 -#define LOCAL_GL_VARIABLE_B_NV 0x8524 -#define LOCAL_GL_VARIABLE_C_NV 0x8525 -#define LOCAL_GL_VARIABLE_D_NV 0x8526 -#define LOCAL_GL_VARIABLE_E_NV 0x8527 -#define LOCAL_GL_VARIABLE_F_NV 0x8528 -#define LOCAL_GL_VARIABLE_G_NV 0x8529 -#define LOCAL_GL_VARIANT_ARRAY_EXT 0x87E8 -#define LOCAL_GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define LOCAL_GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define LOCAL_GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define LOCAL_GL_VARIANT_DATATYPE_EXT 0x87E5 -#define LOCAL_GL_VARIANT_EXT 0x87C1 -#define LOCAL_GL_VARIANT_VALUE_EXT 0x87E4 -#define LOCAL_GL_VBO_FREE_MEMORY_ATI 0x87FB -#define LOCAL_GL_VECTOR_EXT 0x87BF -#define LOCAL_GL_VENDOR 0x1F00 -#define LOCAL_GL_VERSION 0x1F02 -#define LOCAL_GL_VERSION_ES_CL_1_0 1 -#define LOCAL_GL_VERSION_ES_CL_1_1 1 -#define LOCAL_GL_VERSION_ES_CM_1_1 1 -#define LOCAL_GL_VERTEX23_BIT_PGI 0x00000004 -#define LOCAL_GL_VERTEX4_BIT_PGI 0x00000008 -#define LOCAL_GL_VERTEX_ARRAY 0x8074 -#define LOCAL_GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define LOCAL_GL_VERTEX_ARRAY_BINDING 0x85B5 -#define LOCAL_GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#define LOCAL_GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -#define LOCAL_GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define LOCAL_GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define LOCAL_GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define LOCAL_GL_VERTEX_ARRAY_EXT 0x8074 -#define LOCAL_GL_VERTEX_ARRAY_KHR 0x8074 -#define LOCAL_GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define LOCAL_GL_VERTEX_ARRAY_LIST_IBM 103070 -#define LOCAL_GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define LOCAL_GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define LOCAL_GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 -#define LOCAL_GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define LOCAL_GL_VERTEX_ARRAY_POINTER 0x808E -#define LOCAL_GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define LOCAL_GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define LOCAL_GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define LOCAL_GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define LOCAL_GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define LOCAL_GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define LOCAL_GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#define LOCAL_GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define LOCAL_GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#define LOCAL_GL_VERTEX_ARRAY_SIZE 0x807A -#define LOCAL_GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define LOCAL_GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define LOCAL_GL_VERTEX_ARRAY_STRIDE 0x807C -#define LOCAL_GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define LOCAL_GL_VERTEX_ARRAY_TYPE 0x807B -#define LOCAL_GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define LOCAL_GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define LOCAL_GL_VERTEX_ATTRIB_BINDING 0x82D4 -#define LOCAL_GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define LOCAL_GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define LOCAL_GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define LOCAL_GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define LOCAL_GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define LOCAL_GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define LOCAL_GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define LOCAL_GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -#define LOCAL_GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define LOCAL_GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define LOCAL_GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 -#define LOCAL_GL_VERTEX_BINDING_BUFFER 0x8F4F -#define LOCAL_GL_VERTEX_BINDING_DIVISOR 0x82D6 -#define LOCAL_GL_VERTEX_BINDING_OFFSET 0x82D7 -#define LOCAL_GL_VERTEX_BINDING_STRIDE 0x82D8 -#define LOCAL_GL_VERTEX_BLEND_ARB 0x86A7 -#define LOCAL_GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define LOCAL_GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define LOCAL_GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 -#define LOCAL_GL_VERTEX_ID_NV 0x8C7B -#define LOCAL_GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 -#define LOCAL_GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#define LOCAL_GL_VERTEX_PRECLIP_SGIX 0x83EE -#define LOCAL_GL_VERTEX_PROGRAM_ARB 0x8620 -#define LOCAL_GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define LOCAL_GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8BB7 -#define LOCAL_GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8BB6 -#define LOCAL_GL_VERTEX_PROGRAM_CALLBACK_MESA 0x8BB5 -#define LOCAL_GL_VERTEX_PROGRAM_NV 0x8620 -#define LOCAL_GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define LOCAL_GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define LOCAL_GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define LOCAL_GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define LOCAL_GL_VERTEX_PROGRAM_POSITION_MESA 0x8BB4 -#define LOCAL_GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define LOCAL_GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define LOCAL_GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define LOCAL_GL_VERTEX_SHADER 0x8B31 -#define LOCAL_GL_VERTEX_SHADER_ARB 0x8B31 -#define LOCAL_GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define LOCAL_GL_VERTEX_SHADER_BIT 0x00000001 -#define LOCAL_GL_VERTEX_SHADER_BIT_EXT 0x00000001 -#define LOCAL_GL_VERTEX_SHADER_EXT 0x8780 -#define LOCAL_GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define LOCAL_GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define LOCAL_GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 -#define LOCAL_GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define LOCAL_GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define LOCAL_GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define LOCAL_GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define LOCAL_GL_VERTEX_SOURCE_ATI 0x8774 -#define LOCAL_GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define LOCAL_GL_VERTEX_STREAM0_ATI 0x876C -#define LOCAL_GL_VERTEX_STREAM1_ATI 0x876D -#define LOCAL_GL_VERTEX_STREAM2_ATI 0x876E -#define LOCAL_GL_VERTEX_STREAM3_ATI 0x876F -#define LOCAL_GL_VERTEX_STREAM4_ATI 0x8770 -#define LOCAL_GL_VERTEX_STREAM5_ATI 0x8771 -#define LOCAL_GL_VERTEX_STREAM6_ATI 0x8772 -#define LOCAL_GL_VERTEX_STREAM7_ATI 0x8773 -#define LOCAL_GL_VERTEX_SUBROUTINE 0x92E8 -#define LOCAL_GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#define LOCAL_GL_VERTEX_TEXTURE 0x829B -#define LOCAL_GL_VERTEX_WEIGHTING_EXT 0x8509 -#define LOCAL_GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define LOCAL_GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#define LOCAL_GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define LOCAL_GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define LOCAL_GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define LOCAL_GL_VERTICAL_LINE_TO_NV 0x08 -#define LOCAL_GL_VERTICES_SUBMITTED_ARB 0x82EE -#define LOCAL_GL_VIBRANCE_BIAS_NV 0x8719 -#define LOCAL_GL_VIBRANCE_SCALE_NV 0x8713 -#define LOCAL_GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define LOCAL_GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define LOCAL_GL_VIDEO_BUFFER_NV 0x9020 -#define LOCAL_GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define LOCAL_GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define LOCAL_GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define LOCAL_GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define LOCAL_GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define LOCAL_GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -#define LOCAL_GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define LOCAL_GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define LOCAL_GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define LOCAL_GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define LOCAL_GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define LOCAL_GL_VIEWPORT 0x0BA2 -#define LOCAL_GL_VIEWPORT_BIT 0x00000800 -#define LOCAL_GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define LOCAL_GL_VIEWPORT_BOUNDS_RANGE_EXT 0x825D -#define LOCAL_GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D -#define LOCAL_GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D -#define LOCAL_GL_VIEWPORT_COMMAND_NV 0x0010 -#define LOCAL_GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define LOCAL_GL_VIEWPORT_INDEX_PROVOKING_VERTEX_EXT 0x825F -#define LOCAL_GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F -#define LOCAL_GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F -#define LOCAL_GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C -#define LOCAL_GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D -#define LOCAL_GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E -#define LOCAL_GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define LOCAL_GL_VIEWPORT_SUBPIXEL_BITS_EXT 0x825C -#define LOCAL_GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C -#define LOCAL_GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C -#define LOCAL_GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 -#define LOCAL_GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 -#define LOCAL_GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 -#define LOCAL_GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 -#define LOCAL_GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 -#define LOCAL_GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 -#define LOCAL_GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 -#define LOCAL_GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 -#define LOCAL_GL_VIEWPORT_SWIZZLE_W_NV 0x935B -#define LOCAL_GL_VIEWPORT_SWIZZLE_X_NV 0x9358 -#define LOCAL_GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 -#define LOCAL_GL_VIEWPORT_SWIZZLE_Z_NV 0x935A -#define LOCAL_GL_VIEW_CLASS_128_BITS 0x82C4 -#define LOCAL_GL_VIEW_CLASS_16_BITS 0x82CA -#define LOCAL_GL_VIEW_CLASS_24_BITS 0x82C9 -#define LOCAL_GL_VIEW_CLASS_32_BITS 0x82C8 -#define LOCAL_GL_VIEW_CLASS_48_BITS 0x82C7 -#define LOCAL_GL_VIEW_CLASS_64_BITS 0x82C6 -#define LOCAL_GL_VIEW_CLASS_8_BITS 0x82CB -#define LOCAL_GL_VIEW_CLASS_96_BITS 0x82C5 -#define LOCAL_GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 -#define LOCAL_GL_VIEW_CLASS_BPTC_UNORM 0x82D2 -#define LOCAL_GL_VIEW_CLASS_RGTC1_RED 0x82D0 -#define LOCAL_GL_VIEW_CLASS_RGTC2_RG 0x82D1 -#define LOCAL_GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC -#define LOCAL_GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD -#define LOCAL_GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE -#define LOCAL_GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF -#define LOCAL_GL_VIEW_COMPATIBILITY_CLASS 0x82B6 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 -#define LOCAL_GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197 -#define LOCAL_GL_VIVIDLIGHT_NV 0x92A6 -#define LOCAL_GL_VOLATILE_APPLE 0x8A1A -#define LOCAL_GL_WAIT_FAILED 0x911D -#define LOCAL_GL_WAIT_FAILED_APPLE 0x911D -#define LOCAL_GL_WARPS_PER_SM_NV 0x933A -#define LOCAL_GL_WARP_SIZE_NV 0x9339 -#define LOCAL_GL_WEIGHTED_AVERAGE_ARB 0x9367 -#define LOCAL_GL_WEIGHT_ARRAY_ARB 0x86AD -#define LOCAL_GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define LOCAL_GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define LOCAL_GL_WEIGHT_ARRAY_BUFFER_BINDING_OES 0x889E -#define LOCAL_GL_WEIGHT_ARRAY_OES 0x86AD -#define LOCAL_GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define LOCAL_GL_WEIGHT_ARRAY_POINTER_OES 0x86AC -#define LOCAL_GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define LOCAL_GL_WEIGHT_ARRAY_SIZE_OES 0x86AB -#define LOCAL_GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define LOCAL_GL_WEIGHT_ARRAY_STRIDE_OES 0x86AA -#define LOCAL_GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define LOCAL_GL_WEIGHT_ARRAY_TYPE_OES 0x86A9 -#define LOCAL_GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define LOCAL_GL_WIDE_LINE_HINT_PGI 0x1A222 -#define LOCAL_GL_WINDOW_RECTANGLE_EXT 0x8F12 -#define LOCAL_GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 -#define LOCAL_GL_WRAP_BORDER_SUN 0x81D4 -#define LOCAL_GL_WRITEONLY_RENDERING_QCOM 0x8823 -#define LOCAL_GL_WRITE_DISCARD_NV 0x88BE -#define LOCAL_GL_WRITE_ONLY 0x88B9 -#define LOCAL_GL_WRITE_ONLY_ARB 0x88B9 -#define LOCAL_GL_WRITE_ONLY_OES 0x88B9 -#define LOCAL_GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define LOCAL_GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define LOCAL_GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define LOCAL_GL_W_EXT 0x87D8 -#define LOCAL_GL_XOR 0x1506 -#define LOCAL_GL_XOR_NV 0x1506 -#define LOCAL_GL_X_EXT 0x87D5 -#define LOCAL_GL_YCBAYCR8A_4224_NV 0x9032 -#define LOCAL_GL_YCBCR_422_APPLE 0x85B9 -#define LOCAL_GL_YCBCR_MESA 0x8757 -#define LOCAL_GL_YCBYCR8_422_NV 0x9031 -#define LOCAL_GL_YCRCBA_SGIX 0x8319 -#define LOCAL_GL_YCRCB_422_SGIX 0x81BB -#define LOCAL_GL_YCRCB_444_SGIX 0x81BC -#define LOCAL_GL_YCRCB_SGIX 0x8318 -#define LOCAL_GL_Y_EXT 0x87D6 -#define LOCAL_GL_Z400_BINARY_AMD 0x8740 -#define LOCAL_GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define LOCAL_GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define LOCAL_GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define LOCAL_GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define LOCAL_GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define LOCAL_GL_ZERO 0 -#define LOCAL_GL_ZERO_EXT 0x87DD -#define LOCAL_GL_ZERO_TO_ONE 0x935F -#define LOCAL_GL_ZOOM_X 0x0D16 -#define LOCAL_GL_ZOOM_Y 0x0D17 -#define LOCAL_GL_Z_EXT 0x87D7 - - -// EGL -#define LOCAL_EGL_ALPHA_FORMAT 0x3088 -#define LOCAL_EGL_ALPHA_FORMAT_NONPRE 0x308B -#define LOCAL_EGL_ALPHA_FORMAT_PRE 0x308C -#define LOCAL_EGL_ALPHA_MASK_SIZE 0x303E -#define LOCAL_EGL_ALPHA_SIZE 0x3021 -#define LOCAL_EGL_ALREADY_SIGNALED_NV 0x30EA -#define LOCAL_EGL_AUTO_STEREO_NV 0x3136 -#define LOCAL_EGL_BACK_BUFFER 0x3084 -#define LOCAL_EGL_BAD_ACCESS 0x3002 -#define LOCAL_EGL_BAD_ALLOC 0x3003 -#define LOCAL_EGL_BAD_ATTRIBUTE 0x3004 -#define LOCAL_EGL_BAD_CONFIG 0x3005 -#define LOCAL_EGL_BAD_CONTEXT 0x3006 -#define LOCAL_EGL_BAD_CURRENT_SURFACE 0x3007 -#define LOCAL_EGL_BAD_DEVICE_EXT 0x322B -#define LOCAL_EGL_BAD_DISPLAY 0x3008 -#define LOCAL_EGL_BAD_MATCH 0x3009 -#define LOCAL_EGL_BAD_NATIVE_PIXMAP 0x300A -#define LOCAL_EGL_BAD_NATIVE_WINDOW 0x300B -#define LOCAL_EGL_BAD_OUTPUT_LAYER_EXT 0x322D -#define LOCAL_EGL_BAD_OUTPUT_PORT_EXT 0x322E -#define LOCAL_EGL_BAD_PARAMETER 0x300C -#define LOCAL_EGL_BAD_STATE_KHR 0x321C -#define LOCAL_EGL_BAD_STREAM_KHR 0x321B -#define LOCAL_EGL_BAD_SURFACE 0x300D -#define LOCAL_EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define LOCAL_EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define LOCAL_EGL_BITMAP_ORIGIN_KHR 0x30C8 -#define LOCAL_EGL_BITMAP_PITCH_KHR 0x30C7 -#define LOCAL_EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC -#define LOCAL_EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB -#define LOCAL_EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA -#define LOCAL_EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD -#define LOCAL_EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 -#define LOCAL_EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 -#define LOCAL_EGL_BITMAP_POINTER_KHR 0x30C6 -#define LOCAL_EGL_BLUE_SIZE 0x3022 -#define LOCAL_EGL_BUFFER_AGE_EXT 0x313D -#define LOCAL_EGL_BUFFER_AGE_KHR 0x313D -#define LOCAL_EGL_BUFFER_COUNT_NV 0x321D -#define LOCAL_EGL_BUFFER_DESTROYED 0x3095 -#define LOCAL_EGL_BUFFER_PRESERVED 0x3094 -#define LOCAL_EGL_BUFFER_SIZE 0x3020 -#define LOCAL_EGL_CLIENT_APIS 0x308D -#define LOCAL_EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 -#define LOCAL_EGL_CL_EVENT_HANDLE 0x309C -#define LOCAL_EGL_CL_EVENT_HANDLE_KHR 0x309C -#define LOCAL_EGL_COLORSPACE 0x3087 -#define LOCAL_EGL_COLORSPACE_LINEAR 0x308A -#define LOCAL_EGL_COLORSPACE_sRGB 0x3089 -#define LOCAL_EGL_COLOR_ARGB_HI 0x8F73 -#define LOCAL_EGL_COLOR_BUFFER_TYPE 0x303F -#define LOCAL_EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 -#define LOCAL_EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A -#define LOCAL_EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B -#define LOCAL_EGL_COLOR_FORMAT_HI 0x8F70 -#define LOCAL_EGL_COLOR_RGBA_HI 0x8F72 -#define LOCAL_EGL_COLOR_RGB_HI 0x8F71 -#define LOCAL_EGL_COMPOSITOR_DROP_NEWEST_FRAME_EXT 0x3462 -#define LOCAL_EGL_COMPOSITOR_KEEP_NEWEST_FRAME_EXT 0x3463 -#define LOCAL_EGL_CONDITION_SATISFIED 0x30F6 -#define LOCAL_EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define LOCAL_EGL_CONDITION_SATISFIED_NV 0x30EC -#define LOCAL_EGL_CONFIG_CAVEAT 0x3027 -#define LOCAL_EGL_CONFIG_ID 0x3028 -#define LOCAL_EGL_CONFORMANT 0x3042 -#define LOCAL_EGL_CONFORMANT_KHR 0x3042 -#define LOCAL_EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E -#define LOCAL_EGL_CONSUMER_FRAME_KHR 0x3213 -#define LOCAL_EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 -#define LOCAL_EGL_CONSUMER_MAX_FRAME_HINT_NV 0x3338 -#define LOCAL_EGL_CONSUMER_METADATA_NV 0x3254 -#define LOCAL_EGL_CONTEXT_CLIENT_TYPE 0x3097 -#define LOCAL_EGL_CONTEXT_CLIENT_VERSION 0x3098 -#define LOCAL_EGL_CONTEXT_FLAGS_KHR 0x30FC -#define LOCAL_EGL_CONTEXT_LOST 0x300E -#define LOCAL_EGL_CONTEXT_MAJOR_VERSION 0x3098 -#define LOCAL_EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 -#define LOCAL_EGL_CONTEXT_MINOR_VERSION 0x30FB -#define LOCAL_EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define LOCAL_EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define LOCAL_EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#define LOCAL_EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 -#define LOCAL_EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define LOCAL_EGL_CONTEXT_OPENGL_DEBUG 0x31B0 -#define LOCAL_EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define LOCAL_EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 -#define LOCAL_EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define LOCAL_EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 -#define LOCAL_EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD -#define LOCAL_EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD -#define LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 -#define LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 -#define LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF -#define LOCAL_EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define LOCAL_EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define LOCAL_EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#define LOCAL_EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define LOCAL_EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 -#define LOCAL_EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 -#define LOCAL_EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 -#define LOCAL_EGL_CORE_NATIVE_ENGINE 0x305B -#define LOCAL_EGL_COVERAGE_BUFFERS_NV 0x30E0 -#define LOCAL_EGL_COVERAGE_SAMPLES_NV 0x30E1 -#define LOCAL_EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 -#define LOCAL_EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 -#define LOCAL_EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 -#define LOCAL_EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT 0x3360 -#define LOCAL_EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT 0x3361 -#define LOCAL_EGL_CUDA_DEVICE_NV 0x323A -#define LOCAL_EGL_CUDA_EVENT_HANDLE_NV 0x323B -#define LOCAL_EGL_D3D11_DEVICE_ANGLE 0x33A1 -#define LOCAL_EGL_D3D9_DEVICE_ANGLE 0x33A0 -#define LOCAL_EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 -#define LOCAL_EGL_DEBUG_CALLBACK_KHR 0x33B8 -#define LOCAL_EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9 -#define LOCAL_EGL_DEBUG_MSG_ERROR_KHR 0x33BA -#define LOCAL_EGL_DEBUG_MSG_INFO_KHR 0x33BC -#define LOCAL_EGL_DEBUG_MSG_WARN_KHR 0x33BB -#define LOCAL_EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) -#define LOCAL_EGL_DEPTH_ENCODING_NONE_NV 0 -#define LOCAL_EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 -#define LOCAL_EGL_DEPTH_ENCODING_NV 0x30E2 -#define LOCAL_EGL_DEPTH_SIZE 0x3025 -#define LOCAL_EGL_DEVICE_EXT 0x322C -#define LOCAL_EGL_DISCARD_SAMPLES_ARM 0x3286 -#define LOCAL_EGL_DISPLAY_SCALING 10000 -#define LOCAL_EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 -#define LOCAL_EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 -#define LOCAL_EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 -#define LOCAL_EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 -#define LOCAL_EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 -#define LOCAL_EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 -#define LOCAL_EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 -#define LOCAL_EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 -#define LOCAL_EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 -#define LOCAL_EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 -#define LOCAL_EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 -#define LOCAL_EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 -#define LOCAL_EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 -#define LOCAL_EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 -#define LOCAL_EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A -#define LOCAL_EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 -#define LOCAL_EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A -#define LOCAL_EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 -#define LOCAL_EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 -#define LOCAL_EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 -#define LOCAL_EGL_DONT_CARE EGL_CAST(EGLint,-1) -#define LOCAL_EGL_DRAW 0x3059 -#define LOCAL_EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 -#define LOCAL_EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 -#define LOCAL_EGL_DRM_BUFFER_MESA 0x31D3 -#define LOCAL_EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 -#define LOCAL_EGL_DRM_BUFFER_USE_MESA 0x31D1 -#define LOCAL_EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 -#define LOCAL_EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 -#define LOCAL_EGL_DRM_CONNECTOR_EXT 0x3236 -#define LOCAL_EGL_DRM_CRTC_EXT 0x3234 -#define LOCAL_EGL_DRM_DEVICE_FILE_EXT 0x3233 -#define LOCAL_EGL_DRM_PLANE_EXT 0x3235 -#define LOCAL_EGL_EXTENSIONS 0x3055 -#define LOCAL_EGL_EXTERNAL_REF_ID_EXT 0x3461 -#define LOCAL_EGL_FALSE 0 -#define LOCAL_EGL_FIXED_SIZE_ANGLE 0x3201 -#define LOCAL_EGL_FOREVER 0xFFFFFFFFFFFFFFFF -#define LOCAL_EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFF -#define LOCAL_EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFF -#define LOCAL_EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 -#define LOCAL_EGL_FORMAT_RGBA_8888_KHR 0x30C3 -#define LOCAL_EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 -#define LOCAL_EGL_FORMAT_RGB_565_KHR 0x30C1 -#define LOCAL_EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 -#define LOCAL_EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C -#define LOCAL_EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C -#define LOCAL_EGL_GL_COLORSPACE 0x309D -#define LOCAL_EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F -#define LOCAL_EGL_GL_COLORSPACE_BT2020_PQ_EXT 0x3340 -#define LOCAL_EGL_GL_COLORSPACE_DISPLAY_P3_EXT 0x3363 -#define LOCAL_EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362 -#define LOCAL_EGL_GL_COLORSPACE_KHR 0x309D -#define LOCAL_EGL_GL_COLORSPACE_LINEAR 0x308A -#define LOCAL_EGL_GL_COLORSPACE_LINEAR_KHR 0x308A -#define LOCAL_EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350 -#define LOCAL_EGL_GL_COLORSPACE_SRGB 0x3089 -#define LOCAL_EGL_GL_COLORSPACE_SRGB_KHR 0x3089 -#define LOCAL_EGL_GL_RENDERBUFFER 0x30B9 -#define LOCAL_EGL_GL_RENDERBUFFER_KHR 0x30B9 -#define LOCAL_EGL_GL_TEXTURE_2D 0x30B1 -#define LOCAL_EGL_GL_TEXTURE_2D_KHR 0x30B1 -#define LOCAL_EGL_GL_TEXTURE_3D 0x30B2 -#define LOCAL_EGL_GL_TEXTURE_3D_KHR 0x30B2 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 -#define LOCAL_EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 -#define LOCAL_EGL_GL_TEXTURE_LEVEL 0x30BC -#define LOCAL_EGL_GL_TEXTURE_LEVEL_KHR 0x30BC -#define LOCAL_EGL_GL_TEXTURE_ZOFFSET 0x30BD -#define LOCAL_EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD -#define LOCAL_EGL_GREEN_SIZE 0x3023 -#define LOCAL_EGL_HEIGHT 0x3056 -#define LOCAL_EGL_HORIZONTAL_RESOLUTION 0x3090 -#define LOCAL_EGL_IMAGE_PRESERVED 0x30D2 -#define LOCAL_EGL_IMAGE_PRESERVED_KHR 0x30D2 -#define LOCAL_EGL_INTEROP_BIT_KHR 0x0010 -#define LOCAL_EGL_ITU_REC2020_EXT 0x3281 -#define LOCAL_EGL_ITU_REC601_EXT 0x327F -#define LOCAL_EGL_ITU_REC709_EXT 0x3280 -#define LOCAL_EGL_LARGEST_PBUFFER 0x3058 -#define LOCAL_EGL_LEVEL 0x3029 -#define LOCAL_EGL_LINUX_DMA_BUF_EXT 0x3270 -#define LOCAL_EGL_LINUX_DRM_FOURCC_EXT 0x3271 -#define LOCAL_EGL_LOCK_SURFACE_BIT_KHR 0x0080 -#define LOCAL_EGL_LOCK_USAGE_HINT_KHR 0x30C5 -#define LOCAL_EGL_LOSE_CONTEXT_ON_RESET 0x31BF -#define LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF -#define LOCAL_EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define LOCAL_EGL_LOWER_LEFT_KHR 0x30CE -#define LOCAL_EGL_LUMINANCE_BUFFER 0x308F -#define LOCAL_EGL_LUMINANCE_SIZE 0x303D -#define LOCAL_EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 -#define LOCAL_EGL_MATCH_FORMAT_KHR 0x3043 -#define LOCAL_EGL_MATCH_NATIVE_PIXMAP 0x3041 -#define LOCAL_EGL_MAX_PBUFFER_HEIGHT 0x302A -#define LOCAL_EGL_MAX_PBUFFER_PIXELS 0x302B -#define LOCAL_EGL_MAX_PBUFFER_WIDTH 0x302C -#define LOCAL_EGL_MAX_STREAM_METADATA_BLOCKS_NV 0x3250 -#define LOCAL_EGL_MAX_STREAM_METADATA_BLOCK_SIZE_NV 0x3251 -#define LOCAL_EGL_MAX_STREAM_METADATA_TOTAL_SIZE_NV 0x3252 -#define LOCAL_EGL_MAX_SWAP_INTERVAL 0x303C -#define LOCAL_EGL_METADATA0_SIZE_NV 0x3255 -#define LOCAL_EGL_METADATA0_TYPE_NV 0x3259 -#define LOCAL_EGL_METADATA1_SIZE_NV 0x3256 -#define LOCAL_EGL_METADATA1_TYPE_NV 0x325A -#define LOCAL_EGL_METADATA2_SIZE_NV 0x3257 -#define LOCAL_EGL_METADATA2_TYPE_NV 0x325B -#define LOCAL_EGL_METADATA3_SIZE_NV 0x3258 -#define LOCAL_EGL_METADATA3_TYPE_NV 0x325C -#define LOCAL_EGL_METADATA_SCALING_EXT 50000 -#define LOCAL_EGL_MIN_SWAP_INTERVAL 0x303B -#define LOCAL_EGL_MIPMAP_LEVEL 0x3083 -#define LOCAL_EGL_MIPMAP_TEXTURE 0x3082 -#define LOCAL_EGL_MULTISAMPLE_RESOLVE 0x3099 -#define LOCAL_EGL_MULTISAMPLE_RESOLVE_BOX 0x309B -#define LOCAL_EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 -#define LOCAL_EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A -#define LOCAL_EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 -#define LOCAL_EGL_MUTABLE_RENDER_BUFFER_BIT_KHR 0x1000 -#define LOCAL_EGL_NATIVE_BUFFER_ANDROID 0x3140 -#define LOCAL_EGL_NATIVE_BUFFER_MULTIPLANE_SEPARATE_IMG 0x3105 -#define LOCAL_EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG 0x3106 -#define LOCAL_EGL_NATIVE_BUFFER_TIZEN 0x32A0 -#define LOCAL_EGL_NATIVE_BUFFER_USAGE_ANDROID 0x3143 -#define LOCAL_EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID 0x00000001 -#define LOCAL_EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID 0x00000002 -#define LOCAL_EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID 0x00000004 -#define LOCAL_EGL_NATIVE_PIXMAP_KHR 0x30B0 -#define LOCAL_EGL_NATIVE_RENDERABLE 0x302D -#define LOCAL_EGL_NATIVE_SURFACE_TIZEN 0x32A1 -#define LOCAL_EGL_NATIVE_VISUAL_ID 0x302E -#define LOCAL_EGL_NATIVE_VISUAL_TYPE 0x302F -#define LOCAL_EGL_NONE 0x3038 -#define LOCAL_EGL_NON_CONFORMANT_CONFIG 0x3051 -#define LOCAL_EGL_NOT_INITIALIZED 0x3001 -#define LOCAL_EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0) -#define LOCAL_EGL_NO_CONTEXT EGL_CAST(EGLContext,0) -#define LOCAL_EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0) -#define LOCAL_EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0) -#define LOCAL_EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR,-1) -#define LOCAL_EGL_NO_IMAGE EGL_CAST(EGLImage,0) -#define LOCAL_EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR,0) -#define LOCAL_EGL_NO_NATIVE_FENCE_FD_ANDROID -1 -#define LOCAL_EGL_NO_OUTPUT_LAYER_EXT EGL_CAST(EGLOutputLayerEXT,0) -#define LOCAL_EGL_NO_OUTPUT_PORT_EXT EGL_CAST(EGLOutputPortEXT,0) -#define LOCAL_EGL_NO_RESET_NOTIFICATION 0x31BE -#define LOCAL_EGL_NO_RESET_NOTIFICATION_EXT 0x31BE -#define LOCAL_EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define LOCAL_EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR,0) -#define LOCAL_EGL_NO_SURFACE EGL_CAST(EGLSurface,0) -#define LOCAL_EGL_NO_SYNC EGL_CAST(EGLSync,0) -#define LOCAL_EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR,0) -#define LOCAL_EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV,0) -#define LOCAL_EGL_NO_TEXTURE 0x305C -#define LOCAL_EGL_OBJECT_CONTEXT_KHR 0x33B2 -#define LOCAL_EGL_OBJECT_DISPLAY_KHR 0x33B1 -#define LOCAL_EGL_OBJECT_IMAGE_KHR 0x33B4 -#define LOCAL_EGL_OBJECT_STREAM_KHR 0x33B6 -#define LOCAL_EGL_OBJECT_SURFACE_KHR 0x33B3 -#define LOCAL_EGL_OBJECT_SYNC_KHR 0x33B5 -#define LOCAL_EGL_OBJECT_THREAD_KHR 0x33B0 -#define LOCAL_EGL_OPENGL_API 0x30A2 -#define LOCAL_EGL_OPENGL_BIT 0x0008 -#define LOCAL_EGL_OPENGL_ES2_BIT 0x0004 -#define LOCAL_EGL_OPENGL_ES3_BIT 0x00000040 -#define LOCAL_EGL_OPENGL_ES3_BIT_KHR 0x00000040 -#define LOCAL_EGL_OPENGL_ES_API 0x30A0 -#define LOCAL_EGL_OPENGL_ES_BIT 0x0001 -#define LOCAL_EGL_OPENMAX_IL_BIT_KHR 0x0020 -#define LOCAL_EGL_OPENVG_API 0x30A1 -#define LOCAL_EGL_OPENVG_BIT 0x0002 -#define LOCAL_EGL_OPENVG_IMAGE 0x3096 -#define LOCAL_EGL_OPENWF_DEVICE_ID_EXT 0x3237 -#define LOCAL_EGL_OPENWF_PIPELINE_ID_EXT 0x3238 -#define LOCAL_EGL_OPENWF_PORT_ID_EXT 0x3239 -#define LOCAL_EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 -#define LOCAL_EGL_PBUFFER_BIT 0x0001 -#define LOCAL_EGL_PBUFFER_IMAGE_BIT_TAO 0x0008 -#define LOCAL_EGL_PBUFFER_PALETTE_IMAGE_BIT_TAO 0x0010 -#define LOCAL_EGL_PENDING_FRAME_NV 0x3329 -#define LOCAL_EGL_PENDING_METADATA_NV 0x3328 -#define LOCAL_EGL_PIXEL_ASPECT_RATIO 0x3092 -#define LOCAL_EGL_PIXMAP_BIT 0x0002 -#define LOCAL_EGL_PLATFORM_ANDROID_KHR 0x3141 -#define LOCAL_EGL_PLATFORM_DEVICE_EXT 0x313F -#define LOCAL_EGL_PLATFORM_GBM_KHR 0x31D7 -#define LOCAL_EGL_PLATFORM_GBM_MESA 0x31D7 -#define LOCAL_EGL_PLATFORM_SURFACELESS_MESA 0x31DD -#define LOCAL_EGL_PLATFORM_WAYLAND_EXT 0x31D8 -#define LOCAL_EGL_PLATFORM_WAYLAND_KHR 0x31D8 -#define LOCAL_EGL_PLATFORM_X11_EXT 0x31D5 -#define LOCAL_EGL_PLATFORM_X11_KHR 0x31D5 -#define LOCAL_EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 -#define LOCAL_EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 -#define LOCAL_EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE -#define LOCAL_EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460 -#define LOCAL_EGL_PRODUCER_FRAME_KHR 0x3212 -#define LOCAL_EGL_PRODUCER_MAX_FRAME_HINT_NV 0x3337 -#define LOCAL_EGL_PRODUCER_METADATA_NV 0x3253 -#define LOCAL_EGL_PROTECTED_CONTENT_EXT 0x32C0 -#define LOCAL_EGL_READ 0x305A -#define LOCAL_EGL_READ_SURFACE_BIT_KHR 0x0001 -#define LOCAL_EGL_RECORDABLE_ANDROID 0x3142 -#define LOCAL_EGL_RED_SIZE 0x3024 -#define LOCAL_EGL_RENDERABLE_TYPE 0x3040 -#define LOCAL_EGL_RENDER_BUFFER 0x3086 -#define LOCAL_EGL_RGB_BUFFER 0x308E -#define LOCAL_EGL_SAMPLES 0x3031 -#define LOCAL_EGL_SAMPLE_BUFFERS 0x3032 -#define LOCAL_EGL_SAMPLE_RANGE_HINT_EXT 0x327C -#define LOCAL_EGL_SHARED_IMAGE_NOK 0x30DA -#define LOCAL_EGL_SIGNALED 0x30F2 -#define LOCAL_EGL_SIGNALED_KHR 0x30F2 -#define LOCAL_EGL_SIGNALED_NV 0x30E8 -#define LOCAL_EGL_SINGLE_BUFFER 0x3085 -#define LOCAL_EGL_SLOW_CONFIG 0x3050 -#define LOCAL_EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT 0x3345 -#define LOCAL_EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT 0x3346 -#define LOCAL_EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT 0x3343 -#define LOCAL_EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT 0x3344 -#define LOCAL_EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT 0x3341 -#define LOCAL_EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT 0x3342 -#define LOCAL_EGL_SMPTE2086_MAX_LUMINANCE_EXT 0x3349 -#define LOCAL_EGL_SMPTE2086_MIN_LUMINANCE_EXT 0x334A -#define LOCAL_EGL_SMPTE2086_WHITE_POINT_X_EXT 0x3347 -#define LOCAL_EGL_SMPTE2086_WHITE_POINT_Y_EXT 0x3348 -#define LOCAL_EGL_SOCKET_HANDLE_NV 0x324C -#define LOCAL_EGL_SOCKET_TYPE_INET_NV 0x324F -#define LOCAL_EGL_SOCKET_TYPE_NV 0x324D -#define LOCAL_EGL_SOCKET_TYPE_UNIX_NV 0x324E -#define LOCAL_EGL_STENCIL_SIZE 0x3026 -#define LOCAL_EGL_STREAM_BIT_KHR 0x0800 -#define LOCAL_EGL_STREAM_CONSUMER_NV 0x3248 -#define LOCAL_EGL_STREAM_CROSS_DISPLAY_NV 0x334E -#define LOCAL_EGL_STREAM_CROSS_OBJECT_NV 0x334D -#define LOCAL_EGL_STREAM_CROSS_PARTITION_NV 0x323F -#define LOCAL_EGL_STREAM_CROSS_PROCESS_NV 0x3245 -#define LOCAL_EGL_STREAM_CROSS_SYSTEM_NV 0x334F -#define LOCAL_EGL_STREAM_ENDPOINT_NV 0x3243 -#define LOCAL_EGL_STREAM_FIFO_LENGTH_KHR 0x31FC -#define LOCAL_EGL_STREAM_FIFO_SYNCHRONOUS_NV 0x3336 -#define LOCAL_EGL_STREAM_LOCAL_NV 0x3244 -#define LOCAL_EGL_STREAM_PRODUCER_NV 0x3247 -#define LOCAL_EGL_STREAM_PROTOCOL_FD_NV 0x3246 -#define LOCAL_EGL_STREAM_PROTOCOL_NV 0x3242 -#define LOCAL_EGL_STREAM_PROTOCOL_SOCKET_NV 0x324B -#define LOCAL_EGL_STREAM_STATE_CONNECTING_KHR 0x3216 -#define LOCAL_EGL_STREAM_STATE_CREATED_KHR 0x3215 -#define LOCAL_EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A -#define LOCAL_EGL_STREAM_STATE_EMPTY_KHR 0x3217 -#define LOCAL_EGL_STREAM_STATE_INITIALIZING_NV 0x3240 -#define LOCAL_EGL_STREAM_STATE_KHR 0x3214 -#define LOCAL_EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 -#define LOCAL_EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 -#define LOCAL_EGL_STREAM_TIME_CONSUMER_KHR 0x31FE -#define LOCAL_EGL_STREAM_TIME_NOW_KHR 0x31FD -#define LOCAL_EGL_STREAM_TIME_PENDING_NV 0x332A -#define LOCAL_EGL_STREAM_TIME_PRODUCER_KHR 0x31FF -#define LOCAL_EGL_STREAM_TYPE_NV 0x3241 -#define LOCAL_EGL_SUCCESS 0x3000 -#define LOCAL_EGL_SUPPORT_RESET_NV 0x3334 -#define LOCAL_EGL_SUPPORT_REUSE_NV 0x3335 -#define LOCAL_EGL_SURFACE_TYPE 0x3033 -#define LOCAL_EGL_SWAP_BEHAVIOR 0x3093 -#define LOCAL_EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 -#define LOCAL_EGL_SWAP_INTERVAL_EXT 0x322F -#define LOCAL_EGL_SYNC_CL_EVENT 0x30FE -#define LOCAL_EGL_SYNC_CL_EVENT_COMPLETE 0x30FF -#define LOCAL_EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF -#define LOCAL_EGL_SYNC_CL_EVENT_KHR 0x30FE -#define LOCAL_EGL_SYNC_CONDITION 0x30F8 -#define LOCAL_EGL_SYNC_CONDITION_KHR 0x30F8 -#define LOCAL_EGL_SYNC_CONDITION_NV 0x30EE -#define LOCAL_EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D -#define LOCAL_EGL_SYNC_CUDA_EVENT_NV 0x323C -#define LOCAL_EGL_SYNC_FENCE 0x30F9 -#define LOCAL_EGL_SYNC_FENCE_KHR 0x30F9 -#define LOCAL_EGL_SYNC_FENCE_NV 0x30EF -#define LOCAL_EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 -#define LOCAL_EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 -#define LOCAL_EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 -#define LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 -#define LOCAL_EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 -#define LOCAL_EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 -#define LOCAL_EGL_SYNC_NEW_FRAME_NV 0x321F -#define LOCAL_EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 -#define LOCAL_EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 -#define LOCAL_EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 -#define LOCAL_EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A -#define LOCAL_EGL_SYNC_REUSABLE_KHR 0x30FA -#define LOCAL_EGL_SYNC_STATUS 0x30F1 -#define LOCAL_EGL_SYNC_STATUS_KHR 0x30F1 -#define LOCAL_EGL_SYNC_STATUS_NV 0x30E7 -#define LOCAL_EGL_SYNC_TYPE 0x30F7 -#define LOCAL_EGL_SYNC_TYPE_KHR 0x30F7 -#define LOCAL_EGL_SYNC_TYPE_NV 0x30ED -#define LOCAL_EGL_TEXTURE_2D 0x305F -#define LOCAL_EGL_TEXTURE_FORMAT 0x3080 -#define LOCAL_EGL_TEXTURE_RGB 0x305D -#define LOCAL_EGL_TEXTURE_RGBA 0x305E -#define LOCAL_EGL_TEXTURE_TARGET 0x3081 -#define LOCAL_EGL_TIMEOUT_EXPIRED 0x30F5 -#define LOCAL_EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define LOCAL_EGL_TIMEOUT_EXPIRED_NV 0x30EB -#define LOCAL_EGL_TRACK_REFERENCES_KHR 0x3352 -#define LOCAL_EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define LOCAL_EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define LOCAL_EGL_TRANSPARENT_RED_VALUE 0x3037 -#define LOCAL_EGL_TRANSPARENT_RGB 0x3052 -#define LOCAL_EGL_TRANSPARENT_TYPE 0x3034 -#define LOCAL_EGL_TRUE 1 -#define LOCAL_EGL_UNKNOWN EGL_CAST(EGLint,-1) -#define LOCAL_EGL_UNSIGNALED 0x30F3 -#define LOCAL_EGL_UNSIGNALED_KHR 0x30F3 -#define LOCAL_EGL_UNSIGNALED_NV 0x30E9 -#define LOCAL_EGL_UPPER_LEFT_KHR 0x30CF -#define LOCAL_EGL_VENDOR 0x3053 -#define LOCAL_EGL_VERSION 0x3054 -#define LOCAL_EGL_VERTICAL_RESOLUTION 0x3091 -#define LOCAL_EGL_VG_ALPHA_FORMAT 0x3088 -#define LOCAL_EGL_VG_ALPHA_FORMAT_NONPRE 0x308B -#define LOCAL_EGL_VG_ALPHA_FORMAT_PRE 0x308C -#define LOCAL_EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 -#define LOCAL_EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 -#define LOCAL_EGL_VG_COLORSPACE 0x3087 -#define LOCAL_EGL_VG_COLORSPACE_LINEAR 0x308A -#define LOCAL_EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 -#define LOCAL_EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 -#define LOCAL_EGL_VG_COLORSPACE_sRGB 0x3089 -#define LOCAL_EGL_VG_PARENT_IMAGE_KHR 0x30BA -#define LOCAL_EGL_WIDTH 0x3057 -#define LOCAL_EGL_WINDOW_BIT 0x0004 -#define LOCAL_EGL_WRITE_SURFACE_BIT_KHR 0x0002 -#define LOCAL_EGL_YUV_BUFFER_EXT 0x3300 -#define LOCAL_EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D -#define LOCAL_EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 -#define LOCAL_EGL_YUV_CHROMA_SITING_0_EXT 0x3284 -#define LOCAL_EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E -#define LOCAL_EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B -#define LOCAL_EGL_YUV_CSC_STANDARD_2020_EXT 0x330D -#define LOCAL_EGL_YUV_CSC_STANDARD_601_EXT 0x330B -#define LOCAL_EGL_YUV_CSC_STANDARD_709_EXT 0x330C -#define LOCAL_EGL_YUV_CSC_STANDARD_EXT 0x330A -#define LOCAL_EGL_YUV_DEPTH_RANGE_EXT 0x3317 -#define LOCAL_EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 -#define LOCAL_EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 -#define LOCAL_EGL_YUV_FULL_RANGE_EXT 0x3282 -#define LOCAL_EGL_YUV_NARROW_RANGE_EXT 0x3283 -#define LOCAL_EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 -#define LOCAL_EGL_YUV_ORDER_AYUV_EXT 0x3308 -#define LOCAL_EGL_YUV_ORDER_EXT 0x3301 -#define LOCAL_EGL_YUV_ORDER_UYVY_EXT 0x3305 -#define LOCAL_EGL_YUV_ORDER_VYUY_EXT 0x3307 -#define LOCAL_EGL_YUV_ORDER_YUV_EXT 0x3302 -#define LOCAL_EGL_YUV_ORDER_YUYV_EXT 0x3304 -#define LOCAL_EGL_YUV_ORDER_YVU_EXT 0x3303 -#define LOCAL_EGL_YUV_ORDER_YVYU_EXT 0x3306 -#define LOCAL_EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C -#define LOCAL_EGL_YUV_PLANE1_TEXTURE_UNIT_NV 0x332D -#define LOCAL_EGL_YUV_PLANE2_TEXTURE_UNIT_NV 0x332E -#define LOCAL_EGL_YUV_PLANE_BPP_0_EXT 0x331B -#define LOCAL_EGL_YUV_PLANE_BPP_10_EXT 0x331D -#define LOCAL_EGL_YUV_PLANE_BPP_8_EXT 0x331C -#define LOCAL_EGL_YUV_PLANE_BPP_EXT 0x331A -#define LOCAL_EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 -#define LOCAL_EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 -#define LOCAL_EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 -#define LOCAL_EGL_YUV_SUBSAMPLE_EXT 0x3312 -#define LOCAL_EGL_Y_INVERTED_NOK 0x307F - - -// GLX -#define LOCAL_GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -#define LOCAL_GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define LOCAL_GLX_ACCUM_ALPHA_SIZE 17 -#define LOCAL_GLX_ACCUM_BLUE_SIZE 16 -#define LOCAL_GLX_ACCUM_BUFFER_BIT 0x00000080 -#define LOCAL_GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define LOCAL_GLX_ACCUM_GREEN_SIZE 15 -#define LOCAL_GLX_ACCUM_RED_SIZE 14 -#define LOCAL_GLX_ALPHA_SIZE 11 -#define LOCAL_GLX_AUX0_EXT 0x20E2 -#define LOCAL_GLX_AUX1_EXT 0x20E3 -#define LOCAL_GLX_AUX2_EXT 0x20E4 -#define LOCAL_GLX_AUX3_EXT 0x20E5 -#define LOCAL_GLX_AUX4_EXT 0x20E6 -#define LOCAL_GLX_AUX5_EXT 0x20E7 -#define LOCAL_GLX_AUX6_EXT 0x20E8 -#define LOCAL_GLX_AUX7_EXT 0x20E9 -#define LOCAL_GLX_AUX8_EXT 0x20EA -#define LOCAL_GLX_AUX9_EXT 0x20EB -#define LOCAL_GLX_AUX_BUFFERS 7 -#define LOCAL_GLX_AUX_BUFFERS_BIT 0x00000010 -#define LOCAL_GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define LOCAL_GLX_BACK_BUFFER_AGE_EXT 0x20F4 -#define LOCAL_GLX_BACK_EXT 0x20E0 -#define LOCAL_GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define LOCAL_GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define LOCAL_GLX_BACK_LEFT_EXT 0x20E0 -#define LOCAL_GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define LOCAL_GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define LOCAL_GLX_BACK_RIGHT_EXT 0x20E1 -#define LOCAL_GLX_BAD_ATTRIBUTE 2 -#define LOCAL_GLX_BAD_CONTEXT 5 -#define LOCAL_GLX_BAD_ENUM 7 -#define LOCAL_GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define LOCAL_GLX_BAD_HYPERPIPE_SGIX 92 -#define LOCAL_GLX_BAD_SCREEN 1 -#define LOCAL_GLX_BAD_VALUE 6 -#define LOCAL_GLX_BAD_VISUAL 4 -#define LOCAL_GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define LOCAL_GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define LOCAL_GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define LOCAL_GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define LOCAL_GLX_BLENDED_RGBA_SGIS 0x8025 -#define LOCAL_GLX_BLUE_SIZE 10 -#define LOCAL_GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 -#define LOCAL_GLX_BUFFER_SIZE 2 -#define LOCAL_GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 -#define LOCAL_GLX_BufferSwapComplete 1 -#define LOCAL_GLX_COLOR_INDEX_BIT 0x00000002 -#define LOCAL_GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define LOCAL_GLX_COLOR_INDEX_TYPE 0x8015 -#define LOCAL_GLX_COLOR_INDEX_TYPE_SGIX 0x8015 -#define LOCAL_GLX_COLOR_SAMPLES_NV 0x20B3 -#define LOCAL_GLX_CONFIG_CAVEAT 0x20 -#define LOCAL_GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 -#define LOCAL_GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define LOCAL_GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define LOCAL_GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define LOCAL_GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#define LOCAL_GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 -#define LOCAL_GLX_CONTEXT_FLAGS_ARB 0x2094 -#define LOCAL_GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define LOCAL_GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define LOCAL_GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define LOCAL_GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 -#define LOCAL_GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define LOCAL_GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define LOCAL_GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 -#define LOCAL_GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 -#define LOCAL_GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 -#define LOCAL_GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define LOCAL_GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define LOCAL_GLX_COPY_COMPLETE_INTEL 0x8181 -#define LOCAL_GLX_COVERAGE_SAMPLES_NV 100001 -#define LOCAL_GLX_DAMAGED 0x8020 -#define LOCAL_GLX_DAMAGED_SGIX 0x8020 -#define LOCAL_GLX_DEPTH_BUFFER_BIT 0x00000020 -#define LOCAL_GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define LOCAL_GLX_DEPTH_SIZE 12 -#define LOCAL_GLX_DEVICE_ID_NV 0x20CD -#define LOCAL_GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 -#define LOCAL_GLX_DIRECT_COLOR 0x8003 -#define LOCAL_GLX_DIRECT_COLOR_EXT 0x8003 -#define LOCAL_GLX_DONT_CARE 0xFFFFFFFF -#define LOCAL_GLX_DOUBLEBUFFER 5 -#define LOCAL_GLX_DRAWABLE_TYPE 0x8010 -#define LOCAL_GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define LOCAL_GLX_EVENT_MASK 0x801F -#define LOCAL_GLX_EVENT_MASK_SGIX 0x801F -#define LOCAL_GLX_EXCHANGE_COMPLETE_INTEL 0x8180 -#define LOCAL_GLX_EXTENSIONS 0x3 -#define LOCAL_GLX_EXTENSION_NAME "GLX" -#define LOCAL_GLX_FBCONFIG_ID 0x8013 -#define LOCAL_GLX_FBCONFIG_ID_SGIX 0x8013 -#define LOCAL_GLX_FLIP_COMPLETE_INTEL 0x8182 -#define LOCAL_GLX_FLOAT_COMPONENTS_NV 0x20B0 -#define LOCAL_GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 -#define LOCAL_GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 -#define LOCAL_GLX_FRONT_EXT 0x20DE -#define LOCAL_GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define LOCAL_GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define LOCAL_GLX_FRONT_LEFT_EXT 0x20DE -#define LOCAL_GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define LOCAL_GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define LOCAL_GLX_FRONT_RIGHT_EXT 0x20DF -#define LOCAL_GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7 -#define LOCAL_GLX_GPU_CLOCK_AMD 0x21A4 -#define LOCAL_GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define LOCAL_GLX_GPU_NUM_PIPES_AMD 0x21A5 -#define LOCAL_GLX_GPU_NUM_RB_AMD 0x21A7 -#define LOCAL_GLX_GPU_NUM_SIMD_AMD 0x21A6 -#define LOCAL_GLX_GPU_NUM_SPI_AMD 0x21A8 -#define LOCAL_GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define LOCAL_GLX_GPU_RAM_AMD 0x21A3 -#define LOCAL_GLX_GPU_RENDERER_STRING_AMD 0x1F01 -#define LOCAL_GLX_GPU_VENDOR_AMD 0x1F00 -#define LOCAL_GLX_GRAY_SCALE 0x8006 -#define LOCAL_GLX_GRAY_SCALE_EXT 0x8006 -#define LOCAL_GLX_GREEN_SIZE 9 -#define LOCAL_GLX_HEIGHT 0x801E -#define LOCAL_GLX_HEIGHT_SGIX 0x801E -#define LOCAL_GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define LOCAL_GLX_HYPERPIPE_ID_SGIX 0x8030 -#define LOCAL_GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define LOCAL_GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define LOCAL_GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define LOCAL_GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define LOCAL_GLX_LARGEST_PBUFFER 0x801C -#define LOCAL_GLX_LARGEST_PBUFFER_SGIX 0x801C -#define LOCAL_GLX_LATE_SWAPS_TEAR_EXT 0x20F3 -#define LOCAL_GLX_LEVEL 3 -#define LOCAL_GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define LOCAL_GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define LOCAL_GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define LOCAL_GLX_MAX_PBUFFER_PIXELS 0x8018 -#define LOCAL_GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define LOCAL_GLX_MAX_PBUFFER_WIDTH 0x8016 -#define LOCAL_GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define LOCAL_GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 -#define LOCAL_GLX_MIPMAP_TEXTURE_EXT 0x20D7 -#define LOCAL_GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 -#define LOCAL_GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define LOCAL_GLX_NONE 0x8000 -#define LOCAL_GLX_NONE_EXT 0x8000 -#define LOCAL_GLX_NON_CONFORMANT_CONFIG 0x800D -#define LOCAL_GLX_NON_CONFORMANT_VISUAL_EXT 0x800D -#define LOCAL_GLX_NO_EXTENSION 3 -#define LOCAL_GLX_NO_RESET_NOTIFICATION_ARB 0x8261 -#define LOCAL_GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF -#define LOCAL_GLX_NUM_VIDEO_SLOTS_NV 0x20F0 -#define LOCAL_GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define LOCAL_GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define LOCAL_GLX_PBUFFER 0x8023 -#define LOCAL_GLX_PBUFFER_BIT 0x00000004 -#define LOCAL_GLX_PBUFFER_BIT_SGIX 0x00000004 -#define LOCAL_GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define LOCAL_GLX_PBUFFER_HEIGHT 0x8040 -#define LOCAL_GLX_PBUFFER_SGIX 0x8023 -#define LOCAL_GLX_PBUFFER_WIDTH 0x8041 -#define LOCAL_GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define LOCAL_GLX_PIPE_RECT_SGIX 0x00000001 -#define LOCAL_GLX_PIXMAP_BIT 0x00000002 -#define LOCAL_GLX_PIXMAP_BIT_SGIX 0x00000002 -#define LOCAL_GLX_PRESERVED_CONTENTS 0x801B -#define LOCAL_GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define LOCAL_GLX_PSEUDO_COLOR 0x8004 -#define LOCAL_GLX_PSEUDO_COLOR_EXT 0x8004 -#define LOCAL_GLX_PbufferClobber 0 -#define LOCAL_GLX_RED_SIZE 8 -#define LOCAL_GLX_RENDERER_ACCELERATED_MESA 0x8186 -#define LOCAL_GLX_RENDERER_DEVICE_ID_MESA 0x8184 -#define LOCAL_GLX_RENDERER_ID_MESA 0x818E -#define LOCAL_GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B -#define LOCAL_GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A -#define LOCAL_GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D -#define LOCAL_GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C -#define LOCAL_GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189 -#define LOCAL_GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188 -#define LOCAL_GLX_RENDERER_VENDOR_ID_MESA 0x8183 -#define LOCAL_GLX_RENDERER_VERSION_MESA 0x8185 -#define LOCAL_GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187 -#define LOCAL_GLX_RENDER_TYPE 0x8011 -#define LOCAL_GLX_RENDER_TYPE_SGIX 0x8011 -#define LOCAL_GLX_RGBA 4 -#define LOCAL_GLX_RGBA_BIT 0x00000001 -#define LOCAL_GLX_RGBA_BIT_SGIX 0x00000001 -#define LOCAL_GLX_RGBA_FLOAT_BIT_ARB 0x00000004 -#define LOCAL_GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 -#define LOCAL_GLX_RGBA_TYPE 0x8014 -#define LOCAL_GLX_RGBA_TYPE_SGIX 0x8014 -#define LOCAL_GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 -#define LOCAL_GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 -#define LOCAL_GLX_SAMPLES 100001 -#define LOCAL_GLX_SAMPLES_3DFX 0x8051 -#define LOCAL_GLX_SAMPLES_ARB 100001 -#define LOCAL_GLX_SAMPLES_SGIS 100001 -#define LOCAL_GLX_SAMPLE_BUFFERS 100000 -#define LOCAL_GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define LOCAL_GLX_SAMPLE_BUFFERS_ARB 100000 -#define LOCAL_GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define LOCAL_GLX_SAMPLE_BUFFERS_SGIS 100000 -#define LOCAL_GLX_SAVED 0x8021 -#define LOCAL_GLX_SAVED_SGIX 0x8021 -#define LOCAL_GLX_SCREEN 0x800C -#define LOCAL_GLX_SCREEN_EXT 0x800C -#define LOCAL_GLX_SHARE_CONTEXT_EXT 0x800A -#define LOCAL_GLX_SLOW_CONFIG 0x8001 -#define LOCAL_GLX_SLOW_VISUAL_EXT 0x8001 -#define LOCAL_GLX_STATIC_COLOR 0x8005 -#define LOCAL_GLX_STATIC_COLOR_EXT 0x8005 -#define LOCAL_GLX_STATIC_GRAY 0x8007 -#define LOCAL_GLX_STATIC_GRAY_EXT 0x8007 -#define LOCAL_GLX_STENCIL_BUFFER_BIT 0x00000040 -#define LOCAL_GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define LOCAL_GLX_STENCIL_SIZE 13 -#define LOCAL_GLX_STEREO 6 -#define LOCAL_GLX_STEREO_NOTIFY_EXT 0x00000000 -#define LOCAL_GLX_STEREO_NOTIFY_MASK_EXT 0x00000001 -#define LOCAL_GLX_STEREO_TREE_EXT 0x20F5 -#define LOCAL_GLX_SWAP_COPY_OML 0x8062 -#define LOCAL_GLX_SWAP_EXCHANGE_OML 0x8061 -#define LOCAL_GLX_SWAP_INTERVAL_EXT 0x20F1 -#define LOCAL_GLX_SWAP_METHOD_OML 0x8060 -#define LOCAL_GLX_SWAP_UNDEFINED_OML 0x8063 -#define LOCAL_GLX_SYNC_FRAME_SGIX 0x00000000 -#define LOCAL_GLX_SYNC_SWAP_SGIX 0x00000001 -#define LOCAL_GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define LOCAL_GLX_TEXTURE_1D_EXT 0x20DB -#define LOCAL_GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define LOCAL_GLX_TEXTURE_2D_EXT 0x20DC -#define LOCAL_GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define LOCAL_GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define LOCAL_GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA -#define LOCAL_GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define LOCAL_GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 -#define LOCAL_GLX_TEXTURE_RECTANGLE_EXT 0x20DD -#define LOCAL_GLX_TEXTURE_TARGET_EXT 0x20D6 -#define LOCAL_GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define LOCAL_GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define LOCAL_GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define LOCAL_GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define LOCAL_GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define LOCAL_GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define LOCAL_GLX_TRANSPARENT_INDEX 0x8009 -#define LOCAL_GLX_TRANSPARENT_INDEX_EXT 0x8009 -#define LOCAL_GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define LOCAL_GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define LOCAL_GLX_TRANSPARENT_RED_VALUE 0x25 -#define LOCAL_GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define LOCAL_GLX_TRANSPARENT_RGB 0x8008 -#define LOCAL_GLX_TRANSPARENT_RGB_EXT 0x8008 -#define LOCAL_GLX_TRANSPARENT_TYPE 0x23 -#define LOCAL_GLX_TRANSPARENT_TYPE_EXT 0x23 -#define LOCAL_GLX_TRUE_COLOR 0x8002 -#define LOCAL_GLX_TRUE_COLOR_EXT 0x8002 -#define LOCAL_GLX_UNIQUE_ID_NV 0x20CE -#define LOCAL_GLX_USE_GL 1 -#define LOCAL_GLX_VENDOR 0x1 -#define LOCAL_GLX_VENDOR_NAMES_EXT 0x20F6 -#define LOCAL_GLX_VERSION 0x2 -#define LOCAL_GLX_VIDEO_OUT_ALPHA_NV 0x20C4 -#define LOCAL_GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define LOCAL_GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define LOCAL_GLX_VIDEO_OUT_COLOR_NV 0x20C3 -#define LOCAL_GLX_VIDEO_OUT_DEPTH_NV 0x20C5 -#define LOCAL_GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 -#define LOCAL_GLX_VIDEO_OUT_FIELD_2_NV 0x20CA -#define LOCAL_GLX_VIDEO_OUT_FRAME_NV 0x20C8 -#define LOCAL_GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB -#define LOCAL_GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC -#define LOCAL_GLX_VISUAL_CAVEAT_EXT 0x20 -#define LOCAL_GLX_VISUAL_ID 0x800B -#define LOCAL_GLX_VISUAL_ID_EXT 0x800B -#define LOCAL_GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 -#define LOCAL_GLX_WIDTH 0x801D -#define LOCAL_GLX_WIDTH_SGIX 0x801D -#define LOCAL_GLX_WINDOW 0x8022 -#define LOCAL_GLX_WINDOW_BIT 0x00000001 -#define LOCAL_GLX_WINDOW_BIT_SGIX 0x00000001 -#define LOCAL_GLX_WINDOW_SGIX 0x8022 -#define LOCAL_GLX_X_RENDERABLE 0x8012 -#define LOCAL_GLX_X_RENDERABLE_SGIX 0x8012 -#define LOCAL_GLX_X_VISUAL_TYPE 0x22 -#define LOCAL_GLX_X_VISUAL_TYPE_EXT 0x22 -#define LOCAL_GLX_Y_INVERTED_EXT 0x20D4 - - -// WGL -#define LOCAL_WGL_ACCELERATION_ARB 0x2003 -#define LOCAL_WGL_ACCELERATION_EXT 0x2003 -#define LOCAL_WGL_ACCESS_READ_ONLY_NV 0x00000000 -#define LOCAL_WGL_ACCESS_READ_WRITE_NV 0x00000001 -#define LOCAL_WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 -#define LOCAL_WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define LOCAL_WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define LOCAL_WGL_ACCUM_BITS_ARB 0x201D -#define LOCAL_WGL_ACCUM_BITS_EXT 0x201D -#define LOCAL_WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define LOCAL_WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define LOCAL_WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define LOCAL_WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define LOCAL_WGL_ACCUM_RED_BITS_ARB 0x201E -#define LOCAL_WGL_ACCUM_RED_BITS_EXT 0x201E -#define LOCAL_WGL_ALPHA_BITS_ARB 0x201B -#define LOCAL_WGL_ALPHA_BITS_EXT 0x201B -#define LOCAL_WGL_ALPHA_SHIFT_ARB 0x201C -#define LOCAL_WGL_ALPHA_SHIFT_EXT 0x201C -#define LOCAL_WGL_AUX0_ARB 0x2087 -#define LOCAL_WGL_AUX1_ARB 0x2088 -#define LOCAL_WGL_AUX2_ARB 0x2089 -#define LOCAL_WGL_AUX3_ARB 0x208A -#define LOCAL_WGL_AUX4_ARB 0x208B -#define LOCAL_WGL_AUX5_ARB 0x208C -#define LOCAL_WGL_AUX6_ARB 0x208D -#define LOCAL_WGL_AUX7_ARB 0x208E -#define LOCAL_WGL_AUX8_ARB 0x208F -#define LOCAL_WGL_AUX9_ARB 0x2090 -#define LOCAL_WGL_AUX_BUFFERS_ARB 0x2024 -#define LOCAL_WGL_AUX_BUFFERS_EXT 0x2024 -#define LOCAL_WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define LOCAL_WGL_BACK_LEFT_ARB 0x2085 -#define LOCAL_WGL_BACK_RIGHT_ARB 0x2086 -#define LOCAL_WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define LOCAL_WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define LOCAL_WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define LOCAL_WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define LOCAL_WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define LOCAL_WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define LOCAL_WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define LOCAL_WGL_BLUE_BITS_ARB 0x2019 -#define LOCAL_WGL_BLUE_BITS_EXT 0x2019 -#define LOCAL_WGL_BLUE_SHIFT_ARB 0x201A -#define LOCAL_WGL_BLUE_SHIFT_EXT 0x201A -#define LOCAL_WGL_COLORSPACE_EXT 0x3087 -#define LOCAL_WGL_COLORSPACE_LINEAR_EXT 0x308A -#define LOCAL_WGL_COLORSPACE_SRGB_EXT 0x3089 -#define LOCAL_WGL_COLOR_BITS_ARB 0x2014 -#define LOCAL_WGL_COLOR_BITS_EXT 0x2014 -#define LOCAL_WGL_COLOR_SAMPLES_NV 0x20B9 -#define LOCAL_WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define LOCAL_WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define LOCAL_WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define LOCAL_WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#define LOCAL_WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 -#define LOCAL_WGL_CONTEXT_FLAGS_ARB 0x2094 -#define LOCAL_WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define LOCAL_WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define LOCAL_WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define LOCAL_WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define LOCAL_WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 -#define LOCAL_WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define LOCAL_WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 -#define LOCAL_WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 -#define LOCAL_WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 -#define LOCAL_WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 -#define LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define LOCAL_WGL_COVERAGE_SAMPLES_NV 0x2042 -#define LOCAL_WGL_CUBE_MAP_FACE_ARB 0x207C -#define LOCAL_WGL_DEPTH_BITS_ARB 0x2022 -#define LOCAL_WGL_DEPTH_BITS_EXT 0x2022 -#define LOCAL_WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define LOCAL_WGL_DEPTH_COMPONENT_NV 0x20A7 -#define LOCAL_WGL_DEPTH_FLOAT_EXT 0x2040 -#define LOCAL_WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define LOCAL_WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define LOCAL_WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define LOCAL_WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define LOCAL_WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#define LOCAL_WGL_DOUBLE_BUFFER_ARB 0x2011 -#define LOCAL_WGL_DOUBLE_BUFFER_EXT 0x2011 -#define LOCAL_WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define LOCAL_WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define LOCAL_WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define LOCAL_WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define LOCAL_WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define LOCAL_WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define LOCAL_WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define LOCAL_WGL_FONT_LINES 0 -#define LOCAL_WGL_FONT_POLYGONS 1 -#define LOCAL_WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 -#define LOCAL_WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 -#define LOCAL_WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define LOCAL_WGL_FRONT_LEFT_ARB 0x2083 -#define LOCAL_WGL_FRONT_RIGHT_ARB 0x2084 -#define LOCAL_WGL_FULL_ACCELERATION_ARB 0x2027 -#define LOCAL_WGL_FULL_ACCELERATION_EXT 0x2027 -#define LOCAL_WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#define LOCAL_WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define LOCAL_WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define LOCAL_WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define LOCAL_WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define LOCAL_WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define LOCAL_WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#define LOCAL_WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define LOCAL_WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define LOCAL_WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 -#define LOCAL_WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 -#define LOCAL_WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 -#define LOCAL_WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define LOCAL_WGL_GPU_CLOCK_AMD 0x21A4 -#define LOCAL_WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 -#define LOCAL_WGL_GPU_NUM_PIPES_AMD 0x21A5 -#define LOCAL_WGL_GPU_NUM_RB_AMD 0x21A7 -#define LOCAL_WGL_GPU_NUM_SIMD_AMD 0x21A6 -#define LOCAL_WGL_GPU_NUM_SPI_AMD 0x21A8 -#define LOCAL_WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 -#define LOCAL_WGL_GPU_RAM_AMD 0x21A3 -#define LOCAL_WGL_GPU_RENDERER_STRING_AMD 0x1F01 -#define LOCAL_WGL_GPU_VENDOR_AMD 0x1F00 -#define LOCAL_WGL_GREEN_BITS_ARB 0x2017 -#define LOCAL_WGL_GREEN_BITS_EXT 0x2017 -#define LOCAL_WGL_GREEN_SHIFT_ARB 0x2018 -#define LOCAL_WGL_GREEN_SHIFT_EXT 0x2018 -#define LOCAL_WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#define LOCAL_WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define LOCAL_WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define LOCAL_WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define LOCAL_WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define LOCAL_WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define LOCAL_WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define LOCAL_WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define LOCAL_WGL_MIPMAP_LEVEL_ARB 0x207B -#define LOCAL_WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define LOCAL_WGL_NEED_PALETTE_ARB 0x2004 -#define LOCAL_WGL_NEED_PALETTE_EXT 0x2004 -#define LOCAL_WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define LOCAL_WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define LOCAL_WGL_NO_ACCELERATION_ARB 0x2025 -#define LOCAL_WGL_NO_ACCELERATION_EXT 0x2025 -#define LOCAL_WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#define LOCAL_WGL_NO_TEXTURE_ARB 0x2077 -#define LOCAL_WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define LOCAL_WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define LOCAL_WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define LOCAL_WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define LOCAL_WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define LOCAL_WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define LOCAL_WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF -#define LOCAL_WGL_NUM_VIDEO_SLOTS_NV 0x20F0 -#define LOCAL_WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define LOCAL_WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define LOCAL_WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define LOCAL_WGL_PBUFFER_HEIGHT_EXT 0x2035 -#define LOCAL_WGL_PBUFFER_LARGEST_ARB 0x2033 -#define LOCAL_WGL_PBUFFER_LARGEST_EXT 0x2033 -#define LOCAL_WGL_PBUFFER_LOST_ARB 0x2036 -#define LOCAL_WGL_PBUFFER_WIDTH_ARB 0x2034 -#define LOCAL_WGL_PBUFFER_WIDTH_EXT 0x2034 -#define LOCAL_WGL_PIXEL_TYPE_ARB 0x2013 -#define LOCAL_WGL_PIXEL_TYPE_EXT 0x2013 -#define LOCAL_WGL_RED_BITS_ARB 0x2015 -#define LOCAL_WGL_RED_BITS_EXT 0x2015 -#define LOCAL_WGL_RED_SHIFT_ARB 0x2016 -#define LOCAL_WGL_RED_SHIFT_EXT 0x2016 -#define LOCAL_WGL_SAMPLES_3DFX 0x2061 -#define LOCAL_WGL_SAMPLES_ARB 0x2042 -#define LOCAL_WGL_SAMPLES_EXT 0x2042 -#define LOCAL_WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define LOCAL_WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define LOCAL_WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define LOCAL_WGL_SHARE_ACCUM_ARB 0x200E -#define LOCAL_WGL_SHARE_ACCUM_EXT 0x200E -#define LOCAL_WGL_SHARE_DEPTH_ARB 0x200C -#define LOCAL_WGL_SHARE_DEPTH_EXT 0x200C -#define LOCAL_WGL_SHARE_STENCIL_ARB 0x200D -#define LOCAL_WGL_SHARE_STENCIL_EXT 0x200D -#define LOCAL_WGL_STENCIL_BITS_ARB 0x2023 -#define LOCAL_WGL_STENCIL_BITS_EXT 0x2023 -#define LOCAL_WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#define LOCAL_WGL_STEREO_ARB 0x2012 -#define LOCAL_WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define LOCAL_WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define LOCAL_WGL_STEREO_EXT 0x2012 -#define LOCAL_WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#define LOCAL_WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define LOCAL_WGL_SUPPORT_GDI_ARB 0x200F -#define LOCAL_WGL_SUPPORT_GDI_EXT 0x200F -#define LOCAL_WGL_SUPPORT_OPENGL_ARB 0x2010 -#define LOCAL_WGL_SUPPORT_OPENGL_EXT 0x2010 -#define LOCAL_WGL_SWAP_COPY_ARB 0x2029 -#define LOCAL_WGL_SWAP_COPY_EXT 0x2029 -#define LOCAL_WGL_SWAP_EXCHANGE_ARB 0x2028 -#define LOCAL_WGL_SWAP_EXCHANGE_EXT 0x2028 -#define LOCAL_WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define LOCAL_WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define LOCAL_WGL_SWAP_MAIN_PLANE 0x00000001 -#define LOCAL_WGL_SWAP_METHOD_ARB 0x2007 -#define LOCAL_WGL_SWAP_METHOD_EXT 0x2007 -#define LOCAL_WGL_SWAP_OVERLAY1 0x00000002 -#define LOCAL_WGL_SWAP_OVERLAY10 0x00000400 -#define LOCAL_WGL_SWAP_OVERLAY11 0x00000800 -#define LOCAL_WGL_SWAP_OVERLAY12 0x00001000 -#define LOCAL_WGL_SWAP_OVERLAY13 0x00002000 -#define LOCAL_WGL_SWAP_OVERLAY14 0x00004000 -#define LOCAL_WGL_SWAP_OVERLAY15 0x00008000 -#define LOCAL_WGL_SWAP_OVERLAY2 0x00000004 -#define LOCAL_WGL_SWAP_OVERLAY3 0x00000008 -#define LOCAL_WGL_SWAP_OVERLAY4 0x00000010 -#define LOCAL_WGL_SWAP_OVERLAY5 0x00000020 -#define LOCAL_WGL_SWAP_OVERLAY6 0x00000040 -#define LOCAL_WGL_SWAP_OVERLAY7 0x00000080 -#define LOCAL_WGL_SWAP_OVERLAY8 0x00000100 -#define LOCAL_WGL_SWAP_OVERLAY9 0x00000200 -#define LOCAL_WGL_SWAP_UNDEFINED_ARB 0x202A -#define LOCAL_WGL_SWAP_UNDEFINED_EXT 0x202A -#define LOCAL_WGL_SWAP_UNDERLAY1 0x00010000 -#define LOCAL_WGL_SWAP_UNDERLAY10 0x02000000 -#define LOCAL_WGL_SWAP_UNDERLAY11 0x04000000 -#define LOCAL_WGL_SWAP_UNDERLAY12 0x08000000 -#define LOCAL_WGL_SWAP_UNDERLAY13 0x10000000 -#define LOCAL_WGL_SWAP_UNDERLAY14 0x20000000 -#define LOCAL_WGL_SWAP_UNDERLAY15 0x40000000 -#define LOCAL_WGL_SWAP_UNDERLAY2 0x00020000 -#define LOCAL_WGL_SWAP_UNDERLAY3 0x00040000 -#define LOCAL_WGL_SWAP_UNDERLAY4 0x00080000 -#define LOCAL_WGL_SWAP_UNDERLAY5 0x00100000 -#define LOCAL_WGL_SWAP_UNDERLAY6 0x00200000 -#define LOCAL_WGL_SWAP_UNDERLAY7 0x00400000 -#define LOCAL_WGL_SWAP_UNDERLAY8 0x00800000 -#define LOCAL_WGL_SWAP_UNDERLAY9 0x01000000 -#define LOCAL_WGL_TEXTURE_1D_ARB 0x2079 -#define LOCAL_WGL_TEXTURE_2D_ARB 0x207A -#define LOCAL_WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define LOCAL_WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define LOCAL_WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define LOCAL_WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define LOCAL_WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define LOCAL_WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define LOCAL_WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define LOCAL_WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define LOCAL_WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#define LOCAL_WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define LOCAL_WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define LOCAL_WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define LOCAL_WGL_TEXTURE_FORMAT_ARB 0x2072 -#define LOCAL_WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#define LOCAL_WGL_TEXTURE_RGBA_ARB 0x2076 -#define LOCAL_WGL_TEXTURE_RGB_ARB 0x2075 -#define LOCAL_WGL_TEXTURE_TARGET_ARB 0x2073 -#define LOCAL_WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define LOCAL_WGL_TRANSPARENT_ARB 0x200A -#define LOCAL_WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define LOCAL_WGL_TRANSPARENT_EXT 0x200A -#define LOCAL_WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define LOCAL_WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define LOCAL_WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define LOCAL_WGL_TRANSPARENT_VALUE_EXT 0x200B -#define LOCAL_WGL_TYPE_COLORINDEX_ARB 0x202C -#define LOCAL_WGL_TYPE_COLORINDEX_EXT 0x202C -#define LOCAL_WGL_TYPE_RGBA_ARB 0x202B -#define LOCAL_WGL_TYPE_RGBA_EXT 0x202B -#define LOCAL_WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#define LOCAL_WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#define LOCAL_WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 -#define LOCAL_WGL_UNIQUE_ID_NV 0x20CE -#define LOCAL_WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define LOCAL_WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define LOCAL_WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define LOCAL_WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define LOCAL_WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define LOCAL_WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define LOCAL_WGL_VIDEO_OUT_FIELD_2 0x20CA -#define LOCAL_WGL_VIDEO_OUT_FRAME 0x20C8 -#define LOCAL_WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define LOCAL_WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC - - - -#endif // GLCONSTS_H_ diff --git a/sources/firefox/WebGLFormats.cpp b/sources/firefox/WebGLFormats.cpp deleted file mode 100644 index 1b3c83d9..00000000 --- a/sources/firefox/WebGLFormats.cpp +++ /dev/null @@ -1,1205 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "WebGLFormats.h" - -//cjh #include "gfxPrefs.h" -//#include "GLContext.h" -//#include "GLDefs.h" -//#include "mozilla/gfx/Logging.h" -//#include "mozilla/StaticMutex.h" -#include "GLConsts.h" - -#ifdef FOO -#error FOO is already defined! We use FOO() macros to keep things succinct in this file. -#endif - -namespace mozilla { -namespace webgl { - -template -static inline void -AlwaysInsert(std::map& dest, const K2& key, const V2& val) -{ - auto res = dest.insert({ key, val }); - bool didInsert = res.second; - MOZ_ALWAYS_TRUE(didInsert); -} - -template -static inline V* -FindOrNull(const std::map& dest, const K2& key) -{ - auto itr = dest.find(key); - if (itr == dest.end()) - return nullptr; - - return itr->second; -} - -// Returns a pointer to the in-place value for `key`. -template -static inline V* -FindPtrOrNull(std::map& dest, const K2& key) -{ - auto itr = dest.find(key); - if (itr == dest.end()) - return nullptr; - - return &(itr->second); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -std::map gCompressedFormatInfoMap; -std::map gFormatInfoMap; - -static inline const CompressedFormatInfo* -GetCompressedFormatInfo(EffectiveFormat format) -{ - MOZ_ASSERT(!gCompressedFormatInfoMap.empty()); - return FindPtrOrNull(gCompressedFormatInfoMap, format); -} - -static inline FormatInfo* -GetFormatInfo_NoLock(EffectiveFormat format) -{ - MOZ_ASSERT(!gFormatInfoMap.empty()); - return FindPtrOrNull(gFormatInfoMap, format); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -static void -AddCompressedFormatInfo(EffectiveFormat format, uint16_t bitsPerBlock, uint8_t blockWidth, - uint8_t blockHeight, CompressionFamily family) -{ - MOZ_ASSERT(bitsPerBlock % 8 == 0); - uint16_t bytesPerBlock = bitsPerBlock / 8; // The specs always state these in bits, - // but it's only ever useful to us as - // bytes. - MOZ_ASSERT(bytesPerBlock <= 255); - - const CompressedFormatInfo info = { format, uint8_t(bytesPerBlock), blockWidth, - blockHeight, family }; - AlwaysInsert(gCompressedFormatInfoMap, format, info); -} - -static void -InitCompressedFormatInfo() -{ - // GLES 3.0.4, p147, table 3.19 - // GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats" - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB8_ETC2 , 64, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ETC2 , 64, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA8_ETC2_EAC , 128, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC , 128, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_R11_EAC , 64, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RG11_EAC , 128, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SIGNED_R11_EAC , 64, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SIGNED_RG11_EAC , 128, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 , 64, 4, 4, CompressionFamily::ES3); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 64, 4, 4, CompressionFamily::ES3); - - // AMD_compressed_ATC_texture - AddCompressedFormatInfo(EffectiveFormat::ATC_RGB_AMD , 64, 4, 4, CompressionFamily::ATC); - AddCompressedFormatInfo(EffectiveFormat::ATC_RGBA_EXPLICIT_ALPHA_AMD , 128, 4, 4, CompressionFamily::ATC); - AddCompressedFormatInfo(EffectiveFormat::ATC_RGBA_INTERPOLATED_ALPHA_AMD, 128, 4, 4, CompressionFamily::ATC); - - // EXT_texture_compression_s3tc - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB_S3TC_DXT1_EXT , 64, 4, 4, CompressionFamily::S3TC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_S3TC_DXT1_EXT, 64, 4, 4, CompressionFamily::S3TC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_S3TC_DXT3_EXT, 128, 4, 4, CompressionFamily::S3TC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_S3TC_DXT5_EXT, 128, 4, 4, CompressionFamily::S3TC); - - // EXT_texture_compression_s3tc_srgb - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_S3TC_DXT1_EXT , 64, 4, 4, CompressionFamily::S3TC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 64, 4, 4, CompressionFamily::S3TC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 128, 4, 4, CompressionFamily::S3TC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 128, 4, 4, CompressionFamily::S3TC); - - // KHR_texture_compression_astc_ldr - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_4x4_KHR , 128, 4, 4, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_5x4_KHR , 128, 5, 4, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_5x5_KHR , 128, 5, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_6x5_KHR , 128, 6, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_6x6_KHR , 128, 6, 6, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_8x5_KHR , 128, 8, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_8x6_KHR , 128, 8, 6, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_8x8_KHR , 128, 8, 8, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_10x5_KHR , 128, 10, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_10x6_KHR , 128, 10, 6, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_10x8_KHR , 128, 10, 8, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_10x10_KHR , 128, 10, 10, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_12x10_KHR , 128, 12, 10, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_ASTC_12x12_KHR , 128, 12, 12, CompressionFamily::ASTC); - - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR , 128, 4, 4, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR , 128, 5, 4, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR , 128, 5, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR , 128, 6, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR , 128, 6, 6, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR , 128, 8, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR , 128, 8, 6, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR , 128, 8, 8, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR , 128, 10, 5, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR , 128, 10, 6, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR , 128, 10, 8, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 128, 10, 10, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 128, 12, 10, CompressionFamily::ASTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 128, 12, 12, CompressionFamily::ASTC); - - // IMG_texture_compression_pvrtc - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB_PVRTC_4BPPV1 , 256, 8, 8, CompressionFamily::PVRTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_PVRTC_4BPPV1, 256, 8, 8, CompressionFamily::PVRTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGB_PVRTC_2BPPV1 , 256, 16, 8, CompressionFamily::PVRTC); - AddCompressedFormatInfo(EffectiveFormat::COMPRESSED_RGBA_PVRTC_2BPPV1, 256, 16, 8, CompressionFamily::PVRTC); - - // OES_compressed_ETC1_RGB8_texture - AddCompressedFormatInfo(EffectiveFormat::ETC1_RGB8_OES, 64, 4, 4, CompressionFamily::ETC1); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -static void -AddFormatInfo(EffectiveFormat format, const char* name, GLenum sizedFormat, - uint8_t bytesPerPixel, uint8_t r, uint8_t g, uint8_t b, uint8_t a, - uint8_t d, uint8_t s, UnsizedFormat unsizedFormat, bool isSRGB, - ComponentType componentType) -{ - switch (unsizedFormat) { - case UnsizedFormat::R: - MOZ_ASSERT(r && !g && !b && !a && !d && !s); - break; - - case UnsizedFormat::RG: - MOZ_ASSERT(r && g && !b && !a && !d && !s); - break; - - case UnsizedFormat::RGB: - MOZ_ASSERT(r && g && b && !a && !d && !s); - break; - - case UnsizedFormat::RGBA: - MOZ_ASSERT(r && g && b && a && !d && !s); - break; - - case UnsizedFormat::L: - MOZ_ASSERT(r && !g && !b && !a && !d && !s); - break; - - case UnsizedFormat::A: - MOZ_ASSERT(!r && !g && !b && a && !d && !s); - break; - - case UnsizedFormat::LA: - MOZ_ASSERT(r && !g && !b && a && !d && !s); - break; - - case UnsizedFormat::D: - MOZ_ASSERT(!r && !g && !b && !a && d && !s); - break; - - case UnsizedFormat::S: - MOZ_ASSERT(!r && !g && !b && !a && !d && s); - break; - - case UnsizedFormat::DEPTH_STENCIL: - MOZ_ASSERT(!r && !g && !b && !a && d && s); - break; - } - - const CompressedFormatInfo* compressedFormatInfo = GetCompressedFormatInfo(format); - MOZ_ASSERT(!bytesPerPixel == bool(compressedFormatInfo)); - -#ifdef DEBUG - uint8_t totalBits = r + g + b + a + d + s; - if (format == EffectiveFormat::RGB9_E5) { - totalBits = 9 + 9 + 9 + 5; - } - - if (compressedFormatInfo) { - MOZ_ASSERT(totalBits); - MOZ_ASSERT(!bytesPerPixel); - } else { - MOZ_ASSERT(totalBits == bytesPerPixel*8); - } -#endif - - const FormatInfo info = { format, name, sizedFormat, unsizedFormat, componentType, - isSRGB, compressedFormatInfo, bytesPerPixel, r,g,b,a,d,s }; - AlwaysInsert(gFormatInfoMap, format, info); -} - -static void -InitFormatInfo() -{ -#define FOO(x) EffectiveFormat::x, #x, LOCAL_GL_ ## x - // GLES 3.0.4, p130-132, table 3.13 - AddFormatInfo(FOO(R8 ), 1, 8, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::NormUInt); - AddFormatInfo(FOO(R8_SNORM ), 1, 8, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::NormInt ); - AddFormatInfo(FOO(RG8 ), 2, 8, 8, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::NormUInt); - AddFormatInfo(FOO(RG8_SNORM ), 2, 8, 8, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::NormInt ); - AddFormatInfo(FOO(RGB8 ), 3, 8, 8, 8, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); - AddFormatInfo(FOO(RGB8_SNORM ), 3, 8, 8, 8, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormInt ); - AddFormatInfo(FOO(RGB565 ), 2, 5, 6, 5, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); - AddFormatInfo(FOO(RGBA4 ), 2, 4, 4, 4, 4, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(RGB5_A1 ), 2, 5, 5, 5, 1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(RGBA8 ), 4, 8, 8, 8, 8, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(RGBA8_SNORM ), 4, 8, 8, 8, 8, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormInt ); - AddFormatInfo(FOO(RGB10_A2 ), 4, 10,10,10, 2, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(RGB10_A2UI ), 4, 10,10,10, 2, 0,0, UnsizedFormat::RGBA, false, ComponentType::UInt ); - - AddFormatInfo(FOO(SRGB8 ), 3, 8, 8, 8, 0, 0,0, UnsizedFormat::RGB , true , ComponentType::NormUInt); - AddFormatInfo(FOO(SRGB8_ALPHA8 ), 4, 8, 8, 8, 8, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); - - AddFormatInfo(FOO(R16F ), 2, 16, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::Float ); - AddFormatInfo(FOO(RG16F ), 4, 16,16, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::Float ); - AddFormatInfo(FOO(RGB16F ), 6, 16,16,16, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Float ); - AddFormatInfo(FOO(RGBA16F ), 8, 16,16,16,16, 0,0, UnsizedFormat::RGBA, false, ComponentType::Float ); - AddFormatInfo(FOO(R32F ), 4, 32, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::Float ); - AddFormatInfo(FOO(RG32F ), 8, 32,32, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::Float ); - AddFormatInfo(FOO(RGB32F ), 12, 32,32,32, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Float ); - AddFormatInfo(FOO(RGBA32F ), 16, 32,32,32,32, 0,0, UnsizedFormat::RGBA, false, ComponentType::Float ); - - AddFormatInfo(FOO(R11F_G11F_B10F), 4, 11,11,10, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Float ); - AddFormatInfo(FOO(RGB9_E5 ), 4, 14,14,14, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Float ); - - AddFormatInfo(FOO(R8I ), 1, 8, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::Int ); - AddFormatInfo(FOO(R8UI ), 1, 8, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::UInt ); - AddFormatInfo(FOO(R16I ), 2, 16, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::Int ); - AddFormatInfo(FOO(R16UI ), 2, 16, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::UInt ); - AddFormatInfo(FOO(R32I ), 4, 32, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::Int ); - AddFormatInfo(FOO(R32UI ), 4, 32, 0, 0, 0, 0,0, UnsizedFormat::R , false, ComponentType::UInt ); - - AddFormatInfo(FOO(RG8I ), 2, 8, 8, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::Int ); - AddFormatInfo(FOO(RG8UI ), 2, 8, 8, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::UInt ); - AddFormatInfo(FOO(RG16I ), 4, 16,16, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::Int ); - AddFormatInfo(FOO(RG16UI ), 4, 16,16, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::UInt ); - AddFormatInfo(FOO(RG32I ), 8, 32,32, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::Int ); - AddFormatInfo(FOO(RG32UI ), 8, 32,32, 0, 0, 0,0, UnsizedFormat::RG , false, ComponentType::UInt ); - - AddFormatInfo(FOO(RGB8I ), 3, 8, 8, 8, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Int ); - AddFormatInfo(FOO(RGB8UI ), 3, 8, 8, 8, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::UInt ); - AddFormatInfo(FOO(RGB16I ), 6, 16,16,16, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Int ); - AddFormatInfo(FOO(RGB16UI ), 6, 16,16,16, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::UInt ); - AddFormatInfo(FOO(RGB32I ), 12, 32,32,32, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::Int ); - AddFormatInfo(FOO(RGB32UI ), 12, 32,32,32, 0, 0,0, UnsizedFormat::RGB , false, ComponentType::UInt ); - - AddFormatInfo(FOO(RGBA8I ), 4, 8, 8, 8, 8, 0,0, UnsizedFormat::RGBA, false, ComponentType::Int ); - AddFormatInfo(FOO(RGBA8UI ), 4, 8, 8, 8, 8, 0,0, UnsizedFormat::RGBA, false, ComponentType::UInt ); - AddFormatInfo(FOO(RGBA16I ), 8, 16,16,16,16, 0,0, UnsizedFormat::RGBA, false, ComponentType::Int ); - AddFormatInfo(FOO(RGBA16UI ), 8, 16,16,16,16, 0,0, UnsizedFormat::RGBA, false, ComponentType::UInt ); - AddFormatInfo(FOO(RGBA32I ), 16, 32,32,32,32, 0,0, UnsizedFormat::RGBA, false, ComponentType::Int ); - AddFormatInfo(FOO(RGBA32UI ), 16, 32,32,32,32, 0,0, UnsizedFormat::RGBA, false, ComponentType::UInt ); - - // GLES 3.0.4, p133, table 3.14 - AddFormatInfo(FOO(DEPTH_COMPONENT16 ), 2, 0,0,0,0, 16,0, UnsizedFormat::D , false, ComponentType::NormUInt); - AddFormatInfo(FOO(DEPTH_COMPONENT24 ), 3, 0,0,0,0, 24,0, UnsizedFormat::D , false, ComponentType::NormUInt); - AddFormatInfo(FOO(DEPTH_COMPONENT32F), 4, 0,0,0,0, 32,0, UnsizedFormat::D , false, ComponentType::Float); - AddFormatInfo(FOO(DEPTH24_STENCIL8 ), 4, 0,0,0,0, 24,8, UnsizedFormat::DEPTH_STENCIL, false, ComponentType::Special); - AddFormatInfo(FOO(DEPTH32F_STENCIL8 ), 5, 0,0,0,0, 32,8, UnsizedFormat::DEPTH_STENCIL, false, ComponentType::Special); - - // GLES 3.0.4, p205-206, "Required Renderbuffer Formats" - AddFormatInfo(FOO(STENCIL_INDEX8), 1, 0,0,0,0, 0,8, UnsizedFormat::S, false, ComponentType::UInt); - - // GLES 3.0.4, p147, table 3.19 - // GLES 3.0.4 p286+ $C.1 "ETC Compressed Texture Image Formats" -//cjh AddFormatInfo(FOO(COMPRESSED_RGB8_ETC2 ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ETC2 ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA8_ETC2_EAC ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_R11_EAC ), 0, 1,0,0,0, 0,0, UnsizedFormat::R , false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RG11_EAC ), 0, 1,1,0,0, 0,0, UnsizedFormat::RG , false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SIGNED_R11_EAC ), 0, 1,0,0,0, 0,0, UnsizedFormat::R , false, ComponentType::NormInt ); -// AddFormatInfo(FOO(COMPRESSED_SIGNED_RG11_EAC ), 0, 1,1,0,0, 0,0, UnsizedFormat::RG , false, ComponentType::NormInt ); -// AddFormatInfo(FOO(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); - - // AMD_compressed_ATC_texture -//cjh AddFormatInfo(FOO(ATC_RGB_AMD ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); -// AddFormatInfo(FOO(ATC_RGBA_EXPLICIT_ALPHA_AMD ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(ATC_RGBA_INTERPOLATED_ALPHA_AMD), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - - // EXT_texture_compression_s3tc - AddFormatInfo(FOO(COMPRESSED_RGB_S3TC_DXT1_EXT ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); - AddFormatInfo(FOO(COMPRESSED_RGBA_S3TC_DXT1_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(COMPRESSED_RGBA_S3TC_DXT3_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(COMPRESSED_RGBA_S3TC_DXT5_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); - - // EXT_texture_compression_s3tc_srgb - AddFormatInfo(FOO(COMPRESSED_SRGB_S3TC_DXT1_EXT ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , true, ComponentType::NormUInt); - AddFormatInfo(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true, ComponentType::NormUInt); - AddFormatInfo(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true, ComponentType::NormUInt); - AddFormatInfo(FOO(COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true, ComponentType::NormUInt); - - // KHR_texture_compression_astc_ldr -//cjh AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_4x4_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_5x4_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_5x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_6x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_6x6_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_8x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_8x6_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_8x8_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_10x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_10x6_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_10x8_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_10x10_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_12x10_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_ASTC_12x12_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR ), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, true , ComponentType::NormUInt); -// -// // IMG_texture_compression_pvrtc -// AddFormatInfo(FOO(COMPRESSED_RGB_PVRTC_4BPPV1 ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_PVRTC_4BPPV1), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGB_PVRTC_2BPPV1 ), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB , false, ComponentType::NormUInt); -// AddFormatInfo(FOO(COMPRESSED_RGBA_PVRTC_2BPPV1), 0, 1,1,1,1, 0,0, UnsizedFormat::RGBA, false, ComponentType::NormUInt); -// -// // OES_compressed_ETC1_RGB8_texture -// AddFormatInfo(FOO(ETC1_RGB8_OES), 0, 1,1,1,0, 0,0, UnsizedFormat::RGB, false, ComponentType::NormUInt); - -#undef FOO - - // 'Virtual' effective formats have no sizedFormat. -#define FOO(x) EffectiveFormat::x, #x, 0 - - // GLES 3.0.4, p128, table 3.12. - AddFormatInfo(FOO(Luminance8Alpha8), 2, 8,0,0,8, 0,0, UnsizedFormat::LA, false, ComponentType::NormUInt); - AddFormatInfo(FOO(Luminance8 ), 1, 8,0,0,0, 0,0, UnsizedFormat::L , false, ComponentType::NormUInt); - AddFormatInfo(FOO(Alpha8 ), 1, 0,0,0,8, 0,0, UnsizedFormat::A , false, ComponentType::NormUInt); - - // OES_texture_float - AddFormatInfo(FOO(Luminance32FAlpha32F), 8, 32,0,0,32, 0,0, UnsizedFormat::LA, false, ComponentType::Float); - AddFormatInfo(FOO(Luminance32F ), 4, 32,0,0, 0, 0,0, UnsizedFormat::L , false, ComponentType::Float); - AddFormatInfo(FOO(Alpha32F ), 4, 0,0,0,32, 0,0, UnsizedFormat::A , false, ComponentType::Float); - - // OES_texture_half_float - AddFormatInfo(FOO(Luminance16FAlpha16F), 4, 16,0,0,16, 0,0, UnsizedFormat::LA, false, ComponentType::Float); - AddFormatInfo(FOO(Luminance16F ), 2, 16,0,0, 0, 0,0, UnsizedFormat::L , false, ComponentType::Float); - AddFormatInfo(FOO(Alpha16F ), 2, 0,0,0,16, 0,0, UnsizedFormat::A , false, ComponentType::Float); - -#undef FOO - - //////////////////////////////////////////////////////////////////////////// - - const auto fnSetCopyDecay = [](EffectiveFormat src, EffectiveFormat asR, - EffectiveFormat asRG, EffectiveFormat asRGB, - EffectiveFormat asRGBA, EffectiveFormat asL, - EffectiveFormat asA, EffectiveFormat asLA) - { - auto& map = GetFormatInfo_NoLock(src)->copyDecayFormats; - - const auto fnSet = [&map](UnsizedFormat uf, EffectiveFormat ef) { - if (ef == EffectiveFormat::MAX) - return; - - const auto* format = GetFormatInfo_NoLock(ef); - MOZ_ASSERT(format->unsizedFormat == uf); - AlwaysInsert(map, uf, format); - }; - - fnSet(UnsizedFormat::R , asR); - fnSet(UnsizedFormat::RG , asRG); - fnSet(UnsizedFormat::RGB , asRGB); - fnSet(UnsizedFormat::RGBA, asRGBA); - fnSet(UnsizedFormat::L , asL); - fnSet(UnsizedFormat::A , asA); - fnSet(UnsizedFormat::LA , asLA); - }; - -#define SET_COPY_DECAY(src,asR,asRG,asRGB,asRGBA,asL,asA,asLA) \ - fnSetCopyDecay(EffectiveFormat::src, EffectiveFormat::asR, EffectiveFormat::asRG, \ - EffectiveFormat::asRGB, EffectiveFormat::asRGBA, EffectiveFormat::asL, \ - EffectiveFormat::asA, EffectiveFormat::asLA); - - ////// - -#define SET_BY_SUFFIX(X) \ - SET_COPY_DECAY( R##X, R##X, MAX, MAX, MAX, Luminance##X, MAX, MAX) \ - SET_COPY_DECAY( RG##X, R##X, RG##X, MAX, MAX, Luminance##X, MAX, MAX) \ - SET_COPY_DECAY( RGB##X, R##X, RG##X, RGB##X, MAX, Luminance##X, MAX, MAX) \ - SET_COPY_DECAY(RGBA##X, R##X, RG##X, RGB##X, RGBA##X, Luminance##X, Alpha##X, Luminance##X##Alpha##X) - - SET_BY_SUFFIX(8) // WebGL decided that RGB8 should be guaranteed renderable. - SET_BY_SUFFIX(16F) // RGB16F is renderable in EXT_color_buffer_half_float, though not - // EXT_color_buffer_float. - SET_BY_SUFFIX(32F) // Technically RGB32F is never renderable, but no harm here. - -#undef SET_BY_SUFFIX - - ////// - -#define SET_BY_SUFFIX(X) \ - SET_COPY_DECAY( R##X, R##X, MAX, MAX, MAX, MAX, MAX, MAX) \ - SET_COPY_DECAY( RG##X, R##X, RG##X, MAX, MAX, MAX, MAX, MAX) \ - SET_COPY_DECAY(RGBA##X, R##X, RG##X, RGB##X, RGBA##X, MAX, MAX, MAX) - - SET_BY_SUFFIX(8I) - SET_BY_SUFFIX(8UI) - - SET_BY_SUFFIX(16I) - SET_BY_SUFFIX(16UI) - - SET_BY_SUFFIX(32I) - SET_BY_SUFFIX(32UI) - -#undef SET_BY_SUFFIX - - ////// - - SET_COPY_DECAY( RGB565, R8, RG8, RGB565, MAX, Luminance8, MAX, MAX) - SET_COPY_DECAY( RGBA4, R8, RG8, RGB565, RGBA4, Luminance8, Alpha8, Luminance8Alpha8) - SET_COPY_DECAY( RGB5_A1, R8, RG8, RGB565, RGB5_A1, Luminance8, Alpha8, Luminance8Alpha8) - SET_COPY_DECAY( RGB10_A2, R8, RG8, RGB8, RGB10_A2, Luminance8, Alpha8, MAX) - - SET_COPY_DECAY(RGB10_A2UI, R8UI, RG8UI, RGB8UI, RGB10_A2UI, MAX, MAX, MAX) - - SET_COPY_DECAY(SRGB8_ALPHA8, MAX, MAX, MAX, SRGB8_ALPHA8, MAX, Alpha8, MAX) - - SET_COPY_DECAY(R11F_G11F_B10F, R16F, RG16F, R11F_G11F_B10F, MAX, Luminance16F, MAX, MAX) - -#undef SET_COPY_DECAY -} - -////////////////////////////////////////////////////////////////////////////////////////// - -bool gAreFormatTablesInitialized = false; - -static void -EnsureInitFormatTables(/* cjh const StaticMutexAutoLock&*/) // Prove that you locked it! -{ - if (MOZ_LIKELY(gAreFormatTablesInitialized)) - return; - - gAreFormatTablesInitialized = true; - - InitCompressedFormatInfo(); - InitFormatInfo(); -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Public funcs - -//cjh StaticMutex gFormatMapMutex; - -const FormatInfo* -GetFormat(EffectiveFormat format) -{ -//cjh StaticMutexAutoLock lock(gFormatMapMutex); -// EnsureInitFormatTables(lock); - EnsureInitFormatTables(); - - return GetFormatInfo_NoLock(format); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -const FormatInfo* -FormatInfo::GetCopyDecayFormat(UnsizedFormat uf) const -{ - return FindOrNull(this->copyDecayFormats, uf); -} - -bool -GetBytesPerPixel(const PackingInfo& packing, uint8_t* const out_bytes) -{ - uint8_t bytesPerChannel; - - switch (packing.type) { - case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4: - case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1: - case LOCAL_GL_UNSIGNED_SHORT_5_6_5: - *out_bytes = 2; - return true; - - case LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV: - case LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV: - case LOCAL_GL_UNSIGNED_INT_24_8: - case LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV: - *out_bytes = 4; - return true; - - case LOCAL_GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - *out_bytes = 8; - return true; - - // Alright, that's all the fixed-size unpackTypes. - - case LOCAL_GL_BYTE: - case LOCAL_GL_UNSIGNED_BYTE: - bytesPerChannel = 1; - break; - - case LOCAL_GL_SHORT: - case LOCAL_GL_UNSIGNED_SHORT: - case LOCAL_GL_HALF_FLOAT: - case LOCAL_GL_HALF_FLOAT_OES: - bytesPerChannel = 2; - break; - - case LOCAL_GL_INT: - case LOCAL_GL_UNSIGNED_INT: - case LOCAL_GL_FLOAT: - bytesPerChannel = 4; - break; - - default: - return false; - } - - uint8_t channels; - - switch (packing.format) { - case LOCAL_GL_RED: - case LOCAL_GL_RED_INTEGER: - case LOCAL_GL_LUMINANCE: - case LOCAL_GL_ALPHA: - case LOCAL_GL_DEPTH_COMPONENT: - channels = 1; - break; - - case LOCAL_GL_RG: - case LOCAL_GL_RG_INTEGER: - case LOCAL_GL_LUMINANCE_ALPHA: - case LOCAL_GL_DEPTH_COMPONENT16: - channels = 2; - break; - - case LOCAL_GL_RGB: - case LOCAL_GL_RGB_INTEGER: - case LOCAL_GL_SRGB: - case LOCAL_GL_DEPTH_COMPONENT24: - channels = 3; - break; - - case LOCAL_GL_BGRA: - case LOCAL_GL_RGBA: - case LOCAL_GL_RGBA_INTEGER: - case LOCAL_GL_SRGB_ALPHA: - case LOCAL_GL_DEPTH_COMPONENT32F: - channels = 4; - break; - - default: - return false; - } - - *out_bytes = bytesPerChannel * channels; - return true; -} - -uint8_t -BytesPerPixel(const PackingInfo& packing) -{ - uint8_t ret; - if (MOZ_LIKELY(GetBytesPerPixel(packing, &ret))) - return ret; - -//cjh gfxCriticalError() << "Bad `packing`: " << gfx::hexa(packing.format) << ", " -// << gfx::hexa(packing.type); - MOZ_CRASH("Bad `packing`."); -} - -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////// -// FormatUsageAuthority - -bool -FormatUsageInfo::IsUnpackValid(const PackingInfo& key, - const DriverUnpackInfo** const out_value) const -{ - auto itr = validUnpacks.find(key); - if (itr == validUnpacks.end()) - return false; - - *out_value = &(itr->second); - return true; -} - -void -FormatUsageInfo::ResolveMaxSamples(gl::GLContext* gl) -{ -//cjh MOZ_ASSERT(!this->maxSamplesKnown); -// MOZ_ASSERT(this->maxSamples == 0); -// MOZ_ASSERT(gl->IsCurrent()); -// -// this->maxSamplesKnown = true; -// -// const GLenum internalFormat = this->format->sizedFormat; -// if (!internalFormat) -// return; -// -// if (!gl->IsSupported(gl::GLFeature::internalformat_query)) -// return; // Leave it at 0. -// -// GLint maxSamplesGL = 0; -// gl->fGetInternalformativ(LOCAL_GL_RENDERBUFFER, internalFormat, LOCAL_GL_SAMPLES, 1, -// &maxSamplesGL); -// -// this->maxSamples = maxSamplesGL; -} - -//////////////////////////////////////// - -static void -AddSimpleUnsized(FormatUsageAuthority* fua, GLenum unpackFormat, GLenum unpackType, - EffectiveFormat effFormat) -{ - auto usage = fua->EditUsage(effFormat); - usage->isFilterable = true; - - const PackingInfo pi = {unpackFormat, unpackType}; - const DriverUnpackInfo dui = {unpackFormat, unpackFormat, unpackType}; - fua->AddTexUnpack(usage, pi, dui); - - fua->AllowUnsizedTexFormat(pi, usage); -}; - - -/*static*/ const GLint FormatUsageInfo::kLuminanceSwizzleRGBA[4] = { LOCAL_GL_RED, - LOCAL_GL_RED, - LOCAL_GL_RED, - LOCAL_GL_ONE }; -/*static*/ const GLint FormatUsageInfo::kAlphaSwizzleRGBA[4] = { LOCAL_GL_ZERO, - LOCAL_GL_ZERO, - LOCAL_GL_ZERO, - LOCAL_GL_RED }; -/*static*/ const GLint FormatUsageInfo::kLumAlphaSwizzleRGBA[4] = { LOCAL_GL_RED, - LOCAL_GL_RED, - LOCAL_GL_RED, - LOCAL_GL_GREEN }; - -static bool -AddLegacyFormats_LA8(FormatUsageAuthority* fua, gl::GLContext* gl) -{ -//cjh if (gl->IsCoreProfile()) { -// if (!gl->IsSupported(gl::GLFeature::texture_swizzle)) -// return false; -// -// PackingInfo pi; -// DriverUnpackInfo dui; -// -// const auto fnAdd = [fua, &pi, &dui](EffectiveFormat effFormat, -// const GLint* swizzle) -// { -// auto usage = fua->EditUsage(effFormat); -// usage->isFilterable = true; -// usage->textureSwizzleRGBA = swizzle; -// -// fua->AddTexUnpack(usage, pi, dui); -// -// fua->AllowUnsizedTexFormat(pi, usage); -// }; -// -// pi = {LOCAL_GL_LUMINANCE, LOCAL_GL_UNSIGNED_BYTE}; -// dui = {LOCAL_GL_R8, LOCAL_GL_RED, LOCAL_GL_UNSIGNED_BYTE}; -// fnAdd(EffectiveFormat::Luminance8, FormatUsageInfo::kLuminanceSwizzleRGBA); -// -// pi = {LOCAL_GL_ALPHA, LOCAL_GL_UNSIGNED_BYTE}; -// dui = {LOCAL_GL_R8, LOCAL_GL_RED, LOCAL_GL_UNSIGNED_BYTE}; -// fnAdd(EffectiveFormat::Alpha8, FormatUsageInfo::kAlphaSwizzleRGBA); -// -// pi = {LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_UNSIGNED_BYTE}; -// dui = {LOCAL_GL_RG8, LOCAL_GL_RG, LOCAL_GL_UNSIGNED_BYTE}; -// fnAdd(EffectiveFormat::Luminance8Alpha8, FormatUsageInfo::kLumAlphaSwizzleRGBA); -// } else - { - AddSimpleUnsized(fua, LOCAL_GL_LUMINANCE , LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Luminance8 ); - AddSimpleUnsized(fua, LOCAL_GL_ALPHA , LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Alpha8 ); - AddSimpleUnsized(fua, LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_UNSIGNED_BYTE, EffectiveFormat::Luminance8Alpha8); - } - - return true; -} - -static bool -AddUnsizedFormats(FormatUsageAuthority* fua, gl::GLContext* gl) -{ - // GLES 2.0.25, p63, Table 3.4 - AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE , EffectiveFormat::RGBA8 ); - AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_4_4_4_4, EffectiveFormat::RGBA4 ); - AddSimpleUnsized(fua, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_5_5_5_1, EffectiveFormat::RGB5_A1); - AddSimpleUnsized(fua, LOCAL_GL_RGB , LOCAL_GL_UNSIGNED_BYTE , EffectiveFormat::RGB8 ); - AddSimpleUnsized(fua, LOCAL_GL_RGB , LOCAL_GL_UNSIGNED_SHORT_5_6_5 , EffectiveFormat::RGB565 ); - - // L, A, LA - return AddLegacyFormats_LA8(fua, gl); -} - -void -FormatUsageInfo::SetRenderable() -{ - this->isRenderable = true; - -#ifdef DEBUG - const auto format = this->format; - if (format->IsColorFormat()) { - const auto& map = format->copyDecayFormats; - const auto itr = map.find(format->unsizedFormat); - MOZ_ASSERT(itr != map.end(), "Renderable formats must be in copyDecayFormats."); - MOZ_ASSERT(itr->second == format); - } -#endif -} - -UniquePtr -FormatUsageAuthority::CreateForWebGL1(gl::GLContext* gl) -{ - UniquePtr ret(new FormatUsageAuthority); - const auto ptr = ret.get(); - - //////////////////////////////////////////////////////////////////////////// - // Usages - - const auto fnSet = [ptr](EffectiveFormat effFormat, bool isRenderable, - bool isFilterable) - { - MOZ_ASSERT(!ptr->GetUsage(effFormat)); - - auto usage = ptr->EditUsage(effFormat); - usage->isFilterable = isFilterable; - - if (isRenderable) { - usage->SetRenderable(); - } - }; - - // GLES 2.0.25, p117, Table 4.5 - // RGBA8 is made renderable in WebGL 1.0, "Framebuffer Object Attachments" - // render filter - // able able - fnSet(EffectiveFormat::RGBA8 , true, true); - fnSet(EffectiveFormat::RGBA4 , true, true); - fnSet(EffectiveFormat::RGB5_A1, true, true); - fnSet(EffectiveFormat::RGB565 , true, true); - - // RGB8 is not guaranteed to be renderable, but we should allow it for web-compat. - // Min-capability mode should mark this as non-renderable. - fnSet(EffectiveFormat::RGB8, true, true); - - fnSet(EffectiveFormat::Luminance8Alpha8, false, true); - fnSet(EffectiveFormat::Luminance8 , false, true); - fnSet(EffectiveFormat::Alpha8 , false, true); - - fnSet(EffectiveFormat::DEPTH_COMPONENT16, true, false); - fnSet(EffectiveFormat::STENCIL_INDEX8 , true, false); - - // Added in WebGL 1.0 spec: - fnSet(EffectiveFormat::DEPTH24_STENCIL8, true, false); - - //////////////////////////////////// - // RB formats - -#define FOO(x) ptr->AllowRBFormat(LOCAL_GL_ ## x, ptr->GetUsage(EffectiveFormat::x)) - - FOO(RGBA4 ); - FOO(RGB5_A1 ); - FOO(RGB565 ); - FOO(DEPTH_COMPONENT16); - FOO(STENCIL_INDEX8 ); - //FOO(DEPTH24_STENCIL8 ); // WebGL 1 uses DEPTH_STENCIL instead of DEPTH24_STENCIL8. - -#undef FOO - - ptr->AllowRBFormat(LOCAL_GL_DEPTH_STENCIL, - ptr->GetUsage(EffectiveFormat::DEPTH24_STENCIL8)); - - //////////////////////////////////////////////////////////////////////////// - - if (!AddUnsizedFormats(ptr, gl)) - return nullptr; - - return Move(ret); -} - -UniquePtr -FormatUsageAuthority::CreateForWebGL2(gl::GLContext* gl) -{ - UniquePtr ret(new FormatUsageAuthority); - const auto ptr = ret.get(); - - //////////////////////////////////////////////////////////////////////////// - // GLES 3.0.4 p111-113 - - const auto fnAddSizedUnpack = [ptr](EffectiveFormat effFormat, GLenum internalFormat, - GLenum unpackFormat, GLenum unpackType) - { - auto usage = ptr->EditUsage(effFormat); - - const PackingInfo pi = {unpackFormat, unpackType}; - const DriverUnpackInfo dui = {internalFormat, unpackFormat, unpackType}; - ptr->AddTexUnpack(usage, pi, dui); - }; - -#define FOO(x) EffectiveFormat::x, LOCAL_GL_ ## x - - // RGBA - fnAddSizedUnpack(FOO(RGBA8 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGBA4 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 ); - fnAddSizedUnpack(FOO(RGBA4 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGB5_A1 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 ); - fnAddSizedUnpack(FOO(RGB5_A1 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGB5_A1 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV); - fnAddSizedUnpack(FOO(SRGB8_ALPHA8), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGBA8_SNORM ), LOCAL_GL_RGBA, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(RGB10_A2 ), LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV); - fnAddSizedUnpack(FOO(RGBA16F ), LOCAL_GL_RGBA, LOCAL_GL_HALF_FLOAT ); - fnAddSizedUnpack(FOO(RGBA16F ), LOCAL_GL_RGBA, LOCAL_GL_FLOAT ); - fnAddSizedUnpack(FOO(RGBA32F ), LOCAL_GL_RGBA, LOCAL_GL_FLOAT ); - - // RGBA_INTEGER - fnAddSizedUnpack(FOO(RGBA8UI ), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGBA8I ), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(RGBA16UI ), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_UNSIGNED_SHORT ); - fnAddSizedUnpack(FOO(RGBA16I ), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_SHORT ); - fnAddSizedUnpack(FOO(RGBA32UI ), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_UNSIGNED_INT ); - fnAddSizedUnpack(FOO(RGBA32I ), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_INT ); - fnAddSizedUnpack(FOO(RGB10_A2UI), LOCAL_GL_RGBA_INTEGER, LOCAL_GL_UNSIGNED_INT_2_10_10_10_REV); - - // RGB - fnAddSizedUnpack(FOO(RGB8 ), LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(SRGB8 ), LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGB565 ), LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_SHORT_5_6_5 ); - fnAddSizedUnpack(FOO(RGB565 ), LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGB8_SNORM ), LOCAL_GL_RGB, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(R11F_G11F_B10F), LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_INT_10F_11F_11F_REV); - fnAddSizedUnpack(FOO(R11F_G11F_B10F), LOCAL_GL_RGB, LOCAL_GL_HALF_FLOAT ); - fnAddSizedUnpack(FOO(R11F_G11F_B10F), LOCAL_GL_RGB, LOCAL_GL_FLOAT ); - fnAddSizedUnpack(FOO(RGB16F ), LOCAL_GL_RGB, LOCAL_GL_HALF_FLOAT ); - fnAddSizedUnpack(FOO(RGB16F ), LOCAL_GL_RGB, LOCAL_GL_FLOAT ); - fnAddSizedUnpack(FOO(RGB9_E5 ), LOCAL_GL_RGB, LOCAL_GL_UNSIGNED_INT_5_9_9_9_REV ); - fnAddSizedUnpack(FOO(RGB9_E5 ), LOCAL_GL_RGB, LOCAL_GL_HALF_FLOAT ); - fnAddSizedUnpack(FOO(RGB9_E5 ), LOCAL_GL_RGB, LOCAL_GL_FLOAT ); - fnAddSizedUnpack(FOO(RGB32F ), LOCAL_GL_RGB, LOCAL_GL_FLOAT ); - - // RGB_INTEGER - fnAddSizedUnpack(FOO(RGB8UI ), LOCAL_GL_RGB_INTEGER, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RGB8I ), LOCAL_GL_RGB_INTEGER, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(RGB16UI), LOCAL_GL_RGB_INTEGER, LOCAL_GL_UNSIGNED_SHORT); - fnAddSizedUnpack(FOO(RGB16I ), LOCAL_GL_RGB_INTEGER, LOCAL_GL_SHORT ); - fnAddSizedUnpack(FOO(RGB32UI), LOCAL_GL_RGB_INTEGER, LOCAL_GL_UNSIGNED_INT ); - fnAddSizedUnpack(FOO(RGB32I ), LOCAL_GL_RGB_INTEGER, LOCAL_GL_INT ); - - // RG - fnAddSizedUnpack(FOO(RG8 ), LOCAL_GL_RG, LOCAL_GL_UNSIGNED_BYTE); - fnAddSizedUnpack(FOO(RG8_SNORM), LOCAL_GL_RG, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(RG16F ), LOCAL_GL_RG, LOCAL_GL_HALF_FLOAT ); - fnAddSizedUnpack(FOO(RG16F ), LOCAL_GL_RG, LOCAL_GL_FLOAT ); - fnAddSizedUnpack(FOO(RG32F ), LOCAL_GL_RG, LOCAL_GL_FLOAT ); - - // RG_INTEGER - fnAddSizedUnpack(FOO(RG8UI ), LOCAL_GL_RG_INTEGER, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(RG8I ), LOCAL_GL_RG_INTEGER, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(RG16UI), LOCAL_GL_RG_INTEGER, LOCAL_GL_UNSIGNED_SHORT); - fnAddSizedUnpack(FOO(RG16I ), LOCAL_GL_RG_INTEGER, LOCAL_GL_SHORT ); - fnAddSizedUnpack(FOO(RG32UI), LOCAL_GL_RG_INTEGER, LOCAL_GL_UNSIGNED_INT ); - fnAddSizedUnpack(FOO(RG32I ), LOCAL_GL_RG_INTEGER, LOCAL_GL_INT ); - - // RED - fnAddSizedUnpack(FOO(R8 ), LOCAL_GL_RED, LOCAL_GL_UNSIGNED_BYTE); - fnAddSizedUnpack(FOO(R8_SNORM), LOCAL_GL_RED, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(R16F ), LOCAL_GL_RED, LOCAL_GL_HALF_FLOAT ); - fnAddSizedUnpack(FOO(R16F ), LOCAL_GL_RED, LOCAL_GL_FLOAT ); - fnAddSizedUnpack(FOO(R32F ), LOCAL_GL_RED, LOCAL_GL_FLOAT ); - - // RED_INTEGER - fnAddSizedUnpack(FOO(R8UI ), LOCAL_GL_RED_INTEGER, LOCAL_GL_UNSIGNED_BYTE ); - fnAddSizedUnpack(FOO(R8I ), LOCAL_GL_RED_INTEGER, LOCAL_GL_BYTE ); - fnAddSizedUnpack(FOO(R16UI), LOCAL_GL_RED_INTEGER, LOCAL_GL_UNSIGNED_SHORT); - fnAddSizedUnpack(FOO(R16I ), LOCAL_GL_RED_INTEGER, LOCAL_GL_SHORT ); - fnAddSizedUnpack(FOO(R32UI), LOCAL_GL_RED_INTEGER, LOCAL_GL_UNSIGNED_INT ); - fnAddSizedUnpack(FOO(R32I ), LOCAL_GL_RED_INTEGER, LOCAL_GL_INT ); - - // DEPTH_COMPONENT - fnAddSizedUnpack(FOO(DEPTH_COMPONENT16 ), LOCAL_GL_DEPTH_COMPONENT, LOCAL_GL_UNSIGNED_SHORT); - fnAddSizedUnpack(FOO(DEPTH_COMPONENT16 ), LOCAL_GL_DEPTH_COMPONENT, LOCAL_GL_UNSIGNED_INT ); - fnAddSizedUnpack(FOO(DEPTH_COMPONENT24 ), LOCAL_GL_DEPTH_COMPONENT, LOCAL_GL_UNSIGNED_INT ); - fnAddSizedUnpack(FOO(DEPTH_COMPONENT32F), LOCAL_GL_DEPTH_COMPONENT, LOCAL_GL_FLOAT ); - - // DEPTH_STENCIL - fnAddSizedUnpack(FOO(DEPTH24_STENCIL8 ), LOCAL_GL_DEPTH_STENCIL, LOCAL_GL_UNSIGNED_INT_24_8 ); - fnAddSizedUnpack(FOO(DEPTH32F_STENCIL8), LOCAL_GL_DEPTH_STENCIL, LOCAL_GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - -#undef FOO - - //////////////////////////////////////////////////////////////////////////// - - // For renderable, see GLES 3.0.4, p212 "Framebuffer Completeness" - // For filterable, see GLES 3.0.4, p161 "...a texture is complete unless..." - - const auto fnAllowES3TexFormat = [ptr](GLenum sizedFormat, EffectiveFormat effFormat, - bool isRenderable, bool isFilterable) - { - auto usage = ptr->EditUsage(effFormat); - usage->isFilterable = isFilterable; - - if (isRenderable) { - usage->SetRenderable(); - } - - ptr->AllowSizedTexFormat(sizedFormat, usage); - - if (isRenderable) { - ptr->AllowRBFormat(sizedFormat, usage); - } - }; - -#define FOO(x) LOCAL_GL_ ## x, EffectiveFormat::x - - // GLES 3.0.4, p128-129 "Required Texture Formats" - // GLES 3.0.4, p130-132, table 3.13 - // render filter - // able able - fnAllowES3TexFormat(FOO(R8 ), true , true ); - fnAllowES3TexFormat(FOO(R8_SNORM ), false, true ); - fnAllowES3TexFormat(FOO(RG8 ), true , true ); - fnAllowES3TexFormat(FOO(RG8_SNORM ), false, true ); - fnAllowES3TexFormat(FOO(RGB8 ), true , true ); - fnAllowES3TexFormat(FOO(RGB8_SNORM ), false, true ); - fnAllowES3TexFormat(FOO(RGB565 ), true , true ); - fnAllowES3TexFormat(FOO(RGBA4 ), true , true ); - fnAllowES3TexFormat(FOO(RGB5_A1 ), true , true ); - fnAllowES3TexFormat(FOO(RGBA8 ), true , true ); - fnAllowES3TexFormat(FOO(RGBA8_SNORM), false, true ); - fnAllowES3TexFormat(FOO(RGB10_A2 ), true , true ); - fnAllowES3TexFormat(FOO(RGB10_A2UI ), true , false); - - fnAllowES3TexFormat(FOO(SRGB8 ), false, true); - fnAllowES3TexFormat(FOO(SRGB8_ALPHA8), true , true); - - fnAllowES3TexFormat(FOO(R16F ), false, true); - fnAllowES3TexFormat(FOO(RG16F ), false, true); - fnAllowES3TexFormat(FOO(RGB16F ), false, true); - fnAllowES3TexFormat(FOO(RGBA16F), false, true); - - fnAllowES3TexFormat(FOO(R32F ), false, false); - fnAllowES3TexFormat(FOO(RG32F ), false, false); - fnAllowES3TexFormat(FOO(RGB32F ), false, false); - fnAllowES3TexFormat(FOO(RGBA32F), false, false); - - fnAllowES3TexFormat(FOO(R11F_G11F_B10F), false, true); - fnAllowES3TexFormat(FOO(RGB9_E5 ), false, true); - - fnAllowES3TexFormat(FOO(R8I ), true, false); - fnAllowES3TexFormat(FOO(R8UI ), true, false); - fnAllowES3TexFormat(FOO(R16I ), true, false); - fnAllowES3TexFormat(FOO(R16UI), true, false); - fnAllowES3TexFormat(FOO(R32I ), true, false); - fnAllowES3TexFormat(FOO(R32UI), true, false); - - fnAllowES3TexFormat(FOO(RG8I ), true, false); - fnAllowES3TexFormat(FOO(RG8UI ), true, false); - fnAllowES3TexFormat(FOO(RG16I ), true, false); - fnAllowES3TexFormat(FOO(RG16UI), true, false); - fnAllowES3TexFormat(FOO(RG32I ), true, false); - fnAllowES3TexFormat(FOO(RG32UI), true, false); - - fnAllowES3TexFormat(FOO(RGB8I ), false, false); - fnAllowES3TexFormat(FOO(RGB8UI ), false, false); - fnAllowES3TexFormat(FOO(RGB16I ), false, false); - fnAllowES3TexFormat(FOO(RGB16UI), false, false); - fnAllowES3TexFormat(FOO(RGB32I ), false, false); - fnAllowES3TexFormat(FOO(RGB32UI), false, false); - - fnAllowES3TexFormat(FOO(RGBA8I ), true, false); - fnAllowES3TexFormat(FOO(RGBA8UI ), true, false); - fnAllowES3TexFormat(FOO(RGBA16I ), true, false); - fnAllowES3TexFormat(FOO(RGBA16UI), true, false); - fnAllowES3TexFormat(FOO(RGBA32I ), true, false); - fnAllowES3TexFormat(FOO(RGBA32UI), true, false); - - // GLES 3.0.4, p133, table 3.14 - fnAllowES3TexFormat(FOO(DEPTH_COMPONENT16 ), true, false); - fnAllowES3TexFormat(FOO(DEPTH_COMPONENT24 ), true, false); - fnAllowES3TexFormat(FOO(DEPTH_COMPONENT32F), true, false); - fnAllowES3TexFormat(FOO(DEPTH24_STENCIL8 ), true, false); - fnAllowES3TexFormat(FOO(DEPTH32F_STENCIL8 ), true, false); - -#undef FOO - - // GLES 3.0.4, p206, "Required Renderbuffer Formats": - // "Implementations are also required to support STENCIL_INDEX8. Requesting this - // internal format for a renderbuffer will allocate at least 8 stencil bit planes." - - auto usage = ptr->EditUsage(EffectiveFormat::STENCIL_INDEX8); - usage->SetRenderable(); - ptr->AllowRBFormat(LOCAL_GL_STENCIL_INDEX8, usage); - - //////////////// - // Legacy formats - - if (!AddUnsizedFormats(ptr, gl)) - return nullptr; - - ptr->AllowRBFormat(LOCAL_GL_DEPTH_STENCIL, - ptr->GetUsage(EffectiveFormat::DEPTH24_STENCIL8)); - -//cjh if (gfxPrefs::WebGL2CompatMode()) { -// AddSimpleUnsized(ptr, LOCAL_GL_RGBA, LOCAL_GL_FLOAT, EffectiveFormat::RGBA32F); -// AddSimpleUnsized(ptr, LOCAL_GL_RGB , LOCAL_GL_FLOAT, EffectiveFormat::RGB32F ); -// -// AddSimpleUnsized(ptr, LOCAL_GL_RGBA, LOCAL_GL_HALF_FLOAT_OES, EffectiveFormat::RGBA16F); -// AddSimpleUnsized(ptr, LOCAL_GL_RGB , LOCAL_GL_HALF_FLOAT_OES, EffectiveFormat::RGB16F ); -// } - - //////////////////////////////////// - - return Move(ret); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -void -FormatUsageAuthority::AddTexUnpack(FormatUsageInfo* usage, const PackingInfo& pi, - const DriverUnpackInfo& dui) -{ - // Don't AlwaysInsert here, since we'll see duplicates from sized and unsized formats. - auto res = usage->validUnpacks.insert({ pi, dui }); - auto itr = res.first; - - if (!usage->idealUnpack) { - // First one! - usage->idealUnpack = &(itr->second); - } - - mValidTexUnpackFormats.insert(pi.format); - mValidTexUnpackTypes.insert(pi.type); -} - -static bool -Contains(const std::set& set, GLenum key) -{ - return set.find(key) != set.end(); -} - -bool -FormatUsageAuthority::IsInternalFormatEnumValid(GLenum internalFormat) const -{ - return Contains(mValidTexInternalFormats, internalFormat); -} - -bool -FormatUsageAuthority::AreUnpackEnumsValid(GLenum unpackFormat, GLenum unpackType) const -{ - return (Contains(mValidTexUnpackFormats, unpackFormat) && - Contains(mValidTexUnpackTypes, unpackType)); -} - -//////////////////// - -void -FormatUsageAuthority::AllowRBFormat(GLenum sizedFormat, const FormatUsageInfo* usage) -{ - MOZ_ASSERT(!usage->format->compression); - MOZ_ASSERT(usage->format->sizedFormat); - MOZ_ASSERT(usage->IsRenderable()); - - AlwaysInsert(mRBFormatMap, sizedFormat, usage); -} - -void -FormatUsageAuthority::AllowSizedTexFormat(GLenum sizedFormat, - const FormatUsageInfo* usage) -{ - if (usage->format->compression) { - MOZ_ASSERT(usage->isFilterable, "Compressed formats should be filterable."); - } else { - MOZ_ASSERT(usage->validUnpacks.size() && usage->idealUnpack, - "AddTexUnpack() first."); - } - - AlwaysInsert(mSizedTexFormatMap, sizedFormat, usage); - - mValidTexInternalFormats.insert(sizedFormat); -} - -void -FormatUsageAuthority::AllowUnsizedTexFormat(const PackingInfo& pi, - const FormatUsageInfo* usage) -{ - MOZ_ASSERT(!usage->format->compression); - MOZ_ASSERT(usage->validUnpacks.size() && usage->idealUnpack, "AddTexUnpack() first."); - - AlwaysInsert(mUnsizedTexFormatMap, pi, usage); - - mValidTexInternalFormats.insert(pi.format); - mValidTexUnpackFormats.insert(pi.format); - mValidTexUnpackTypes.insert(pi.type); -} - -const FormatUsageInfo* -FormatUsageAuthority::GetRBUsage(GLenum sizedFormat) const -{ - return FindOrNull(mRBFormatMap, sizedFormat); -} - -const FormatUsageInfo* -FormatUsageAuthority::GetSizedTexUsage(GLenum sizedFormat) const -{ - return FindOrNull(mSizedTexFormatMap, sizedFormat); -} - -const FormatUsageInfo* -FormatUsageAuthority::GetUnsizedTexUsage(const PackingInfo& pi) const -{ - return FindOrNull(mUnsizedTexFormatMap, pi); -} - -FormatUsageInfo* -FormatUsageAuthority::EditUsage(EffectiveFormat format) -{ - auto itr = mUsageMap.find(format); - - if (itr == mUsageMap.end()) { - const FormatInfo* formatInfo = GetFormat(format); - MOZ_RELEASE_ASSERT(formatInfo, "GFX: no format info set."); - - FormatUsageInfo usage(formatInfo); - - auto res = mUsageMap.insert({ format, usage }); -//cjh DebugOnly didInsert = res.second; -// MOZ_ASSERT(didInsert); - - itr = res.first; - } - - return &(itr->second); -} - -const FormatUsageInfo* -FormatUsageAuthority::GetUsage(EffectiveFormat format) const -{ - auto itr = mUsageMap.find(format); - if (itr == mUsageMap.end()) - return nullptr; - - return &(itr->second); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace webgl -} // namespace mozilla diff --git a/sources/firefox/WebGLFormats.h b/sources/firefox/WebGLFormats.h deleted file mode 100644 index 73dd8186..00000000 --- a/sources/firefox/WebGLFormats.h +++ /dev/null @@ -1,387 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef WEBGL_FORMATS_H_ -#define WEBGL_FORMATS_H_ - -#include -#include - -#include "mozilla/UniquePtr.h" -#include "WebGLTypes.h" - -namespace mozilla { -namespace webgl { - -typedef uint8_t EffectiveFormatValueT; - -enum class EffectiveFormat : EffectiveFormatValueT { - // GLES 3.0.4, p128-129, "Required Texture Formats" - // "Texture and renderbuffer color formats" - RGBA32I, - RGBA32UI, - RGBA16I, - RGBA16UI, - RGBA8, - RGBA8I, - RGBA8UI, - SRGB8_ALPHA8, - RGB10_A2, - RGB10_A2UI, - RGBA4, - RGB5_A1, - - RGB8, - RGB565, - - RG32I, - RG32UI, - RG16I, - RG16UI, - RG8, - RG8I, - RG8UI, - - R32I, - R32UI, - R16I, - R16UI, - R8, - R8I, - R8UI, - - // "Texture-only color formats" - RGBA32F, - RGBA16F, - RGBA8_SNORM, - - RGB32F, - RGB32I, - RGB32UI, - - RGB16F, - RGB16I, - RGB16UI, - - RGB8_SNORM, - RGB8I, - RGB8UI, - SRGB8, - - R11F_G11F_B10F, - RGB9_E5, - - RG32F, - RG16F, - RG8_SNORM, - - R32F, - R16F, - R8_SNORM, - - // "Depth formats" - DEPTH_COMPONENT32F, - DEPTH_COMPONENT24, - DEPTH_COMPONENT16, - - // "Combined depth+stencil formats" - DEPTH32F_STENCIL8, - DEPTH24_STENCIL8, - - // GLES 3.0.4, p205-206, "Required Renderbuffer Formats" - STENCIL_INDEX8, - - //////////////////////////////////// - - // GLES 3.0.4, p147, table 3.19 - // GLES 3.0.4, p286+, $C.1 "ETC Compressed Texture Image Formats" - COMPRESSED_R11_EAC, - COMPRESSED_SIGNED_R11_EAC, - COMPRESSED_RG11_EAC, - COMPRESSED_SIGNED_RG11_EAC, - COMPRESSED_RGB8_ETC2, - COMPRESSED_SRGB8_ETC2, - COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, - COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, - COMPRESSED_RGBA8_ETC2_EAC, - COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, - - // AMD_compressed_ATC_texture - ATC_RGB_AMD, - ATC_RGBA_EXPLICIT_ALPHA_AMD, - ATC_RGBA_INTERPOLATED_ALPHA_AMD, - - // EXT_texture_compression_s3tc - COMPRESSED_RGB_S3TC_DXT1_EXT, - COMPRESSED_RGBA_S3TC_DXT1_EXT, - COMPRESSED_RGBA_S3TC_DXT3_EXT, - COMPRESSED_RGBA_S3TC_DXT5_EXT, - - // EXT_texture_sRGB - COMPRESSED_SRGB_S3TC_DXT1_EXT, - COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, - COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, - COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, - - // KHR_texture_compression_astc_ldr - COMPRESSED_RGBA_ASTC_4x4_KHR, - COMPRESSED_RGBA_ASTC_5x4_KHR, - COMPRESSED_RGBA_ASTC_5x5_KHR, - COMPRESSED_RGBA_ASTC_6x5_KHR, - COMPRESSED_RGBA_ASTC_6x6_KHR, - COMPRESSED_RGBA_ASTC_8x5_KHR, - COMPRESSED_RGBA_ASTC_8x6_KHR, - COMPRESSED_RGBA_ASTC_8x8_KHR, - COMPRESSED_RGBA_ASTC_10x5_KHR, - COMPRESSED_RGBA_ASTC_10x6_KHR, - COMPRESSED_RGBA_ASTC_10x8_KHR, - COMPRESSED_RGBA_ASTC_10x10_KHR, - COMPRESSED_RGBA_ASTC_12x10_KHR, - COMPRESSED_RGBA_ASTC_12x12_KHR, - - COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, - COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, - - // IMG_texture_compression_pvrtc - COMPRESSED_RGB_PVRTC_4BPPV1, - COMPRESSED_RGBA_PVRTC_4BPPV1, - COMPRESSED_RGB_PVRTC_2BPPV1, - COMPRESSED_RGBA_PVRTC_2BPPV1, - - // OES_compressed_ETC1_RGB8_texture - ETC1_RGB8_OES, - - //////////////////////////////////// - - // GLES 3.0.4, p128, table 3.12. - Luminance8Alpha8, - Luminance8, - Alpha8, - - // OES_texture_float - Luminance32FAlpha32F, - Luminance32F, - Alpha32F, - - // OES_texture_half_float - Luminance16FAlpha16F, - Luminance16F, - Alpha16F, - - MAX, -}; - -enum class UnsizedFormat : uint8_t { - R, - RG, - RGB, - RGBA, - LA, - L, - A, - D, - S, - DEPTH_STENCIL, // `DS` is a macro on Solaris. (regset.h) -}; - -// GLES 3.0.4 p114 Table 3.4, p240 -enum class ComponentType : uint8_t { - None, - Int, // RGBA32I - UInt, // RGBA32UI, STENCIL_INDEX8 - NormInt, // RGBA8_SNORM - NormUInt, // RGBA8, DEPTH_COMPONENT16 - Float, // RGBA32F - Special, // DEPTH24_STENCIL8 -}; - -enum class CompressionFamily : uint8_t { - ASTC, - ATC, - ES3, // ETC2 or EAC - ETC1, - PVRTC, - S3TC, -}; - -//////////////////////////////////////////////////////////////////////////////// - -struct CompressedFormatInfo -{ - const EffectiveFormat effectiveFormat; - const uint8_t bytesPerBlock; - const uint8_t blockWidth; - const uint8_t blockHeight; - const CompressionFamily family; -}; - -struct FormatInfo -{ - const EffectiveFormat effectiveFormat; - const char* const name; - const GLenum sizedFormat; - const UnsizedFormat unsizedFormat; - const ComponentType componentType; - const bool isSRGB; - - const CompressedFormatInfo* const compression; - - const uint8_t estimatedBytesPerPixel; // 0 iff bool(compression). - - // In bits. Iff bool(compression), active channels are 1. - const uint8_t r; - const uint8_t g; - const uint8_t b; - const uint8_t a; - const uint8_t d; - const uint8_t s; - - ////// - - std::map copyDecayFormats; - - const FormatInfo* GetCopyDecayFormat(UnsizedFormat) const; - - bool IsColorFormat() const { - // Alpha is a 'color format' since it's 'color-attachable'. - return bool(compression) || - bool(r | g | b | a); - } -}; - -struct PackingInfo -{ - GLenum format; - GLenum type; - - bool operator <(const PackingInfo& x) const - { - if (format != x.format) - return format < x.format; - - return type < x.type; - } - - bool operator ==(const PackingInfo& x) const { - return (format == x.format && - type == x.type); - } -}; - -struct DriverUnpackInfo -{ - GLenum internalFormat; - GLenum unpackFormat; - GLenum unpackType; - - PackingInfo ToPacking() const { - return {unpackFormat, unpackType}; - } -}; - -////////////////////////////////////////////////////////////////////////////////////////// - -const FormatInfo* GetFormat(EffectiveFormat format); -uint8_t BytesPerPixel(const PackingInfo& packing); -bool GetBytesPerPixel(const PackingInfo& packing, uint8_t* const out_bytes); -/* -GLint ComponentSize(const FormatInfo* format, GLenum component); -GLenum ComponentType(const FormatInfo* format); -*/ -//////////////////////////////////////// - -struct FormatUsageInfo -{ - const FormatInfo* const format; -private: - bool isRenderable; -public: - bool isFilterable; - - std::map validUnpacks; - const DriverUnpackInfo* idealUnpack; - - const GLint* textureSwizzleRGBA; - - bool maxSamplesKnown; - uint32_t maxSamples; - - static const GLint kLuminanceSwizzleRGBA[4]; - static const GLint kAlphaSwizzleRGBA[4]; - static const GLint kLumAlphaSwizzleRGBA[4]; - - explicit FormatUsageInfo(const FormatInfo* _format) - : format(_format) - , isRenderable(false) - , isFilterable(false) - , idealUnpack(nullptr) - , textureSwizzleRGBA(nullptr) - , maxSamplesKnown(false) - , maxSamples(0) - { } - - bool IsRenderable() const { return isRenderable; } - void SetRenderable(); - - bool IsUnpackValid(const PackingInfo& key, - const DriverUnpackInfo** const out_value) const; - - void ResolveMaxSamples(gl::GLContext* gl); -}; - -class FormatUsageAuthority -{ - std::map mUsageMap; - - std::map mRBFormatMap; - std::map mSizedTexFormatMap; - std::map mUnsizedTexFormatMap; - - std::set mValidTexInternalFormats; - std::set mValidTexUnpackFormats; - std::set mValidTexUnpackTypes; - -public: - static UniquePtr CreateForWebGL1(gl::GLContext* gl); - static UniquePtr CreateForWebGL2(gl::GLContext* gl); - -private: - FormatUsageAuthority() { } - -public: - FormatUsageInfo* EditUsage(EffectiveFormat format); - const FormatUsageInfo* GetUsage(EffectiveFormat format) const; - - void AddTexUnpack(FormatUsageInfo* usage, const PackingInfo& pi, - const DriverUnpackInfo& dui); - - bool IsInternalFormatEnumValid(GLenum internalFormat) const; - bool AreUnpackEnumsValid(GLenum unpackFormat, GLenum unpackType) const; - - void AllowRBFormat(GLenum sizedFormat, const FormatUsageInfo* usage); - void AllowSizedTexFormat(GLenum sizedFormat, const FormatUsageInfo* usage); - void AllowUnsizedTexFormat(const PackingInfo& pi, const FormatUsageInfo* usage); - - const FormatUsageInfo* GetRBUsage(GLenum sizedFormat) const; - const FormatUsageInfo* GetSizedTexUsage(GLenum sizedFormat) const; - const FormatUsageInfo* GetUnsizedTexUsage(const PackingInfo& pi) const; -}; - -} // namespace webgl -} // namespace mozilla - -#endif // WEBGL_FORMATS_H_ diff --git a/sources/firefox/WebGLTexelConversions.cpp b/sources/firefox/WebGLTexelConversions.cpp deleted file mode 100644 index 88334150..00000000 --- a/sources/firefox/WebGLTexelConversions.cpp +++ /dev/null @@ -1,435 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -//cjh #include "WebGLContext.h" -#include "WebGLTexelConversions.h" -#include - -namespace mozilla { - -using namespace WebGLTexelConversions; - -namespace { - -/** @class WebGLImageConverter - * - * This class is just a helper to implement WebGLContext::ConvertImage below. - * - * Design comments: - * - * WebGLContext::ConvertImage has to handle hundreds of format conversion paths. - * It is important to minimize executable code size here. Instead of passing around - * a large number of function parameters hundreds of times, we create a - * WebGLImageConverter object once, storing these parameters, and then we call - * the run() method on it. - */ -class WebGLImageConverter -{ - const size_t mWidth, mHeight; - const void* const mSrcStart; - void* const mDstStart; - const ptrdiff_t mSrcStride, mDstStride; - bool mAlreadyRun; - bool mSuccess; - - /* - * Returns sizeof(texel)/sizeof(type). The point is that we will iterate over - * texels with typed pointers and this value will tell us by how much we need - * to increment these pointers to advance to the next texel. - */ - template - static size_t NumElementsPerTexelForFormat() { - switch (Format) { - case WebGLTexelFormat::A8: - case WebGLTexelFormat::A16F: - case WebGLTexelFormat::A32F: - case WebGLTexelFormat::R8: - case WebGLTexelFormat::R16F: - case WebGLTexelFormat::R32F: - case WebGLTexelFormat::RGB565: - case WebGLTexelFormat::RGB11F11F10F: - case WebGLTexelFormat::RGBA4444: - case WebGLTexelFormat::RGBA5551: - return 1; - case WebGLTexelFormat::RA8: - case WebGLTexelFormat::RA16F: - case WebGLTexelFormat::RA32F: - case WebGLTexelFormat::RG8: - case WebGLTexelFormat::RG16F: - case WebGLTexelFormat::RG32F: - return 2; - case WebGLTexelFormat::RGB8: - case WebGLTexelFormat::RGB16F: - case WebGLTexelFormat::RGB32F: - return 3; - case WebGLTexelFormat::RGBA8: - case WebGLTexelFormat::RGBA16F: - case WebGLTexelFormat::RGBA32F: - case WebGLTexelFormat::BGRX8: - case WebGLTexelFormat::BGRA8: - return 4; - default: - MOZ_ASSERT(false, "Unknown texel format. Coding mistake?"); - return 0; - } - } - - /* - * This is the completely format-specific templatized conversion function, - * that will be instantiated hundreds of times for all different combinations. - * It is important to avoid generating useless code here. In particular, many - * instantiations of this function template will never be called, so we try - * to return immediately in these cases to allow the compiler to avoid generating - * useless code. - */ - template - void run() - { - // check for never-called cases. We early-return to allow the compiler - // to avoid generating this code. It would be tempting to abort() instead, - // as returning early does leave the destination surface with uninitialized - // data, but that would not allow the compiler to avoid generating this code. - // So instead, we return early, so Success() will return false, and the caller - // must check that and abort in that case. See WebGLContext::ConvertImage. - - if (SrcFormat == DstFormat && - PremultiplicationOp == WebGLTexelPremultiplicationOp::None) - { - // Should have used a fast exit path earlier, rather than entering this function. - // we explicitly return here to allow the compiler to avoid generating this code - return; - } - - // Only textures uploaded from DOM elements or ImageData can allow DstFormat != SrcFormat. - // DOM elements can only give BGRA8, BGRX8, A8, RGB565 formats. See DOMElementToImageSurface. - // ImageData is always RGBA8. So all other SrcFormat will always satisfy DstFormat==SrcFormat, - // so we can avoid compiling the code for all the unreachable paths. -//cjh const bool CanSrcFormatComeFromDOMElementOrImageData -// = SrcFormat == WebGLTexelFormat::BGRA8 || -// SrcFormat == WebGLTexelFormat::BGRX8 || -// SrcFormat == WebGLTexelFormat::A8 || -// SrcFormat == WebGLTexelFormat::RGB565 || -// SrcFormat == WebGLTexelFormat::RGBA8; -// if (!CanSrcFormatComeFromDOMElementOrImageData && -// SrcFormat != DstFormat) -// { -// return; -// } -// -// // Likewise, only textures uploaded from DOM elements or ImageData can possibly have to be unpremultiplied. -// if (!CanSrcFormatComeFromDOMElementOrImageData && -// PremultiplicationOp == WebGLTexelPremultiplicationOp::Unpremultiply) -// { -// return; -// } - - // there is no point in premultiplication/unpremultiplication - // in the following cases: - // - the source format has no alpha - // - the source format has no color - // - the destination format has no color - if (!HasAlpha(SrcFormat) || - !HasColor(SrcFormat) || - !HasColor(DstFormat)) - { - - if (PremultiplicationOp != WebGLTexelPremultiplicationOp::None) - { - return; - } - } - - // end of early return cases. - - MOZ_ASSERT(!mAlreadyRun, "converter should be run only once!"); - mAlreadyRun = true; - - // gather some compile-time meta-data about the formats at hand. - - typedef - typename DataTypeForFormat::Type - SrcType; - typedef - typename DataTypeForFormat::Type - DstType; - - const WebGLTexelFormat IntermediateSrcFormat - = IntermediateFormat::Value; - const WebGLTexelFormat IntermediateDstFormat - = IntermediateFormat::Value; - typedef - typename DataTypeForFormat::Type - IntermediateSrcType; - typedef - typename DataTypeForFormat::Type - IntermediateDstType; - - const size_t NumElementsPerSrcTexel = NumElementsPerTexelForFormat(); - const size_t NumElementsPerDstTexel = NumElementsPerTexelForFormat(); - const size_t MaxElementsPerTexel = 4; - MOZ_ASSERT(NumElementsPerSrcTexel <= MaxElementsPerTexel, "unhandled format"); - MOZ_ASSERT(NumElementsPerDstTexel <= MaxElementsPerTexel, "unhandled format"); - - // we assume that the strides are multiples of the sizeof of respective types. - // this assumption will allow us to iterate over src and dst images using typed - // pointers, e.g. uint8_t* or uint16_t* or float*, instead of untyped pointers. - // So this assumption allows us to write cleaner and safer code, but it might - // not be true forever and if it eventually becomes wrong, we'll have to revert - // to always iterating using uint8_t* pointers regardless of the types at hand. - MOZ_ASSERT(mSrcStride % sizeof(SrcType) == 0 && - mDstStride % sizeof(DstType) == 0, - "Unsupported: texture stride is not a multiple of sizeof(type)"); - const ptrdiff_t srcStrideInElements = mSrcStride / sizeof(SrcType); - const ptrdiff_t dstStrideInElements = mDstStride / sizeof(DstType); - - const SrcType* srcRowStart = static_cast(mSrcStart); - DstType* dstRowStart = static_cast(mDstStart); - - // the loop performing the texture format conversion - for (size_t i = 0; i < mHeight; ++i) { - const SrcType* srcRowEnd = srcRowStart + mWidth * NumElementsPerSrcTexel; - const SrcType* srcPtr = srcRowStart; - DstType* dstPtr = dstRowStart; - while (srcPtr != srcRowEnd) { - // convert a single texel. We proceed in 3 steps: unpack the source texel - // so the corresponding interchange format (e.g. unpack RGB565 to RGBA8), - // convert the resulting data type to the destination type (e.g. convert - // from RGBA8 to RGBA32F), and finally pack the destination texel - // (e.g. pack RGBA32F to RGB32F). - IntermediateSrcType unpackedSrc[MaxElementsPerTexel]; - IntermediateDstType unpackedDst[MaxElementsPerTexel]; - - // unpack a src texel to corresponding intermediate src format. - // for example, unpack RGB565 to RGBA8 - unpack(srcPtr, unpackedSrc); - // convert the data type to the destination type, if needed. - // for example, convert RGBA8 to RGBA32F - convertType(unpackedSrc, unpackedDst); - // pack the destination texel. - // for example, pack RGBA32F to RGB32F -// pack(unpackedDst, dstPtr); - - srcPtr += NumElementsPerSrcTexel; - dstPtr += NumElementsPerDstTexel; - } - srcRowStart += srcStrideInElements; - dstRowStart += dstStrideInElements; - } - - mSuccess = true; - } - - template - void run(WebGLTexelPremultiplicationOp premultiplicationOp) - { - #define WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(PremultiplicationOp) \ - case PremultiplicationOp: \ - return run(); - - switch (premultiplicationOp) { - WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(WebGLTexelPremultiplicationOp::None) - WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(WebGLTexelPremultiplicationOp::Premultiply) - WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP(WebGLTexelPremultiplicationOp::Unpremultiply) - default: - MOZ_ASSERT(false, "unhandled case. Coding mistake?"); - } - - #undef WEBGLIMAGECONVERTER_CASE_PREMULTIPLICATIONOP - } - - template - void run(WebGLTexelFormat dstFormat, - WebGLTexelPremultiplicationOp premultiplicationOp) - { - #define WEBGLIMAGECONVERTER_CASE_DSTFORMAT(DstFormat) \ - case DstFormat: \ - return run(premultiplicationOp); - - switch (dstFormat) { - // 1-channel formats - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::A8) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::A16F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::A32F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::R8) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::R16F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::R32F) - // 2-channel formats - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RA8) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RA16F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RA32F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RG8) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RG16F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RG32F) - // 3-channel formats - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB565) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB8) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB11F11F10F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB16F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB32F) - // 4-channel formats - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA4444) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA5551) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA8) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA16F) - WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGBA32F) - - default: - MOZ_ASSERT(false, "unhandled case. Coding mistake?"); - } - - #undef WEBGLIMAGECONVERTER_CASE_DSTFORMAT - } - -public: - - void run(WebGLTexelFormat srcFormat, - WebGLTexelFormat dstFormat, - WebGLTexelPremultiplicationOp premultiplicationOp) - { - #define WEBGLIMAGECONVERTER_CASE_SRCFORMAT(SrcFormat) \ - case SrcFormat: \ - return run(dstFormat, premultiplicationOp); - - switch (srcFormat) { - // 1-channel formats - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::A8) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::A16F) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::A32F) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::R8) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::R16F) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::R32F) - // 2-channel formats - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RA8) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RA16F) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RA32F) - // 3-channel formats - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB565) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB8) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB16F) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGB32F) - // 4-channel formats - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA4444) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA5551) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA8) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA16F) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::RGBA32F) - // DOM element source formats - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::BGRX8) - WEBGLIMAGECONVERTER_CASE_SRCFORMAT(WebGLTexelFormat::BGRA8) - - default: - MOZ_ASSERT(false, "unhandled case. Coding mistake?"); - } - - #undef WEBGLIMAGECONVERTER_CASE_SRCFORMAT - } - - WebGLImageConverter(size_t width, size_t height, - const void* srcStart, void* dstStart, - ptrdiff_t srcStride, ptrdiff_t dstStride) - : mWidth(width), mHeight(height), - mSrcStart(srcStart), mDstStart(dstStart), - mSrcStride(srcStride), mDstStride(dstStride), - mAlreadyRun(false), mSuccess(false) - {} - - bool Success() const { - return mSuccess; - } -}; - -} // end anonymous namespace - -bool -ConvertImage(size_t width, size_t height, - const void* srcBegin, size_t srcStride, gl::OriginPos srcOrigin, - WebGLTexelFormat srcFormat, bool srcPremultiplied, - void* dstBegin, size_t dstStride, gl::OriginPos dstOrigin, - WebGLTexelFormat dstFormat, bool dstPremultiplied, - bool* const out_wasTrivial) -{ - *out_wasTrivial = true; - - if (srcFormat == WebGLTexelFormat::FormatNotSupportingAnyConversion || - dstFormat == WebGLTexelFormat::FormatNotSupportingAnyConversion) - { - return false; - } - - if (!width || !height) - return true; - - const bool shouldYFlip = (srcOrigin != dstOrigin); - - const bool canSkipPremult = (!HasAlpha(srcFormat) || - !HasColor(srcFormat) || - !HasColor(dstFormat)); - - WebGLTexelPremultiplicationOp premultOp; - if (canSkipPremult) { - premultOp = WebGLTexelPremultiplicationOp::None; - } else if (!srcPremultiplied && dstPremultiplied) { - premultOp = WebGLTexelPremultiplicationOp::Premultiply; - } else if (srcPremultiplied && !dstPremultiplied) { - premultOp = WebGLTexelPremultiplicationOp::Unpremultiply; - } else { - premultOp = WebGLTexelPremultiplicationOp::None; - } - - const uint8_t* srcItr = (const uint8_t*)srcBegin; - const uint8_t* const srcEnd = srcItr + srcStride * height; - uint8_t* dstItr = (uint8_t*)dstBegin; - ptrdiff_t dstItrStride = dstStride; - if (shouldYFlip) { - dstItr = dstItr + dstStride * (height - 1); - dstItrStride = -dstItrStride; - } - - if (srcFormat == dstFormat && premultOp == WebGLTexelPremultiplicationOp::None) { - // Fast exit path: we just have to memcpy all the rows. - // - // The case where absolutely nothing needs to be done is supposed to have - // been handled earlier (in TexImage2D_base, etc). - // - // So the case we're handling here is when even though no format conversion is - // needed, we still might have to flip vertically and/or to adjust to a different - // stride. - - // We ignore canSkipPremult for this perf trap, since it's an avoidable perf cliff - // under the WebGL API user's control. - MOZ_ASSERT((srcPremultiplied != dstPremultiplied || - shouldYFlip || - srcStride != dstStride), - "Performance trap -- should handle this case earlier to avoid memcpy"); - - const auto bytesPerPixel = TexelBytesForFormat(srcFormat); - const size_t bytesPerRow = bytesPerPixel * width; - - while (srcItr != srcEnd) { - memcpy(dstItr, srcItr, bytesPerRow); - srcItr += srcStride; - dstItr += dstItrStride; - } - return true; - } - - *out_wasTrivial = false; - - WebGLImageConverter converter(width, height, srcItr, dstItr, srcStride, dstItrStride); - converter.run(srcFormat, dstFormat, premultOp); - - if (!converter.Success()) { - // the dst image may be left uninitialized, so we better not try to - // continue even in release builds. This should never happen anyway, - // and would be a bug in our code. - MOZ_CRASH("programming mistake in WebGL texture conversions"); - } - - return true; -} - -} // end namespace mozilla diff --git a/sources/firefox/WebGLTexelConversions.h b/sources/firefox/WebGLTexelConversions.h deleted file mode 100644 index b5cdb5dd..00000000 --- a/sources/firefox/WebGLTexelConversions.h +++ /dev/null @@ -1,1354 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * Copyright (C) 2010 Google Inc. All rights reserved. - * Copyright (C) 2010 Mozilla Corporation. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WEBGLTEXELCONVERSIONS_H_ -#define WEBGLTEXELCONVERSIONS_H_ - -#ifdef __SUNPRO_CC -#define __restrict -#endif - -#include "WebGLTypes.h" -#include -#include "mozilla/Attributes.h" -#include "mozilla/Casting.h" - -namespace mozilla { - - // Added from gfx/gl/GLContextTypes.h - namespace gl { - enum class OriginPos : uint8_t { - TopLeft, - BottomLeft - }; - } - // - -bool ConvertImage(size_t width, size_t height, - const void* srcBegin, size_t srcStride, gl::OriginPos srcOrigin, - WebGLTexelFormat srcFormat, bool srcPremultiplied, - void* dstBegin, size_t dstStride, gl::OriginPos dstOrigin, - WebGLTexelFormat dstFormat, bool dstPremultiplied, - bool* out_wasTrivial); - -////////////////////////////////////////////////////////////////////////////////////////// - -// single precision float -// seeeeeeeemmmmmmmmmmmmmmmmmmmmmmm - -// half precision float -// seeeeemmmmmmmmmm - -// IEEE 16bits floating point: -const uint16_t kFloat16Value_Zero = 0x0000; // = 0000000000000000b -const uint16_t kFloat16Value_One = 0x3C00; // = 0011110000000000b -const uint16_t kFloat16Value_Infinity = 0x7C00; // = 0111110000000000b -const uint16_t kFloat16Value_NaN = 0x7FFF; // = 011111yyyyyyyyyyb (nonzero y) - -MOZ_ALWAYS_INLINE uint16_t -packToFloat16(float v) -{ - union { - float f32Value; - uint32_t f32Bits; - }; - - f32Value = v; - - // pull the sign from v into f16bits - uint16_t f16Bits = uint16_t(f32Bits >> 16) & 0x8000; - const uint32_t mantissa = f32Bits & 0x7FFFFF; - const uint32_t exp = (f32Bits >> 23) & 0xFF; - - // Adapted from: OpenGL ES 2.0 Programming Guide Appx. - // Converting Float to Half-Float - // 143 = 255 - 127 + 15 - // = sp_max - sp_bias + hp_bias - if (exp >= 143) { - if (mantissa && exp == 0xFF) { - // Single precision was NaN - return f16Bits | kFloat16Value_NaN; - } else { - // Outside range, store as infinity - return f16Bits | kFloat16Value_Infinity; - } - } - - // too small, try to make a denormalized number - // 112 = 255 - 127 - (15 + 1) - // = sp_max - sp_bias - (hp_bias + 1) - if (exp <= 112) { - return f16Bits | uint16_t(mantissa >> (14 + 112 - exp)); - } - - f16Bits |= uint16_t(exp - 112) << 10; - f16Bits |= uint16_t(mantissa >> 13) & 0x03FF; - - return f16Bits; -} - -MOZ_ALWAYS_INLINE float -unpackFromFloat16(uint16_t v) -{ - union { - float f32Value; - uint32_t f32Bits; - }; - - // grab sign bit - f32Bits = uint32_t(v & 0x8000) << 16; - uint16_t exp = (v >> 10) & 0x001F; - uint16_t mantissa = v & 0x03FF; - - if (!exp) { - // Handle denormalized numbers - // Adapted from: OpenGL ES 2.0 Programming Guide Appx. - // Converting Float to Half-Float - if (mantissa) { - exp = 112; // See packToFloat16 - mantissa <<= 1; - // For every leading zero, decrement the exponent - // and shift the mantissa to the left - while ((mantissa & (1 << 10)) == 0) { - mantissa <<= 1; - --exp; - } - mantissa &= 0x03FF; - - f32Bits |= (exp << 23) | (mantissa << 13); - - // Denormalized number - return f32Value; - } - - // +/- zero - return f32Value; - } - - if (exp == 0x001F) { - if (v & 0x03FF) { - // this is a NaN - f32Bits |= 0x7FFFFFFF; - } else { - // this is -inf or +inf - f32Bits |= 0x7F800000; - } - return f32Value; - } - - f32Bits |= uint32_t(exp + (-15 + 127)) << 23; - f32Bits |= uint32_t(v & 0x03FF) << 13; - - return f32Value; -} - -// These routines come from angle/common/mathutil.h -// They are copied here to remove the dependency on ANGLE headers -// included from mathutil.h -MOZ_ALWAYS_INLINE uint16_t -packToFloat11(float fp32) -{ - const unsigned int float32MantissaMask = 0x7FFFFF; - const unsigned int float32ExponentMask = 0x7F800000; - const unsigned int float32SignMask = 0x80000000; - const unsigned int float32ValueMask = ~float32SignMask; - const unsigned int float32ExponentFirstBit = 23; - const unsigned int float32ExponentBias = 127; - - const unsigned short float11Max = 0x7BF; - const unsigned short float11MantissaMask = 0x3F; - const unsigned short float11ExponentMask = 0x7C0; - const unsigned short float11BitMask = 0x7FF; - const unsigned int float11ExponentBias = 14; - - const unsigned int float32Maxfloat11 = 0x477E0000; - const unsigned int float32Minfloat11 = 0x38800000; - - const unsigned int float32Bits = BitwiseCast(fp32); - const bool float32Sign = (float32Bits & float32SignMask) == float32SignMask; - - unsigned int float32Val = float32Bits & float32ValueMask; - - if ((float32Val & float32ExponentMask) == float32ExponentMask) - { - // INF or NAN - if ((float32Val & float32MantissaMask) != 0) - { - return float11ExponentMask | (((float32Val >> 17) | (float32Val >> 11) | (float32Val >> 6) | (float32Val)) & float11MantissaMask); - } - else if (float32Sign) - { - // -INF is clamped to 0 since float11 is positive only - return 0; - } - else - { - return float11ExponentMask; - } - } - else if (float32Sign) - { - // float11 is positive only, so clamp to zero - return 0; - } - else if (float32Val > float32Maxfloat11) - { - // The number is too large to be represented as a float11, set to max - return float11Max; - } - else - { - if (float32Val < float32Minfloat11) - { - // The number is too small to be represented as a normalized float11 - // Convert it to a denormalized value. - const unsigned int shift = (float32ExponentBias - float11ExponentBias) - (float32Val >> float32ExponentFirstBit); - float32Val = ((1 << float32ExponentFirstBit) | (float32Val & float32MantissaMask)) >> shift; - } - else - { - // Rebias the exponent to represent the value as a normalized float11 - float32Val += 0xC8000000; - } - - return ((float32Val + 0xFFFF + ((float32Val >> 17) & 1)) >> 17) & float11BitMask; - } -} - -MOZ_ALWAYS_INLINE uint16_t -packToFloat10(float fp32) -{ - const unsigned int float32MantissaMask = 0x7FFFFF; - const unsigned int float32ExponentMask = 0x7F800000; - const unsigned int float32SignMask = 0x80000000; - const unsigned int float32ValueMask = ~float32SignMask; - const unsigned int float32ExponentFirstBit = 23; - const unsigned int float32ExponentBias = 127; - - const unsigned short float10Max = 0x3DF; - const unsigned short float10MantissaMask = 0x1F; - const unsigned short float10ExponentMask = 0x3E0; - const unsigned short float10BitMask = 0x3FF; - const unsigned int float10ExponentBias = 14; - - const unsigned int float32Maxfloat10 = 0x477C0000; - const unsigned int float32Minfloat10 = 0x38800000; - - const unsigned int float32Bits = BitwiseCast(fp32); - const bool float32Sign = (float32Bits & float32SignMask) == float32SignMask; - - unsigned int float32Val = float32Bits & float32ValueMask; - - if ((float32Val & float32ExponentMask) == float32ExponentMask) - { - // INF or NAN - if ((float32Val & float32MantissaMask) != 0) - { - return float10ExponentMask | (((float32Val >> 18) | (float32Val >> 13) | (float32Val >> 3) | (float32Val)) & float10MantissaMask); - } - else if (float32Sign) - { - // -INF is clamped to 0 since float11 is positive only - return 0; - } - else - { - return float10ExponentMask; - } - } - else if (float32Sign) - { - // float10 is positive only, so clamp to zero - return 0; - } - else if (float32Val > float32Maxfloat10) - { - // The number is too large to be represented as a float11, set to max - return float10Max; - } - else - { - if (float32Val < float32Minfloat10) - { - // The number is too small to be represented as a normalized float11 - // Convert it to a denormalized value. - const unsigned int shift = (float32ExponentBias - float10ExponentBias) - (float32Val >> float32ExponentFirstBit); - float32Val = ((1 << float32ExponentFirstBit) | (float32Val & float32MantissaMask)) >> shift; - } - else - { - // Rebias the exponent to represent the value as a normalized float11 - float32Val += 0xC8000000; - } - - return ((float32Val + 0x1FFFF + ((float32Val >> 18) & 1)) >> 18) & float10BitMask; - } -} - - -enum class WebGLTexelPremultiplicationOp : int { - None, - Premultiply, - Unpremultiply -}; - -namespace WebGLTexelConversions { - -template -struct IsFloatFormat -{ - static const bool Value = - Format == WebGLTexelFormat::A32F || - Format == WebGLTexelFormat::R32F || - Format == WebGLTexelFormat::RA32F || - Format == WebGLTexelFormat::RG32F || - Format == WebGLTexelFormat::RGB11F11F10F || - Format == WebGLTexelFormat::RGB32F || - Format == WebGLTexelFormat::RGBA32F; -}; - -template -struct IsHalfFloatFormat -{ - static const bool Value = - Format == WebGLTexelFormat::A16F || - Format == WebGLTexelFormat::R16F || - Format == WebGLTexelFormat::RA16F || - Format == WebGLTexelFormat::RG16F || - Format == WebGLTexelFormat::RGB16F || - Format == WebGLTexelFormat::RGBA16F; -}; - -template -struct Is16bppFormat -{ - static const bool Value = - Format == WebGLTexelFormat::RGB565 || - Format == WebGLTexelFormat::RGBA4444 || - Format == WebGLTexelFormat::RGBA5551; -}; - -template::Value, - bool Is16bpp = Is16bppFormat::Value, - bool IsHalfFloat = IsHalfFloatFormat::Value> -struct DataTypeForFormat -{ - typedef uint8_t Type; -}; - -template -struct DataTypeForFormat -{ - typedef float Type; -}; - -template -struct DataTypeForFormat -{ - typedef uint16_t Type; -}; - -template -struct DataTypeForFormat -{ - typedef uint16_t Type; -}; - -template<> -struct DataTypeForFormat -{ - typedef uint32_t Type; -}; - -template -struct IntermediateFormat -{ - static const WebGLTexelFormat Value - = IsFloatFormat::Value - ? WebGLTexelFormat::RGBA32F - : IsHalfFloatFormat::Value ? WebGLTexelFormat::RGBA16F - : WebGLTexelFormat::RGBA8; -}; - -inline size_t TexelBytesForFormat(WebGLTexelFormat format) { - switch (format) { - case WebGLTexelFormat::A8: - case WebGLTexelFormat::R8: - return 1; - case WebGLTexelFormat::A16F: - case WebGLTexelFormat::R16F: - case WebGLTexelFormat::RA8: - case WebGLTexelFormat::RG8: - case WebGLTexelFormat::RGB565: - case WebGLTexelFormat::RGBA4444: - case WebGLTexelFormat::RGBA5551: - return 2; - case WebGLTexelFormat::RGB8: - return 3; - case WebGLTexelFormat::A32F: - case WebGLTexelFormat::R32F: - case WebGLTexelFormat::RA16F: - case WebGLTexelFormat::RG16F: - case WebGLTexelFormat::RGB11F11F10F: - case WebGLTexelFormat::RGBA8: - case WebGLTexelFormat::BGRX8: - case WebGLTexelFormat::BGRA8: - return 4; - case WebGLTexelFormat::RGB16F: - return 6; - case WebGLTexelFormat::RA32F: - case WebGLTexelFormat::RG32F: - case WebGLTexelFormat::RGBA16F: - return 8; - case WebGLTexelFormat::RGB32F: - return 12; - case WebGLTexelFormat::RGBA32F: - return 16; - default: - MOZ_ASSERT(false, "Unknown texel format. Coding mistake?"); - return 0; - } -} - -MOZ_ALWAYS_INLINE bool HasAlpha(WebGLTexelFormat format) { - return (format == WebGLTexelFormat::A8 || - format == WebGLTexelFormat::A16F || - format == WebGLTexelFormat::A32F || - format == WebGLTexelFormat::RA8 || - format == WebGLTexelFormat::RA16F || - format == WebGLTexelFormat::RA32F || - format == WebGLTexelFormat::RGBA4444 || - format == WebGLTexelFormat::RGBA5551 || - format == WebGLTexelFormat::RGBA8 || - format == WebGLTexelFormat::RGBA16F || - format == WebGLTexelFormat::RGBA32F || - format == WebGLTexelFormat::BGRA8); -} - -MOZ_ALWAYS_INLINE bool HasColor(WebGLTexelFormat format) { - return (format == WebGLTexelFormat::R8 || - format == WebGLTexelFormat::R16F || - format == WebGLTexelFormat::R32F || - format == WebGLTexelFormat::RA8 || - format == WebGLTexelFormat::RA16F || - format == WebGLTexelFormat::RA32F || - format == WebGLTexelFormat::RG8 || - format == WebGLTexelFormat::RG16F || - format == WebGLTexelFormat::RG32F || - format == WebGLTexelFormat::RGB565 || - format == WebGLTexelFormat::RGB8 || - format == WebGLTexelFormat::RGB11F11F10F || - format == WebGLTexelFormat::RGB16F || - format == WebGLTexelFormat::RGB32F || - format == WebGLTexelFormat::RGBA4444 || - format == WebGLTexelFormat::RGBA5551 || - format == WebGLTexelFormat::RGBA8 || - format == WebGLTexelFormat::RGBA16F || - format == WebGLTexelFormat::RGBA32F || - format == WebGLTexelFormat::BGRX8 || - format == WebGLTexelFormat::BGRA8); -} - -/****** BEGIN CODE SHARED WITH WEBKIT ******/ - -// the pack/unpack functions here are originally from this file: -// http://trac.webkit.org/browser/trunk/WebCore/platform/graphics/GraphicsContext3D.cpp - -//---------------------------------------------------------------------- -// Pixel unpacking routines. - -template -MOZ_ALWAYS_INLINE void -unpack(const SrcType* __restrict src, - DstType* __restrict dst) -{ - MOZ_ASSERT(false, "Unimplemented texture format conversion"); -} - -//////////////////////////////////////////////////////////////////////////////// -// 1-channel formats -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = 0; - dst[1] = 0; - dst[2] = 0; - dst[3] = src[0]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = kFloat16Value_Zero; - dst[1] = kFloat16Value_Zero; - dst[2] = kFloat16Value_Zero; - dst[3] = src[0]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = 0; - dst[1] = 0; - dst[2] = 0; - dst[3] = src[0]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[0]; - dst[2] = src[0]; - dst[3] = 0xFF; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[0]; - dst[2] = src[0]; - dst[3] = kFloat16Value_One; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[0]; - dst[2] = src[0]; - dst[3] = 1.0f; -} - -//////////////////////////////////////////////////////////////////////////////// -// 2-channel formats -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[0]; - dst[2] = src[0]; - dst[3] = src[1]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[0]; - dst[2] = src[0]; - dst[3] = src[1]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[0]; - dst[2] = src[0]; - dst[3] = src[1]; -} - -//////////////////////////////////////////////////////////////////////////////// -// 3-channel formats -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint8_t* __restrict dst) -{ - uint16_t packedValue = src[0]; - uint8_t r = (packedValue >> 11) & 0x1F; - uint8_t g = (packedValue >> 5) & 0x3F; - uint8_t b = packedValue & 0x1F; - dst[0] = (r << 3) | (r & 0x7); - dst[1] = (g << 2) | (g & 0x3); - dst[2] = (b << 3) | (b & 0x7); - dst[3] = 0xFF; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = 0xFF; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = kFloat16Value_One; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = 1.0f; -} - -//////////////////////////////////////////////////////////////////////////////// -// 4-channel formats -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint8_t* __restrict dst) -{ - uint16_t packedValue = src[0]; - uint8_t r = (packedValue >> 12) & 0x0F; - uint8_t g = (packedValue >> 8) & 0x0F; - uint8_t b = (packedValue >> 4) & 0x0F; - uint8_t a = packedValue & 0x0F; - dst[0] = (r << 4) | r; - dst[1] = (g << 4) | g; - dst[2] = (b << 4) | b; - dst[3] = (a << 4) | a; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint8_t* __restrict dst) -{ - uint16_t packedValue = src[0]; - uint8_t r = (packedValue >> 11) & 0x1F; - uint8_t g = (packedValue >> 6) & 0x1F; - uint8_t b = (packedValue >> 1) & 0x1F; - dst[0] = (r << 3) | (r & 0x7); - dst[1] = (g << 3) | (g & 0x7); - dst[2] = (b << 3) | (b & 0x7); - dst[3] = (packedValue & 0x1) ? 0xFF : 0; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -//////////////////////////////////////////////////////////////////////////////// -// DOM element formats -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = 0xFF; -} - -template<> MOZ_ALWAYS_INLINE void -unpack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = src[3]; -} - -//---------------------------------------------------------------------- -// Pixel packing routines. -// - -template -MOZ_ALWAYS_INLINE void -pack(const SrcType* __restrict src, - DstType* __restrict dst) -{ - MOZ_CRASH("GFX: Unimplemented texture format conversion"); -} - -//////////////////////////////////////////////////////////////////////////////// -// 1-channel formats -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - dst[0] = srcR; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - dst[0] = srcR; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = unpackFromFloat16(src[3]); - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float unpackedAlpha = unpackFromFloat16(src[3]); - float scaleFactor = unpackedAlpha ? 1.0f / unpackedAlpha : 1.0f; - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3]; - dst[0] = src[0] * scaleFactor; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f; - dst[0] = src[0] * scaleFactor; -} - -//////////////////////////////////////////////////////////////////////////////// -// 2-channel formats -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - dst[0] = srcR; - dst[1] = src[3]; -} - -// FIXME: this routine is lossy and must be removed. -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - dst[0] = srcR; - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = unpackFromFloat16(src[3]); - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float unpackedAlpha = unpackFromFloat16(src[3]); - float scaleFactor = unpackedAlpha ? 1.0f / unpackedAlpha : 1.0f; - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3]; - dst[0] = src[0] * scaleFactor; - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f; - dst[0] = src[0] * scaleFactor; - dst[1] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - dst[0] = srcR; - dst[1] = srcG; -} - -// FIXME: this routine is lossy and must be removed. -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - dst[0] = srcR; - dst[1] = srcG; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = unpackFromFloat16(src[3]); - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float unpackedAlpha = unpackFromFloat16(src[3]); - float scaleFactor = unpackedAlpha ? 1.0f / unpackedAlpha : 1.0f; - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3]; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; -} - -//////////////////////////////////////////////////////////////////////////////// -// 3-channel formats -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - *dst = ( ((src[0] & 0xF8) << 8) - | ((src[1] & 0xFC) << 3) - | ((src[2] & 0xF8) >> 3)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = ( ((srcR & 0xF8) << 8) - | ((srcG & 0xFC) << 3) - | ((srcB & 0xF8) >> 3)); -} - -// FIXME: this routine is lossy and must be removed. -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = ( ((srcR & 0xF8) << 8) - | ((srcG & 0xFC) << 3) - | ((srcB & 0xF8) >> 3)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - dst[0] = srcR; - dst[1] = srcG; - dst[2] = srcB; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - dst[0] = srcR; - dst[1] = srcG; - dst[2] = srcB; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, uint32_t* __restrict dst) -{ - dst[0] = ((packToFloat11(src[0]) << 0) | - (packToFloat11(src[1]) << 11) | - (packToFloat10(src[2]) << 22)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, uint32_t* __restrict dst) -{ - float scaleFactor = src[3]; - dst[0] = ((packToFloat11(src[0] * scaleFactor) << 0) | - (packToFloat11(src[1] * scaleFactor) << 11) | - (packToFloat10(src[2] * scaleFactor) << 22)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, uint32_t* __restrict dst) -{ - float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f; - dst[0] = ((packToFloat11(src[0] * scaleFactor) << 0) | - (packToFloat11(src[1] * scaleFactor) << 11) | - (packToFloat10(src[2] * scaleFactor) << 22)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = unpackFromFloat16(src[3]); - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor); - dst[2] = packToFloat16(unpackFromFloat16(src[2]) * scaleFactor); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float unpackedAlpha = unpackFromFloat16(src[3]); - float scaleFactor = unpackedAlpha ? 1.0f / unpackedAlpha : 1.0f; - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor); - dst[2] = packToFloat16(unpackFromFloat16(src[2]) * scaleFactor); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3]; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; - dst[2] = src[2] * scaleFactor; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; - dst[2] = src[2] * scaleFactor; -} - -//////////////////////////////////////////////////////////////////////////////// -// 4-channel formats -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - *dst = ( ((src[0] & 0xF0) << 8) - | ((src[1] & 0xF0) << 4) - | (src[2] & 0xF0) - | (src[3] >> 4) ); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = ( ((srcR & 0xF0) << 8) - | ((srcG & 0xF0) << 4) - | (srcB & 0xF0) - | (src[3] >> 4)); -} - -// FIXME: this routine is lossy and must be removed. -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = ( ((srcR & 0xF0) << 8) - | ((srcG & 0xF0) << 4) - | (srcB & 0xF0) - | (src[3] >> 4)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - *dst = ( ((src[0] & 0xF8) << 8) - | ((src[1] & 0xF8) << 3) - | ((src[2] & 0xF8) >> 2) - | (src[3] >> 7)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = ( ((srcR & 0xF8) << 8) - | ((srcG & 0xF8) << 3) - | ((srcB & 0xF8) >> 2) - | (src[3] >> 7)); -} - -// FIXME: this routine is lossy and must be removed. -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - *dst = ( ((srcR & 0xF8) << 8) - | ((srcG & 0xF8) << 3) - | ((srcB & 0xF8) >> 2) - | (src[3] >> 7)); -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] / 255.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - dst[0] = srcR; - dst[1] = srcG; - dst[2] = srcB; - dst[3] = src[3]; -} - -// FIXME: this routine is lossy and must be removed. -template<> MOZ_ALWAYS_INLINE void -pack(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - float scaleFactor = src[3] ? 255.0f / src[3] : 1.0f; - uint8_t srcR = static_cast(src[0] * scaleFactor); - uint8_t srcG = static_cast(src[1] * scaleFactor); - uint8_t srcB = static_cast(src[2] * scaleFactor); - dst[0] = srcR; - dst[1] = srcG; - dst[2] = srcB; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float scaleFactor = unpackFromFloat16(src[3]); - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor); - dst[2] = packToFloat16(unpackFromFloat16(src[2]) * scaleFactor); - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - float unpackedAlpha = unpackFromFloat16(src[3]); - float scaleFactor = unpackedAlpha ? 1.0f / unpackedAlpha : 1.0f; - dst[0] = packToFloat16(unpackFromFloat16(src[0]) * scaleFactor); - dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor); - dst[2] = packToFloat16(unpackFromFloat16(src[2]) * scaleFactor); - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3]; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; - dst[2] = src[2] * scaleFactor; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -pack(const float* __restrict src, float* __restrict dst) -{ - float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; - dst[2] = src[2] * scaleFactor; - dst[3] = src[3]; -} - -/****** END CODE SHARED WITH WEBKIT ******/ - -template MOZ_ALWAYS_INLINE void -convertType(const SrcType* __restrict src, DstType* __restrict dst) -{ - MOZ_ASSERT(false, "Unimplemented texture format conversion"); -} - -template<> MOZ_ALWAYS_INLINE void -convertType(const uint8_t* __restrict src, uint8_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -convertType(const uint16_t* __restrict src, uint16_t* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -convertType(const float* __restrict src, float* __restrict dst) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -template<> MOZ_ALWAYS_INLINE void -convertType(const uint8_t* __restrict src, float* __restrict dst) -{ - const float scaleFactor = 1.f / 255.0f; - dst[0] = src[0] * scaleFactor; - dst[1] = src[1] * scaleFactor; - dst[2] = src[2] * scaleFactor; - dst[3] = src[3] * scaleFactor; -} - -template<> MOZ_ALWAYS_INLINE void -convertType(const uint8_t* __restrict src, uint16_t* __restrict dst) -{ - const float scaleFactor = 1.f / 255.0f; - dst[0] = packToFloat16(src[0] * scaleFactor); - dst[1] = packToFloat16(src[1] * scaleFactor); - dst[2] = packToFloat16(src[2] * scaleFactor); - dst[3] = packToFloat16(src[3] * scaleFactor); -} - -} // end namespace WebGLTexelConversions - -} // end namespace mozilla - -#endif // WEBGLTEXELCONVERSIONS_H_ diff --git a/sources/firefox/WebGLTypes.h b/sources/firefox/WebGLTypes.h deleted file mode 100644 index 305e512e..00000000 --- a/sources/firefox/WebGLTypes.h +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef WEBGLTYPES_H_ -#define WEBGLTYPES_H_ - -// Most WebIDL typedefs are identical to their OpenGL counterparts. -//cjh #include "GLTypes.h" -#include "platform/CCGL.h" - -#include "mozilla/Attributes.h" -#include -#include - -// Manual reflection of WebIDL typedefs that are different from their -// OpenGL counterparts. -typedef int64_t WebGLsizeiptr; -typedef int64_t WebGLintptr; -typedef bool WebGLboolean; - -namespace mozilla { -namespace gl { -class GLContext; // This is going to be needed a lot. -} // namespace gl - -/* - * WebGLTextureFakeBlackStatus is an enum to track what needs to use a dummy 1x1 black - * texture, which we refer to as a 'fake black' texture. - * - * There are two things that can cause us to use such 'fake black' textures: - * - * (1) OpenGL ES rules on sampling incomplete textures specify that they - * must be sampled as RGBA(0, 0, 0, 1) (opaque black). We have to implement these rules - * ourselves, if only because we do not always run on OpenGL ES, and also - * because this is dangerously close to the kind of case where we don't - * want to trust the driver with corner cases of texture memory accesses. - * - * (2) OpenGL has cases where a renderbuffer, or a texture image, can contain - * uninitialized image data. See below the comment about WebGLImageDataStatus. - * WebGL must never have access to uninitialized image data. The WebGL 1 spec, - * section 4.1 'Resource Restrictions', specifies that in any such case, the - * uninitialized image data must be exposed to WebGL as if it were filled - * with zero bytes, which means it's either opaque or transparent black - * depending on whether the image format has alpha. - */ - -enum class FakeBlackType : uint8_t { - None, - RGBA0001, // Incomplete textures and uninitialized no-alpha color textures. - RGBA0000, // Uninitialized with-alpha color textures. -}; - -/* - * Implementing WebGL (or OpenGL ES 2.0) on top of desktop OpenGL requires - * emulating the vertex attrib 0 array when it's not enabled. Indeed, - * OpenGL ES 2.0 allows drawing without vertex attrib 0 array enabled, but - * desktop OpenGL does not allow that. - */ -enum class WebGLVertexAttrib0Status : uint8_t { - Default, // default status - no emulation needed - EmulatedUninitializedArray, // need an artificial attrib 0 array, but contents may be left uninitialized - EmulatedInitializedArray // need an artificial attrib 0 array, and contents must be initialized -}; - -/* - * Enum to track the status of image data (renderbuffer or texture image) presence - * and initialization. - * - * - NoImageData is the initial state before any image data is allocated. - * - InitializedImageData is the state after image data is allocated and initialized. - * - UninitializedImageData is an intermediate state where data is allocated but not - * initialized. It is the state that renderbuffers are in after a renderbufferStorage call, - * and it is the state that texture images are in after a texImage2D call with null data. - */ -enum class WebGLImageDataStatus : uint8_t { - NoImageData, - UninitializedImageData, - InitializedImageData -}; - -/* - * The formats that may participate, either as source or destination formats, - * in WebGL texture conversions. This includes: - * - all the formats accepted by WebGL.texImage2D, e.g. RGBA4444 - * - additional formats provided by extensions, e.g. RGB32F - * - additional source formats, depending on browser details, used when uploading - * textures from DOM elements. See gfxImageSurface::Format(). - */ -enum class WebGLTexelFormat : uint8_t { - // returned by SurfaceFromElementResultToImageSurface to indicate absence of image data - None, - // common value for formats for which format conversions are not supported - FormatNotSupportingAnyConversion, - // dummy pseudo-format meaning "use the other format". - // For example, if SrcFormat=Auto and DstFormat=RGB8, then the source - // is implicitly treated as being RGB8 itself. - Auto, - // 1-channel formats - A8, - A16F, // OES_texture_half_float - A32F, // OES_texture_float - R8, - R16F, // OES_texture_half_float - R32F, // OES_texture_float - // 2-channel formats - RA8, - RA16F, // OES_texture_half_float - RA32F, // OES_texture_float - RG8, - RG16F, - RG32F, - // 3-channel formats - RGB8, - RGB565, - RGB11F11F10F, - RGB16F, // OES_texture_half_float - RGB32F, // OES_texture_float - // 4-channel formats - RGBA8, - RGBA5551, - RGBA4444, - RGBA16F, // OES_texture_half_float - RGBA32F, // OES_texture_float - // DOM element source only formats. - RGBX8, - BGRX8, - BGRA8 -}; - -enum class WebGLTexImageFunc : uint8_t { - TexImage, - TexSubImage, - CopyTexImage, - CopyTexSubImage, - CompTexImage, - CompTexSubImage, -}; - -enum class WebGLTexDimensions : uint8_t { - Tex2D, - Tex3D -}; - -// Please keep extensions in alphabetic order. -enum class WebGLExtensionID : uint8_t { - ANGLE_instanced_arrays, - EXT_blend_minmax, - EXT_color_buffer_float, - EXT_color_buffer_half_float, - EXT_frag_depth, - EXT_sRGB, - EXT_shader_texture_lod, - EXT_texture_filter_anisotropic, - EXT_disjoint_timer_query, - MOZ_debug, - OES_element_index_uint, - OES_standard_derivatives, - OES_texture_float, - OES_texture_float_linear, - OES_texture_half_float, - OES_texture_half_float_linear, - OES_vertex_array_object, - WEBGL_color_buffer_float, - WEBGL_compressed_texture_astc, - WEBGL_compressed_texture_atc, - WEBGL_compressed_texture_etc, - WEBGL_compressed_texture_etc1, - WEBGL_compressed_texture_pvrtc, - WEBGL_compressed_texture_s3tc, - WEBGL_compressed_texture_s3tc_srgb, - WEBGL_debug_renderer_info, - WEBGL_debug_shaders, - WEBGL_depth_texture, - WEBGL_draw_buffers, - WEBGL_lose_context, - Max, - Unknown -}; - -class UniqueBuffer -{ - // Like UniquePtr<>, but for void* and malloc/calloc/free. - void* mBuffer; - -public: - UniqueBuffer() - : mBuffer(nullptr) - { } - - MOZ_IMPLICIT UniqueBuffer(void* buffer) - : mBuffer(buffer) - { } - - ~UniqueBuffer() { - free(mBuffer); - } - - UniqueBuffer(UniqueBuffer&& other) { - this->mBuffer = other.mBuffer; - other.mBuffer = nullptr; - } - - UniqueBuffer& operator =(UniqueBuffer&& other) { - free(this->mBuffer); - this->mBuffer = other.mBuffer; - other.mBuffer = nullptr; - return *this; - } - - UniqueBuffer& operator =(void* newBuffer) { - free(this->mBuffer); - this->mBuffer = newBuffer; - return *this; - } - - explicit operator bool() const { return bool(mBuffer); } - - void* get() const { return mBuffer; } - - UniqueBuffer(const UniqueBuffer& other) = delete; // construct using Move()! - void operator =(const UniqueBuffer& other) = delete; // assign using Move()! -}; - -} // namespace mozilla - -#endif diff --git a/sources/firefox/mozilla/Assertions.cpp b/sources/firefox/mozilla/Assertions.cpp deleted file mode 100644 index 2021d13f..00000000 --- a/sources/firefox/mozilla/Assertions.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Assertions.h" -#include "mozilla/Atomics.h" - -#include - -MOZ_BEGIN_EXTERN_C - -/* - * The crash reason is defined as a global variable here rather than in the - * crash reporter itself to make it available to all code, even libraries like - * JS that don't link with the crash reporter directly. This value will only - * be consumed if the crash reporter is used by the target application. - */ -MFBT_DATA const char* gMozCrashReason = nullptr; - -#ifndef DEBUG -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void -MOZ_CrashOOL(int aLine, const char* aReason) -#else -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void -MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason) -#endif -{ -#ifdef DEBUG - MOZ_ReportCrash(aReason, aFilename, aLine); -#endif - gMozCrashReason = aReason; - MOZ_REALLY_CRASH(aLine); -} - -static char sPrintfCrashReason[sPrintfCrashReasonSize] = {}; -static mozilla::Atomic sCrashing(false); - -#ifndef DEBUG -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE MOZ_FORMAT_PRINTF(2, 3) void -MOZ_CrashPrintf(int aLine, const char* aFormat, ...) -#else -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE MOZ_FORMAT_PRINTF(3, 4) void -MOZ_CrashPrintf(const char* aFilename, int aLine, const char* aFormat, ...) -#endif -{ - if (!sCrashing.compareExchange(false, true)) { - // In the unlikely event of a race condition, skip - // setting the crash reason and just crash safely. - MOZ_REALLY_CRASH(aLine); - } - va_list aArgs; - va_start(aArgs, aFormat); - int ret = vsnprintf(sPrintfCrashReason, sPrintfCrashReasonSize, - aFormat, aArgs); - va_end(aArgs); - MOZ_RELEASE_ASSERT(ret >= 0 && size_t(ret) < sPrintfCrashReasonSize, - "Could not write the explanation string to the supplied buffer!"); -#ifdef DEBUG - MOZ_ReportCrash(sPrintfCrashReason, aFilename, aLine); -#endif - gMozCrashReason = sPrintfCrashReason; - MOZ_REALLY_CRASH(aLine); -} - -MOZ_END_EXTERN_C diff --git a/sources/firefox/mozilla/Assertions.h b/sources/firefox/mozilla/Assertions.h deleted file mode 100755 index 0d12a5cb..00000000 --- a/sources/firefox/mozilla/Assertions.h +++ /dev/null @@ -1,659 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implementations of runtime and static assertion macros for C and C++. */ - -#ifndef mozilla_Assertions_h -#define mozilla_Assertions_h - -#if defined(MOZILLA_INTERNAL_API) && defined(__cplusplus) -#define MOZ_DUMP_ASSERTION_STACK -#endif - -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/Likely.h" -#include "mozilla/MacroArgs.h" -#include "mozilla/StaticAnalysisFunctions.h" -#include "mozilla/Types.h" -#ifdef MOZ_DUMP_ASSERTION_STACK -#include "nsTraceRefcnt.h" -#endif - -/* - * The crash reason set by MOZ_CRASH_ANNOTATE is consumed by the crash reporter - * if present. It is declared here (and defined in Assertions.cpp) to make it - * available to all code, even libraries that don't link with the crash reporter - * directly. - */ -MOZ_BEGIN_EXTERN_C -extern MFBT_DATA const char* gMozCrashReason; -MOZ_END_EXTERN_C - -#if !defined(DEBUG) && (defined(MOZ_HAS_MOZGLUE) || defined(MOZILLA_INTERNAL_API)) -static inline void -AnnotateMozCrashReason(const char* reason) -{ - gMozCrashReason = reason; -} -# define MOZ_CRASH_ANNOTATE(...) AnnotateMozCrashReason(__VA_ARGS__) -#else -# define MOZ_CRASH_ANNOTATE(...) do { /* nothing */ } while (0) -#endif - -#include -#include -#include -#ifdef _MSC_VER - /* - * TerminateProcess and GetCurrentProcess are defined in , which - * further depends on . We hardcode these few definitions manually - * because those headers clutter the global namespace with a significant - * number of undesired macros and symbols. - */ -MOZ_BEGIN_EXTERN_C -__declspec(dllimport) int __stdcall -TerminateProcess(void* hProcess, unsigned int uExitCode); -__declspec(dllimport) void* __stdcall GetCurrentProcess(void); -MOZ_END_EXTERN_C -#else -# include -#endif -#ifdef ANDROID -# include -#endif - -#if defined(__GNUC__) -# define MOZ_UNUSED_ATTRIBUTE __attribute__((unused)) -#else -# define MOZ_UNUSED_ATTRIBUTE /* nothing */ -#endif - -/* - * MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C. - * In C++11, static_assert is provided by the compiler to the same effect. - * This can be useful when you make certain assumptions about what must hold for - * optimal, or even correct, behavior. For example, you might assert that the - * size of a struct is a multiple of the target architecture's word size: - * - * struct S { ... }; - * // C - * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, - * "S should be a multiple of word size for efficiency"); - * // C++11 - * static_assert(sizeof(S) % sizeof(size_t) == 0, - * "S should be a multiple of word size for efficiency"); - * - * This macro can be used in any location where both an extern declaration and a - * typedef could be used. - */ -#ifndef __cplusplus - /* - * Some of the definitions below create an otherwise-unused typedef. This - * triggers compiler warnings with some versions of gcc, so mark the typedefs - * as permissibly-unused to disable the warnings. - */ -# define MOZ_STATIC_ASSERT_GLUE1(x, y) x##y -# define MOZ_STATIC_ASSERT_GLUE(x, y) MOZ_STATIC_ASSERT_GLUE1(x, y) -# if defined(__SUNPRO_CC) - /* - * The Sun Studio C++ compiler is buggy when declaring, inside a function, - * another extern'd function with an array argument whose length contains a - * sizeof, triggering the error message "sizeof expression not accepted as - * size of array parameter". This bug (6688515, not public yet) would hit - * defining moz_static_assert as a function, so we always define an extern - * array for Sun Studio. - * - * We include the line number in the symbol name in a best-effort attempt - * to avoid conflicts (see below). - */ -# define MOZ_STATIC_ASSERT(cond, reason) \ - extern char MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)[(cond) ? 1 : -1] -# elif defined(__COUNTER__) - /* - * If there was no preferred alternative, use a compiler-agnostic version. - * - * Note that the non-__COUNTER__ version has a bug in C++: it can't be used - * in both |extern "C"| and normal C++ in the same translation unit. (Alas - * |extern "C"| isn't allowed in a function.) The only affected compiler - * we really care about is gcc 4.2. For that compiler and others like it, - * we include the line number in the function name to do the best we can to - * avoid conflicts. These should be rare: a conflict would require use of - * MOZ_STATIC_ASSERT on the same line in separate files in the same - * translation unit, *and* the uses would have to be in code with - * different linkage, *and* the first observed use must be in C++-linkage - * code. - */ -# define MOZ_STATIC_ASSERT(cond, reason) \ - typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_UNUSED_ATTRIBUTE -# else -# define MOZ_STATIC_ASSERT(cond, reason) \ - extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_UNUSED_ATTRIBUTE -# endif - -#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) -#else -#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) static_assert(!(cond) || (expr), reason) -#endif - -MOZ_BEGIN_EXTERN_C - -/* - * Prints |aStr| as an assertion failure (using aFilename and aLine as the - * location of the assertion) to the standard debug-output channel. - * - * Usually you should use MOZ_ASSERT or MOZ_CRASH instead of this method. This - * method is primarily for internal use in this header, and only secondarily - * for use in implementing release-build assertions. - */ -MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void -MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine) - MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS -{ -#ifdef ANDROID - __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert", - "Assertion failure: %s, at %s:%d\n", - aStr, aFilename, aLine); -#else - fprintf(stderr, "Assertion failure: %s, at %s:%d\n", aStr, aFilename, aLine); -#if defined (MOZ_DUMP_ASSERTION_STACK) - nsTraceRefcnt::WalkTheStack(stderr); -#endif - fflush(stderr); -#endif -} - -MOZ_MAYBE_UNUSED static MOZ_COLD MOZ_NEVER_INLINE void -MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine) - MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS -{ -#ifdef ANDROID - __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", - "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine); -#else - fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine); -#if defined(MOZ_DUMP_ASSERTION_STACK) - nsTraceRefcnt::WalkTheStack(stderr); -#endif - fflush(stderr); -#endif -} - -/** - * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). You should - * call MOZ_CRASH instead. - */ -#if defined(_MSC_VER) - /* - * On MSVC use the __debugbreak compiler intrinsic, which produces an inline - * (not nested in a system function) breakpoint. This distinctively invokes - * Breakpad without requiring system library symbols on all stack-processing - * machines, as a nested breakpoint would require. - * - * We use __LINE__ to prevent the compiler from folding multiple crash sites - * together, which would make crash reports hard to understand. - * - * We use TerminateProcess with the exit code aborting would generate - * because we don't want to invoke atexit handlers, destructors, library - * unload handlers, and so on when our process might be in a compromised - * state. - * - * We don't use abort() because it'd cause Windows to annoyingly pop up the - * process error dialog multiple times. See bug 345118 and bug 426163. - * - * (Technically these are Windows requirements, not MSVC requirements. But - * practically you need MSVC for debugging, and we only ship builds created - * by MSVC, so doing it this way reduces complexity.) - */ - -static MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void MOZ_NoReturn(int aLine) -{ - *((volatile int*) NULL) = aLine; - TerminateProcess(GetCurrentProcess(), 3); -} - -# define MOZ_REALLY_CRASH(line) \ - do { \ - __debugbreak(); \ - MOZ_NoReturn(line); \ - } while (0) -#else -# ifdef __cplusplus -# define MOZ_REALLY_CRASH(line) \ - do { \ - *((volatile int*) NULL) = line; \ - ::abort(); \ - } while (0) -# else -# define MOZ_REALLY_CRASH(line) \ - do { \ - *((volatile int*) NULL) = line; \ - abort(); \ - } while (0) -# endif -#endif - -/* - * MOZ_CRASH([explanation-string]) crashes the program, plain and simple, in a - * Breakpad-compatible way, in both debug and release builds. - * - * MOZ_CRASH is a good solution for "handling" failure cases when you're - * unwilling or unable to handle them more cleanly -- for OOM, for likely memory - * corruption, and so on. It's also a good solution if you need safe behavior - * in release builds as well as debug builds. But if the failure is one that - * should be debugged and fixed, MOZ_ASSERT is generally preferable. - * - * The optional explanation-string, if provided, must be a string literal - * explaining why we're crashing. This argument is intended for use with - * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's - * obvious why we're crashing. - * - * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an - * explanation-string, we print the string to stderr. Otherwise, we don't - * print anything; this is because we want MOZ_CRASH to be 100% safe in release - * builds, and it's hard to print to stderr safely when memory might have been - * corrupted. - */ -#ifndef DEBUG -# define MOZ_CRASH(...) \ - do { \ - MOZ_CRASH_ANNOTATE("MOZ_CRASH(" __VA_ARGS__ ")"); \ - MOZ_REALLY_CRASH(__LINE__); \ - } while (0) -#else -# define MOZ_CRASH(...) \ - do { \ - MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \ - MOZ_CRASH_ANNOTATE("MOZ_CRASH(" __VA_ARGS__ ")"); \ - MOZ_REALLY_CRASH(__LINE__); \ - } while (0) -#endif - -/* - * MOZ_CRASH_UNSAFE_OOL(explanation-string) can be used if the explanation - * string cannot be a string literal (but no other processing needs to be done - * on it). A regular MOZ_CRASH() is preferred wherever possible, as passing - * arbitrary strings from a potentially compromised process is not without risk. - * If the string being passed is the result of a printf-style function, - * consider using MOZ_CRASH_UNSAFE_PRINTF instead. - * - * @note This macro causes data collection because crash strings are annotated - * to crash-stats and are publicly visible. Firefox data stewards must do data - * review on usages of this macro. - */ -#ifndef DEBUG -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void -MOZ_CrashOOL(int aLine, const char* aReason); -# define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__LINE__, reason) -#else -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void -MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason); -# define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__FILE__, __LINE__, reason) -#endif - -static const size_t sPrintfMaxArgs = 4; -static const size_t sPrintfCrashReasonSize = 1024; - -#ifndef DEBUG -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE MOZ_FORMAT_PRINTF(2, 3) void -MOZ_CrashPrintf(int aLine, const char* aFormat, ...); -# define MOZ_CALL_CRASH_PRINTF(format, ...) \ - MOZ_CrashPrintf(__LINE__, format, __VA_ARGS__) -#else -MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE MOZ_FORMAT_PRINTF(3, 4) void -MOZ_CrashPrintf(const char* aFilename, int aLine, const char* aFormat, ...); -# define MOZ_CALL_CRASH_PRINTF(format, ...) \ - MOZ_CrashPrintf(__FILE__, __LINE__, format, __VA_ARGS__) -#endif - -/* - * MOZ_CRASH_UNSAFE_PRINTF(format, arg1 [, args]) can be used when more - * information is desired than a string literal can supply. The caller provides - * a printf-style format string, which must be a string literal and between - * 1 and 4 additional arguments. A regular MOZ_CRASH() is preferred wherever - * possible, as passing arbitrary strings to printf from a potentially - * compromised process is not without risk. - * - * @note This macro causes data collection because crash strings are annotated - * to crash-stats and are publicly visible. Firefox data stewards must do data - * review on usages of this macro. - */ -#define MOZ_CRASH_UNSAFE_PRINTF(format, ...) \ - do { \ - static_assert( \ - MOZ_ARG_COUNT(__VA_ARGS__) > 0, \ - "Did you forget arguments to MOZ_CRASH_UNSAFE_PRINTF? " \ - "Or maybe you want MOZ_CRASH instead?"); \ - static_assert( \ - MOZ_ARG_COUNT(__VA_ARGS__) <= sPrintfMaxArgs, \ - "Only up to 4 additional arguments are allowed!"); \ - static_assert(sizeof(format) <= sPrintfCrashReasonSize, \ - "The supplied format string is too long!"); \ - MOZ_CALL_CRASH_PRINTF("" format, __VA_ARGS__); \ - } while (0) - -MOZ_END_EXTERN_C - -/* - * MOZ_ASSERT(expr [, explanation-string]) asserts that |expr| must be truthy in - * debug builds. If it is, execution continues. Otherwise, an error message - * including the expression and the explanation-string (if provided) is printed, - * an attempt is made to invoke any existing debugger, and execution halts. - * MOZ_ASSERT is fatal: no recovery is possible. Do not assert a condition - * which can correctly be falsy. - * - * The optional explanation-string, if provided, must be a string literal - * explaining the assertion. It is intended for use with assertions whose - * correctness or rationale is non-obvious, and for assertions where the "real" - * condition being tested is best described prosaically. Don't provide an - * explanation if it's not actually helpful. - * - * // No explanation needed: pointer arguments often must not be NULL. - * MOZ_ASSERT(arg); - * - * // An explanation can be helpful to explain exactly how we know an - * // assertion is valid. - * MOZ_ASSERT(state == WAITING_FOR_RESPONSE, - * "given that and , we must have..."); - * - * // Or it might disambiguate multiple identical (save for their location) - * // assertions of the same expression. - * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), - * "we already set [[PrimitiveThis]] for this Boolean object"); - * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), - * "we already set [[PrimitiveThis]] for this String object"); - * - * MOZ_ASSERT has no effect in non-debug builds. It is designed to catch bugs - * *only* during debugging, not "in the field". If you want the latter, use - * MOZ_RELEASE_ASSERT, which applies to non-debug builds as well. - * - * MOZ_DIAGNOSTIC_ASSERT works like MOZ_RELEASE_ASSERT in Nightly/Aurora and - * MOZ_ASSERT in Beta/Release - use this when a condition is potentially rare - * enough to require real user testing to hit, but is not security-sensitive. - * This can cause user pain, so use it sparingly. If a MOZ_DIAGNOSTIC_ASSERT - * is firing, it should promptly be converted to a MOZ_ASSERT while the failure - * is being investigated, rather than letting users suffer. - * - * MOZ_DIAGNOSTIC_ASSERT_ENABLED is defined when MOZ_DIAGNOSTIC_ASSERT is like - * MOZ_RELEASE_ASSERT rather than MOZ_ASSERT. - */ - -/* - * Implement MOZ_VALIDATE_ASSERT_CONDITION_TYPE, which is used to guard against - * accidentally passing something unintended in lieu of an assertion condition. - */ - -#ifdef __cplusplus -# include "mozilla/TypeTraits.h" -namespace mozilla { -namespace detail { - -template -struct AssertionConditionType -{ - typedef typename RemoveReference::Type ValueT; - static_assert(!IsArray::value, - "Expected boolean assertion condition, got an array or a " - "string!"); - static_assert(!IsFunction::value, - "Expected boolean assertion condition, got a function! Did " - "you intend to call that function?"); - static_assert(!IsFloatingPoint::value, - "It's often a bad idea to assert that a floating-point number " - "is nonzero, because such assertions tend to intermittently " - "fail. Shouldn't your code gracefully handle this case instead " - "of asserting? Anyway, if you really want to do that, write an " - "explicit boolean condition, like !!x or x!=0."); - - static const bool isValid = true; -}; - -} // namespace detail -} // namespace mozilla -# define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x) \ - static_assert(mozilla::detail::AssertionConditionType::isValid, \ - "invalid assertion condition") -#else -# define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x) -#endif - -#if defined(DEBUG) || defined(MOZ_ASAN) -# define MOZ_REPORT_ASSERTION_FAILURE(...) MOZ_ReportAssertionFailure(__VA_ARGS__) -#else -# define MOZ_REPORT_ASSERTION_FAILURE(...) do { /* nothing */ } while (0) -#endif - -/* First the single-argument form. */ -#define MOZ_ASSERT_HELPER1(expr) \ - do { \ - MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \ - if (MOZ_UNLIKELY(!MOZ_CHECK_ASSERT_ASSIGNMENT(expr))) { \ - MOZ_REPORT_ASSERTION_FAILURE(#expr, __FILE__, __LINE__); \ - MOZ_CRASH_ANNOTATE("MOZ_RELEASE_ASSERT(" #expr ")"); \ - MOZ_REALLY_CRASH(__LINE__); \ - } \ - } while (0) -/* Now the two-argument form. */ -#define MOZ_ASSERT_HELPER2(expr, explain) \ - do { \ - MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \ - if (MOZ_UNLIKELY(!MOZ_CHECK_ASSERT_ASSIGNMENT(expr))) { \ - MOZ_REPORT_ASSERTION_FAILURE(#expr " (" explain ")", __FILE__, __LINE__); \ - MOZ_CRASH_ANNOTATE("MOZ_RELEASE_ASSERT(" #expr ") (" explain ")"); \ - MOZ_REALLY_CRASH(__LINE__); \ - } \ - } while (0) - -#define MOZ_RELEASE_ASSERT_GLUE(a, b) a b -#define MOZ_RELEASE_ASSERT(...) \ - MOZ_RELEASE_ASSERT_GLUE( \ - MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_ASSERT_HELPER, __VA_ARGS__), \ - (__VA_ARGS__)) - -#ifdef DEBUG -# define MOZ_ASSERT(...) MOZ_RELEASE_ASSERT(__VA_ARGS__) -#else -# define MOZ_ASSERT(...) do { } while (0) -#endif /* DEBUG */ - -#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) -# define MOZ_DIAGNOSTIC_ASSERT MOZ_RELEASE_ASSERT -# define MOZ_DIAGNOSTIC_ASSERT_ENABLED 1 -#else -# define MOZ_DIAGNOSTIC_ASSERT MOZ_ASSERT -# ifdef DEBUG -# define MOZ_DIAGNOSTIC_ASSERT_ENABLED 1 -# endif -#endif - -/* - * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is - * true. - * - * MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num)); - * - * As with MOZ_ASSERT, MOZ_ASSERT_IF has effect only in debug builds. It is - * designed to catch bugs during debugging, not "in the field". - */ -#ifdef DEBUG -# define MOZ_ASSERT_IF(cond, expr) \ - do { \ - if (cond) { \ - MOZ_ASSERT(expr); \ - } \ - } while (0) -#else -# define MOZ_ASSERT_IF(cond, expr) do { } while (0) -#endif - -/* - * MOZ_ASSUME_UNREACHABLE_MARKER() expands to an expression which states that - * it is undefined behavior for execution to reach this point. No guarantees - * are made about what will happen if this is reached at runtime. Most code - * should use MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE because it has extra - * asserts. - */ -#if defined(__clang__) || defined(__GNUC__) -# define MOZ_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable() -#elif defined(_MSC_VER) -# define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0) -#else -# ifdef __cplusplus -# define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() -# else -# define MOZ_ASSUME_UNREACHABLE_MARKER() abort() -# endif -#endif - -/* - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE([reason]) tells the compiler that it - * can assume that the macro call cannot be reached during execution. This lets - * the compiler generate better-optimized code under some circumstances, at the - * expense of the program's behavior being undefined if control reaches the - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE. - * - * In Gecko, you probably should not use this macro outside of performance- or - * size-critical code, because it's unsafe. If you don't care about code size - * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH. - * - * SpiderMonkey is a different beast, and there it's acceptable to use - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE more widely. - * - * Note that MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE is noreturn, so it's valid - * not to return a value following a MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE - * call. - * - * Example usage: - * - * enum ValueType { - * VALUE_STRING, - * VALUE_INT, - * VALUE_FLOAT - * }; - * - * int ptrToInt(ValueType type, void* value) { - * { - * // We know for sure that type is either INT or FLOAT, and we want this - * // code to run as quickly as possible. - * switch (type) { - * case VALUE_INT: - * return *(int*) value; - * case VALUE_FLOAT: - * return (int) *(float*) value; - * default: - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected ValueType"); - * } - * } - */ - -/* - * Unconditional assert in debug builds for (assumed) unreachable code paths - * that have a safe return without crashing in release builds. - */ -#define MOZ_ASSERT_UNREACHABLE(reason) \ - MOZ_ASSERT(false, "MOZ_ASSERT_UNREACHABLE: " reason) - -#define MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE(reason) \ - do { \ - MOZ_ASSERT_UNREACHABLE(reason); \ - MOZ_ASSUME_UNREACHABLE_MARKER(); \ - } while (0) - -/** - * MOZ_FALLTHROUGH_ASSERT is an annotation to suppress compiler warnings about - * switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in - * debug builds, but intentionally fall through in release builds to handle - * unexpected values. - * - * Why do we need MOZ_FALLTHROUGH_ASSERT in addition to MOZ_FALLTHROUGH? In - * release builds, the MOZ_ASSERT(false) will expand to `do { } while (0)`, - * requiring a MOZ_FALLTHROUGH annotation to suppress a -Wimplicit-fallthrough - * warning. In debug builds, the MOZ_ASSERT(false) will expand to something like - * `if (true) { MOZ_CRASH(); }` and the MOZ_FALLTHROUGH annotation will cause - * a -Wunreachable-code warning. The MOZ_FALLTHROUGH_ASSERT macro breaks this - * warning stalemate. - * - * // Example before MOZ_FALLTHROUGH_ASSERT: - * switch (foo) { - * default: - * // This case wants to assert in debug builds, fall through in release. - * MOZ_ASSERT(false); // -Wimplicit-fallthrough warning in release builds! - * MOZ_FALLTHROUGH; // but -Wunreachable-code warning in debug builds! - * case 5: - * return 5; - * } - * - * // Example with MOZ_FALLTHROUGH_ASSERT: - * switch (foo) { - * default: - * // This case asserts in debug builds, falls through in release. - * MOZ_FALLTHROUGH_ASSERT("Unexpected foo value?!"); - * case 5: - * return 5; - * } - */ -#ifdef DEBUG -# define MOZ_FALLTHROUGH_ASSERT(reason) MOZ_CRASH("MOZ_FALLTHROUGH_ASSERT: " reason) -#else -# define MOZ_FALLTHROUGH_ASSERT(...) MOZ_FALLTHROUGH -#endif - -/* - * MOZ_ALWAYS_TRUE(expr) and MOZ_ALWAYS_FALSE(expr) always evaluate the provided - * expression, in debug builds and in release builds both. Then, in debug - * builds only, the value of the expression is asserted either true or false - * using MOZ_ASSERT. - */ -#ifdef DEBUG -# define MOZ_ALWAYS_TRUE(expr) \ - do { \ - if ((expr)) { \ - /* Do nothing. */ \ - } else { \ - MOZ_ASSERT(false, #expr); \ - } \ - } while (0) -# define MOZ_ALWAYS_FALSE(expr) \ - do { \ - if ((expr)) { \ - MOZ_ASSERT(false, #expr); \ - } else { \ - /* Do nothing. */ \ - } \ - } while (0) -# define MOZ_ALWAYS_OK(expr) MOZ_ASSERT((expr).isOk()) -# define MOZ_ALWAYS_ERR(expr) MOZ_ASSERT((expr).isErr()) -#else -# define MOZ_ALWAYS_TRUE(expr) \ - do { \ - if ((expr)) { \ - /* Silence MOZ_MUST_USE. */ \ - } \ - } while (0) -# define MOZ_ALWAYS_FALSE(expr) \ - do { \ - if ((expr)) { \ - /* Silence MOZ_MUST_USE. */ \ - } \ - } while (0) -# define MOZ_ALWAYS_OK(expr) \ - do { \ - if ((expr).isOk()) { \ - /* Silence MOZ_MUST_USE. */ \ - } \ - } while (0) -# define MOZ_ALWAYS_ERR(expr) \ - do { \ - if ((expr).isErr()) { \ - /* Silence MOZ_MUST_USE. */ \ - } \ - } while (0) -#endif - -#undef MOZ_DUMP_ASSERTION_STACK -#undef MOZ_CRASH_CRASHREPORT - -#endif /* mozilla_Assertions_h */ diff --git a/sources/firefox/mozilla/Atomics.h b/sources/firefox/mozilla/Atomics.h deleted file mode 100644 index 7dfc2b24..00000000 --- a/sources/firefox/mozilla/Atomics.h +++ /dev/null @@ -1,563 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements (almost always) lock-free atomic operations. The operations here - * are a subset of that which can be found in C++11's header, with a - * different API to enforce consistent memory ordering constraints. - * - * Anyone caught using |volatile| for inter-thread memory safety needs to be - * sent a copy of this header and the C++11 standard. - */ - -#ifndef mozilla_Atomics_h -#define mozilla_Atomics_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/TypeTraits.h" - -#include - -#include - -namespace mozilla { - -/** - * An enum of memory ordering possibilities for atomics. - * - * Memory ordering is the observable state of distinct values in memory. - * (It's a separate concept from atomicity, which concerns whether an - * operation can ever be observed in an intermediate state. Don't - * conflate the two!) Given a sequence of operations in source code on - * memory, it is *not* always the case that, at all times and on all - * cores, those operations will appear to have occurred in that exact - * sequence. First, the compiler might reorder that sequence, if it - * thinks another ordering will be more efficient. Second, the CPU may - * not expose so consistent a view of memory. CPUs will often perform - * their own instruction reordering, above and beyond that performed by - * the compiler. And each core has its own memory caches, and accesses - * (reads and writes both) to "memory" may only resolve to out-of-date - * cache entries -- not to the "most recently" performed operation in - * some global sense. Any access to a value that may be used by - * multiple threads, potentially across multiple cores, must therefore - * have a memory ordering imposed on it, for all code on all - * threads/cores to have a sufficiently coherent worldview. - * - * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and - * http://en.cppreference.com/w/cpp/atomic/memory_order go into more - * detail on all this, including examples of how each mode works. - * - * Note that for simplicity and practicality, not all of the modes in - * C++11 are supported. The missing C++11 modes are either subsumed by - * the modes we provide below, or not relevant for the CPUs we support - * in Gecko. These three modes are confusing enough as it is! - */ -enum MemoryOrdering { - /* - * Relaxed ordering is the simplest memory ordering: none at all. - * When the result of a write is observed, nothing may be inferred - * about other memory. Writes ostensibly performed "before" on the - * writing thread may not yet be visible. Writes performed "after" on - * the writing thread may already be visible, if the compiler or CPU - * reordered them. (The latter can happen if reads and/or writes get - * held up in per-processor caches.) Relaxed ordering means - * operations can always use cached values (as long as the actual - * updates to atomic values actually occur, correctly, eventually), so - * it's usually the fastest sort of atomic access. For this reason, - * *it's also the most dangerous kind of access*. - * - * Relaxed ordering is good for things like process-wide statistics - * counters that don't need to be consistent with anything else, so - * long as updates themselves are atomic. (And so long as any - * observations of that value can tolerate being out-of-date -- if you - * need some sort of up-to-date value, you need some sort of other - * synchronizing operation.) It's *not* good for locks, mutexes, - * reference counts, etc. that mediate access to other memory, or must - * be observably consistent with other memory. - * - * x86 architectures don't take advantage of the optimization - * opportunities that relaxed ordering permits. Thus it's possible - * that using relaxed ordering will "work" on x86 but fail elsewhere - * (ARM, say, which *does* implement non-sequentially-consistent - * relaxed ordering semantics). Be extra-careful using relaxed - * ordering if you can't easily test non-x86 architectures! - */ - Relaxed, - - /* - * When an atomic value is updated with ReleaseAcquire ordering, and - * that new value is observed with ReleaseAcquire ordering, prior - * writes (atomic or not) are also observable. What ReleaseAcquire - * *doesn't* give you is any observable ordering guarantees for - * ReleaseAcquire-ordered operations on different objects. For - * example, if there are two cores that each perform ReleaseAcquire - * operations on separate objects, each core may or may not observe - * the operations made by the other core. The only way the cores can - * be synchronized with ReleaseAcquire is if they both - * ReleaseAcquire-access the same object. This implies that you can't - * necessarily describe some global total ordering of ReleaseAcquire - * operations. - * - * ReleaseAcquire ordering is good for (as the name implies) atomic - * operations on values controlling ownership of things: reference - * counts, mutexes, and the like. However, if you are thinking about - * using these to implement your own locks or mutexes, you should take - * a good, hard look at actual lock or mutex primitives first. - */ - ReleaseAcquire, - - /* - * When an atomic value is updated with SequentiallyConsistent - * ordering, all writes observable when the update is observed, just - * as with ReleaseAcquire ordering. But, furthermore, a global total - * ordering of SequentiallyConsistent operations *can* be described. - * For example, if two cores perform SequentiallyConsistent operations - * on separate objects, one core will observably perform its update - * (and all previous operations will have completed), then the other - * core will observably perform its update (and all previous - * operations will have completed). (Although those previous - * operations aren't themselves ordered -- they could be intermixed, - * or ordered if they occur on atomic values with ordering - * requirements.) SequentiallyConsistent is the *simplest and safest* - * ordering of atomic operations -- it's always as if one operation - * happens, then another, then another, in some order -- and every - * core observes updates to happen in that single order. Because it - * has the most synchronization requirements, operations ordered this - * way also tend to be slowest. - * - * SequentiallyConsistent ordering can be desirable when multiple - * threads observe objects, and they all have to agree on the - * observable order of changes to them. People expect - * SequentiallyConsistent ordering, even if they shouldn't, when - * writing code, atomic or otherwise. SequentiallyConsistent is also - * the ordering of choice when designing lockless data structures. If - * you don't know what order to use, use this one. - */ - SequentiallyConsistent, -}; - -namespace detail { - -/* - * We provide CompareExchangeFailureOrder to work around a bug in some - * versions of GCC's header. See bug 898491. - */ -template struct AtomicOrderConstraints; - -template<> -struct AtomicOrderConstraints -{ - static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed; - static const std::memory_order LoadOrder = std::memory_order_relaxed; - static const std::memory_order StoreOrder = std::memory_order_relaxed; - static const std::memory_order CompareExchangeFailureOrder = - std::memory_order_relaxed; -}; - -template<> -struct AtomicOrderConstraints -{ - static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel; - static const std::memory_order LoadOrder = std::memory_order_acquire; - static const std::memory_order StoreOrder = std::memory_order_release; - static const std::memory_order CompareExchangeFailureOrder = - std::memory_order_acquire; -}; - -template<> -struct AtomicOrderConstraints -{ - static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst; - static const std::memory_order LoadOrder = std::memory_order_seq_cst; - static const std::memory_order StoreOrder = std::memory_order_seq_cst; - static const std::memory_order CompareExchangeFailureOrder = - std::memory_order_seq_cst; -}; - -template -struct IntrinsicBase -{ - typedef std::atomic ValueType; - typedef AtomicOrderConstraints OrderedOp; -}; - -template -struct IntrinsicMemoryOps : public IntrinsicBase -{ - typedef IntrinsicBase Base; - - static T load(const typename Base::ValueType& aPtr) - { - return aPtr.load(Base::OrderedOp::LoadOrder); - } - - static void store(typename Base::ValueType& aPtr, T aVal) - { - aPtr.store(aVal, Base::OrderedOp::StoreOrder); - } - - static T exchange(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.exchange(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static bool compareExchange(typename Base::ValueType& aPtr, - T aOldVal, T aNewVal) - { - return aPtr.compare_exchange_strong(aOldVal, aNewVal, - Base::OrderedOp::AtomicRMWOrder, - Base::OrderedOp::CompareExchangeFailureOrder); - } -}; - -template -struct IntrinsicAddSub : public IntrinsicBase -{ - typedef IntrinsicBase Base; - - static T add(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T sub(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder); - } -}; - -template -struct IntrinsicAddSub : public IntrinsicBase -{ - typedef IntrinsicBase Base; - - static T* add(typename Base::ValueType& aPtr, ptrdiff_t aVal) - { - return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T* sub(typename Base::ValueType& aPtr, ptrdiff_t aVal) - { - return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder); - } -}; - -template -struct IntrinsicIncDec : public IntrinsicAddSub -{ - typedef IntrinsicBase Base; - - static T inc(typename Base::ValueType& aPtr) - { - return IntrinsicAddSub::add(aPtr, 1); - } - - static T dec(typename Base::ValueType& aPtr) - { - return IntrinsicAddSub::sub(aPtr, 1); - } -}; - -template -struct AtomicIntrinsics : public IntrinsicMemoryOps, - public IntrinsicIncDec -{ - typedef IntrinsicBase Base; - - static T or_(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_or(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T xor_(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_xor(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T and_(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_and(aVal, Base::OrderedOp::AtomicRMWOrder); - } -}; - -template -struct AtomicIntrinsics - : public IntrinsicMemoryOps, public IntrinsicIncDec -{ -}; - -template -struct ToStorageTypeArgument -{ - static constexpr T convert (T aT) { return aT; } -}; - -template -class AtomicBase -{ - static_assert(sizeof(T) == 4 || sizeof(T) == 8, - "mozilla/Atomics.h only supports 32-bit and 64-bit types"); - -protected: - typedef typename detail::AtomicIntrinsics Intrinsics; - typedef typename Intrinsics::ValueType ValueType; - ValueType mValue; - -public: - constexpr AtomicBase() : mValue() {} - explicit constexpr AtomicBase(T aInit) - : mValue(ToStorageTypeArgument::convert(aInit)) - {} - - // Note: we can't provide operator T() here because Atomic inherits - // from AtomcBase with T=uint32_t and not T=bool. If we implemented - // operator T() here, it would cause errors when comparing Atomic with - // a regular bool. - - T operator=(T aVal) - { - Intrinsics::store(mValue, aVal); - return aVal; - } - - /** - * Performs an atomic swap operation. aVal is stored and the previous - * value of this variable is returned. - */ - T exchange(T aVal) - { - return Intrinsics::exchange(mValue, aVal); - } - - /** - * Performs an atomic compare-and-swap operation and returns true if it - * succeeded. This is equivalent to atomically doing - * - * if (mValue == aOldValue) { - * mValue = aNewValue; - * return true; - * } else { - * return false; - * } - */ - bool compareExchange(T aOldValue, T aNewValue) - { - return Intrinsics::compareExchange(mValue, aOldValue, aNewValue); - } - -private: - template - AtomicBase(const AtomicBase& aCopy) = delete; -}; - -template -class AtomicBaseIncDec : public AtomicBase -{ - typedef typename detail::AtomicBase Base; - -public: - constexpr AtomicBaseIncDec() : Base() {} - explicit constexpr AtomicBaseIncDec(T aInit) : Base(aInit) {} - - using Base::operator=; - - operator T() const { return Base::Intrinsics::load(Base::mValue); } - T operator++(int) { return Base::Intrinsics::inc(Base::mValue); } - T operator--(int) { return Base::Intrinsics::dec(Base::mValue); } - T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; } - T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; } - -private: - template - AtomicBaseIncDec(const AtomicBaseIncDec& aCopy) = delete; -}; - -} // namespace detail - -/** - * A wrapper for a type that enforces that all memory accesses are atomic. - * - * In general, where a variable |T foo| exists, |Atomic foo| can be used in - * its place. Implementations for integral and pointer types are provided - * below. - * - * Atomic accesses are sequentially consistent by default. You should - * use the default unless you are tall enough to ride the - * memory-ordering roller coaster (if you're not sure, you aren't) and - * you have a compelling reason to do otherwise. - * - * There is one exception to the case of atomic memory accesses: providing an - * initial value of the atomic value is not guaranteed to be atomic. This is a - * deliberate design choice that enables static atomic variables to be declared - * without introducing extra static constructors. - */ -template -class Atomic; - -/** - * Atomic implementation for integral types. - * - * In addition to atomic store and load operations, compound assignment and - * increment/decrement operators are implemented which perform the - * corresponding read-modify-write operation atomically. Finally, an atomic - * swap method is provided. - */ -template -class Atomic::value && - !IsSame::value>::Type> - : public detail::AtomicBaseIncDec -{ - typedef typename detail::AtomicBaseIncDec Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(T aInit) : Base(aInit) {} - - using Base::operator=; - - T operator+=(T aDelta) - { - return Base::Intrinsics::add(Base::mValue, aDelta) + aDelta; - } - - T operator-=(T aDelta) - { - return Base::Intrinsics::sub(Base::mValue, aDelta) - aDelta; - } - - T operator|=(T aVal) - { - return Base::Intrinsics::or_(Base::mValue, aVal) | aVal; - } - - T operator^=(T aVal) - { - return Base::Intrinsics::xor_(Base::mValue, aVal) ^ aVal; - } - - T operator&=(T aVal) - { - return Base::Intrinsics::and_(Base::mValue, aVal) & aVal; - } - -private: - Atomic(Atomic& aOther) = delete; -}; - -/** - * Atomic implementation for pointer types. - * - * An atomic compare-and-swap primitive for pointer variables is provided, as - * are atomic increment and decement operators. Also provided are the compound - * assignment operators for addition and subtraction. Atomic swap (via - * exchange()) is included as well. - */ -template -class Atomic : public detail::AtomicBaseIncDec -{ - typedef typename detail::AtomicBaseIncDec Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(T* aInit) : Base(aInit) {} - - using Base::operator=; - - T* operator+=(ptrdiff_t aDelta) - { - return Base::Intrinsics::add(Base::mValue, aDelta) + aDelta; - } - - T* operator-=(ptrdiff_t aDelta) - { - return Base::Intrinsics::sub(Base::mValue, aDelta) - aDelta; - } - -private: - Atomic(Atomic& aOther) = delete; -}; - -/** - * Atomic implementation for enum types. - * - * The atomic store and load operations and the atomic swap method is provided. - */ -template -class Atomic::value>::Type> - : public detail::AtomicBase -{ - typedef typename detail::AtomicBase Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(T aInit) : Base(aInit) {} - - operator T() const { return T(Base::Intrinsics::load(Base::mValue)); } - - using Base::operator=; - -private: - Atomic(Atomic& aOther) = delete; -}; - -/** - * Atomic implementation for boolean types. - * - * The atomic store and load operations and the atomic swap method is provided. - * - * Note: - * - * - sizeof(Atomic) != sizeof(bool) for some implementations of - * bool and/or some implementations of std::atomic. This is allowed in - * [atomic.types.generic]p9. - * - * - It's not obvious whether the 8-bit atomic functions on Windows are always - * inlined or not. If they are not inlined, the corresponding functions in the - * runtime library are not available on Windows XP. This is why we implement - * Atomic with an underlying type of uint32_t. - */ -template -class Atomic - : protected detail::AtomicBase -{ - typedef typename detail::AtomicBase Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(bool aInit) : Base(aInit) {} - - // We provide boolean wrappers for the underlying AtomicBase methods. - MOZ_IMPLICIT operator bool() const - { - return Base::Intrinsics::load(Base::mValue); - } - - bool operator=(bool aVal) - { - return Base::operator=(aVal); - } - - bool exchange(bool aVal) - { - return Base::exchange(aVal); - } - - bool compareExchange(bool aOldValue, bool aNewValue) - { - return Base::compareExchange(aOldValue, aNewValue); - } - -private: - Atomic(Atomic& aOther) = delete; -}; - -} // namespace mozilla - -#endif /* mozilla_Atomics_h */ diff --git a/sources/firefox/mozilla/Attributes.h b/sources/firefox/mozilla/Attributes.h deleted file mode 100644 index 8c7a9664..00000000 --- a/sources/firefox/mozilla/Attributes.h +++ /dev/null @@ -1,747 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implementations of various class and method modifier attributes. */ - -#ifndef mozilla_Attributes_h -#define mozilla_Attributes_h - -#include "mozilla/Compiler.h" - -/* - * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the - * method decorated with it must be inlined, even if the compiler thinks - * otherwise. This is only a (much) stronger version of the inline hint: - * compilers are not guaranteed to respect it (although they're much more likely - * to do so). - * - * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the - * compiler to inline even in DEBUG builds. It should be used very rarely. - */ -#if defined(_MSC_VER) -# define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline -#elif defined(__GNUC__) -# define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) inline -#else -# define MOZ_ALWAYS_INLINE_EVEN_DEBUG inline -#endif - -#if !defined(DEBUG) -# define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG -#elif defined(_MSC_VER) && !defined(__cplusplus) -# define MOZ_ALWAYS_INLINE __inline -#else -# define MOZ_ALWAYS_INLINE inline -#endif - -#if defined(_MSC_VER) -/* - * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality - * without warnings (functionality used by the macros below). These modes are - * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more - * standardly, by checking whether __cplusplus has a C++11 or greater value. - * Current versions of g++ do not correctly set __cplusplus, so we check both - * for forward compatibility. - */ -# define MOZ_HAVE_NEVER_INLINE __declspec(noinline) -# define MOZ_HAVE_NORETURN __declspec(noreturn) -#elif defined(__clang__) - /* - * Per Clang documentation, "Note that marketing version numbers should not - * be used to check for language features, as different vendors use different - * numbering schemes. Instead, use the feature checking macros." - */ -# ifndef __has_extension -# define __has_extension __has_feature /* compatibility, for older versions of clang */ -# endif -# if __has_attribute(noinline) -# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) -# endif -# if __has_attribute(noreturn) -# define MOZ_HAVE_NORETURN __attribute__((noreturn)) -# endif -#elif defined(__GNUC__) -# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) -# define MOZ_HAVE_NORETURN __attribute__((noreturn)) -# define MOZ_HAVE_NORETURN_PTR __attribute__((noreturn)) -#endif - -/* - * When built with clang analyzer (a.k.a scan-build), define MOZ_HAVE_NORETURN - * to mark some false positives - */ -#ifdef __clang_analyzer__ -# if __has_extension(attribute_analyzer_noreturn) -# define MOZ_HAVE_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) -# endif -#endif - -/* - * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the - * method decorated with it must never be inlined, even if the compiler would - * otherwise choose to inline the method. Compilers aren't absolutely - * guaranteed to support this, but most do. - */ -#if defined(MOZ_HAVE_NEVER_INLINE) -# define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE -#else -# define MOZ_NEVER_INLINE /* no support */ -#endif - -/* - * MOZ_NORETURN, specified at the start of a function declaration, indicates - * that the given function does not return. (The function definition does not - * need to be annotated.) - * - * MOZ_NORETURN void abort(const char* msg); - * - * This modifier permits the compiler to optimize code assuming a call to such a - * function will never return. It also enables the compiler to avoid spurious - * warnings about not initializing variables, or about any other seemingly-dodgy - * operations performed after the function returns. - * - * There are two variants. The GCC version of NORETURN may be applied to a - * function pointer, while for MSVC it may not. - * - * This modifier does not affect the corresponding function's linking behavior. - */ -#if defined(MOZ_HAVE_NORETURN) -# define MOZ_NORETURN MOZ_HAVE_NORETURN -#else -# define MOZ_NORETURN /* no support */ -#endif -#if defined(MOZ_HAVE_NORETURN_PTR) -# define MOZ_NORETURN_PTR MOZ_HAVE_NORETURN_PTR -#else -# define MOZ_NORETURN_PTR /* no support */ -#endif - -/** - * MOZ_COLD tells the compiler that a function is "cold", meaning infrequently - * executed. This may lead it to optimize for size more aggressively than speed, - * or to allocate the body of the function in a distant part of the text segment - * to help keep it from taking up unnecessary icache when it isn't in use. - * - * Place this attribute at the very beginning of a function definition. For - * example, write - * - * MOZ_COLD int foo(); - * - * or - * - * MOZ_COLD int foo() { return 42; } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_COLD __attribute__ ((cold)) -#else -# define MOZ_COLD -#endif - -/** - * MOZ_NONNULL tells the compiler that some of the arguments to a function are - * known to be non-null. The arguments are a list of 1-based argument indexes - * identifying arguments which are known to be non-null. - * - * Place this attribute at the very beginning of a function definition. For - * example, write - * - * MOZ_NONNULL(1, 2) int foo(char *p, char *q); - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__))) -#else -# define MOZ_NONNULL(...) -#endif - -/** - * MOZ_NONNULL_RETURN tells the compiler that the function's return value is - * guaranteed to be a non-null pointer, which may enable the compiler to - * optimize better at call sites. - * - * Place this attribute at the end of a function declaration. For example, - * - * char* foo(char *p, char *q) MOZ_NONNULL_RETURN; - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_NONNULL_RETURN __attribute__ ((returns_nonnull)) -#else -# define MOZ_NONNULL_RETURN -#endif - -/* - * MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS, specified at the end of a function - * declaration, indicates that for the purposes of static analysis, this - * function does not return. (The function definition does not need to be - * annotated.) - * - * MOZ_ReportCrash(const char* s, const char* file, int ln) - * MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS - * - * Some static analyzers, like scan-build from clang, can use this information - * to eliminate false positives. From the upstream documentation of scan-build: - * "This attribute is useful for annotating assertion handlers that actually - * can return, but for the purpose of using the analyzer we want to pretend - * that such functions do not return." - * - */ -#if defined(MOZ_HAVE_ANALYZER_NORETURN) -# define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS MOZ_HAVE_ANALYZER_NORETURN -#else -# define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS /* no support */ -#endif - -/* - * MOZ_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time - * instrumentation shipped with Clang and GCC) to not instrument the annotated - * function. Furthermore, it will prevent the compiler from inlining the - * function because inlining currently breaks the blacklisting mechanism of - * AddressSanitizer. - */ -#if defined(__has_feature) -# if __has_feature(address_sanitizer) -# define MOZ_HAVE_ASAN_BLACKLIST -# endif -#elif defined(__GNUC__) -# if defined(__SANITIZE_ADDRESS__) -# define MOZ_HAVE_ASAN_BLACKLIST -# endif -#endif - -#if defined(MOZ_HAVE_ASAN_BLACKLIST) -# define MOZ_ASAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_address)) -#else -# define MOZ_ASAN_BLACKLIST /* nothing */ -#endif - -/* - * MOZ_TSAN_BLACKLIST is a macro to tell ThreadSanitizer (a compile-time - * instrumentation shipped with Clang) to not instrument the annotated function. - * Furthermore, it will prevent the compiler from inlining the function because - * inlining currently breaks the blacklisting mechanism of ThreadSanitizer. - */ -#if defined(__has_feature) -# if __has_feature(thread_sanitizer) -# define MOZ_TSAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_thread)) -# else -# define MOZ_TSAN_BLACKLIST /* nothing */ -# endif -#else -# define MOZ_TSAN_BLACKLIST /* nothing */ -#endif - -/* - * The MOZ_NO_SANITIZE_* family of macros is an annotation based on a more recently - * introduced Clang feature that allows disabling various sanitizer features for - * the particular function, including those from UndefinedBehaviorSanitizer. - */ - -#if defined(__has_attribute) -# if __has_attribute(no_sanitize) -# define MOZ_HAVE_NO_SANITIZE_ATTR -# endif -#endif - -#if defined(MOZ_HAVE_NO_SANITIZE_ATTR) -# define MOZ_NO_SANITIZE_UINT_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow"))) -# define MOZ_NO_SANITIZE_INT_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow"))) -#else -# define MOZ_NO_SANITIZE_UINT_OVERFLOW /* nothing */ -# define MOZ_NO_SANITIZE_INT_OVERFLOW /* nothing */ -#endif - - -#undef MOZ_HAVE_NO_SANITIZE_ATTR - - -/** - * MOZ_ALLOCATOR tells the compiler that the function it marks returns either a - * "fresh", "pointer-free" block of memory, or nullptr. "Fresh" means that the - * block is not pointed to by any other reachable pointer in the program. - * "Pointer-free" means that the block contains no pointers to any valid object - * in the program. It may be initialized with other (non-pointer) values. - * - * Placing this attribute on appropriate functions helps GCC analyze pointer - * aliasing more accurately in their callers. - * - * GCC warns if a caller ignores the value returned by a function marked with - * MOZ_ALLOCATOR: it is hard to imagine cases where dropping the value returned - * by a function that meets the criteria above would be intentional. - * - * Place this attribute after the argument list and 'this' qualifiers of a - * function definition. For example, write - * - * void *my_allocator(size_t) MOZ_ALLOCATOR; - * - * or - * - * void *my_allocator(size_t bytes) MOZ_ALLOCATOR { ... } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_ALLOCATOR __attribute__ ((malloc, warn_unused_result)) -#else -# define MOZ_ALLOCATOR -#endif - -/** - * MOZ_MUST_USE tells the compiler to emit a warning if a function's - * return value is not used by the caller. - * - * Place this attribute at the very beginning of a function declaration. For - * example, write - * - * MOZ_MUST_USE int foo(); - * or - * MOZ_MUST_USE int foo() { return 42; } - * - * MOZ_MUST_USE is most appropriate for functions where the return value is - * some kind of success/failure indicator -- often |nsresult|, |bool| or |int| - * -- because these functions are most commonly the ones that have missing - * checks. There are three cases of note. - * - * - Fallible functions whose return values should always be checked. For - * example, a function that opens a file should always be checked because any - * subsequent operations on the file will fail if opening it fails. Such - * functions should be given a MOZ_MUST_USE annotation. - * - * - Fallible functions whose return value need not always be checked. For - * example, a function that closes a file might not be checked because it's - * common that no further operations would be performed on the file. Such - * functions do not need a MOZ_MUST_USE annotation. - * - * - Infallible functions, i.e. ones that always return a value indicating - * success. These do not need a MOZ_MUST_USE annotation. Ideally, they would - * be converted to not return a success/failure indicator, though sometimes - * interface constraints prevent this. - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_MUST_USE __attribute__ ((warn_unused_result)) -#else -# define MOZ_MUST_USE -#endif - -/** - * MOZ_MAYBE_UNUSED suppresses compiler warnings about functions that are - * never called (in this build configuration, at least). - * - * Place this attribute at the very beginning of a function declaration. For - * example, write - * - * MOZ_MAYBE_UNUSED int foo(); - * - * or - * - * MOZ_MAYBE_UNUSED int foo() { return 42; } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_MAYBE_UNUSED __attribute__ ((__unused__)) -#elif defined(_MSC_VER) -# define MOZ_MAYBE_UNUSED __pragma(warning(suppress:4505)) -#else -# define MOZ_MAYBE_UNUSED -#endif - -#ifdef __cplusplus - -/** - * MOZ_FALLTHROUGH is an annotation to suppress compiler warnings about switch - * cases that fall through without a break or return statement. MOZ_FALLTHROUGH - * is only needed on cases that have code. - * - * MOZ_FALLTHROUGH_ASSERT is an annotation to suppress compiler warnings about - * switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in - * debug builds, but intentionally fall through in release builds. See comment - * in Assertions.h for more details. - * - * switch (foo) { - * case 1: // These cases have no code. No fallthrough annotations are needed. - * case 2: - * case 3: // This case has code, so a fallthrough annotation is needed! - * foo++; - * MOZ_FALLTHROUGH; - * case 4: - * return foo; - * - * default: - * // This case asserts in debug builds, falls through in release. - * MOZ_FALLTHROUGH_ASSERT("Unexpected foo value?!"); - * case 5: - * return 5; - * } - */ -#ifndef __has_cpp_attribute -# define __has_cpp_attribute(x) 0 -#endif - -#if __has_cpp_attribute(clang::fallthrough) -# define MOZ_FALLTHROUGH [[clang::fallthrough]] -#elif __has_cpp_attribute(gnu::fallthrough) -# define MOZ_FALLTHROUGH [[gnu::fallthrough]] -#elif defined(_MSC_VER) - /* - * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis): - * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx - */ -# include -# define MOZ_FALLTHROUGH __fallthrough -#else -# define MOZ_FALLTHROUGH /* FALLTHROUGH */ -#endif - -/* - * The following macros are attributes that support the static analysis plugin - * included with Mozilla, and will be implemented (when such support is enabled) - * as C++11 attributes. Since such attributes are legal pretty much everywhere - * and have subtly different semantics depending on their placement, the - * following is a guide on where to place the attributes. - * - * Attributes that apply to a struct or class precede the name of the class: - * (Note that this is different from the placement of final for classes!) - * - * class MOZ_CLASS_ATTRIBUTE SomeClass {}; - * - * Attributes that apply to functions follow the parentheses and const - * qualifiers but precede final, override and the function body: - * - * void DeclaredFunction() MOZ_FUNCTION_ATTRIBUTE; - * void SomeFunction() MOZ_FUNCTION_ATTRIBUTE {} - * void PureFunction() const MOZ_FUNCTION_ATTRIBUTE = 0; - * void OverriddenFunction() MOZ_FUNCTION_ATTIRBUTE override; - * - * Attributes that apply to variables or parameters follow the variable's name: - * - * int variable MOZ_VARIABLE_ATTRIBUTE; - * - * Attributes that apply to types follow the type name: - * - * typedef int MOZ_TYPE_ATTRIBUTE MagicInt; - * int MOZ_TYPE_ATTRIBUTE someVariable; - * int* MOZ_TYPE_ATTRIBUTE magicPtrInt; - * int MOZ_TYPE_ATTRIBUTE* ptrToMagicInt; - * - * Attributes that apply to statements precede the statement: - * - * MOZ_IF_ATTRIBUTE if (x == 0) - * MOZ_DO_ATTRIBUTE do { } while (0); - * - * Attributes that apply to labels precede the label: - * - * MOZ_LABEL_ATTRIBUTE target: - * goto target; - * MOZ_CASE_ATTRIBUTE case 5: - * MOZ_DEFAULT_ATTRIBUTE default: - * - * The static analyses that are performed by the plugin are as follows: - * - * MOZ_CAN_RUN_SCRIPT: Applies to functions which can run script. Callers of - * this function must also be marked as MOZ_CAN_RUN_SCRIPT, and all refcounted - * arguments must be strongly held in the caller. - * MOZ_MUST_OVERRIDE: Applies to all C++ member functions. All immediate - * subclasses must provide an exact override of this method; if a subclass - * does not override this method, the compiler will emit an error. This - * attribute is not limited to virtual methods, so if it is applied to a - * nonvirtual method and the subclass does not provide an equivalent - * definition, the compiler will emit an error. - * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is - * expected to live on the stack, so it is a compile-time error to use it, or - * an array of such objects, as a global or static variable, or as the type of - * a new expression (unless placement new is being used). If a member of - * another class uses this class, or if another class inherits from this - * class, then it is considered to be a stack class as well, although this - * attribute need not be provided in such cases. - * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is - * expected to live on the stack or in static storage, so it is a compile-time - * error to use it, or an array of such objects, as the type of a new - * expression. If a member of another class uses this class, or if another - * class inherits from this class, then it is considered to be a non-heap class - * as well, although this attribute need not be provided in such cases. - * MOZ_HEAP_CLASS: Applies to all classes. Any class with this annotation is - * expected to live on the heap, so it is a compile-time error to use it, or - * an array of such objects, as the type of a variable declaration, or as a - * temporary object. If a member of another class uses this class, or if - * another class inherits from this class, then it is considered to be a heap - * class as well, although this attribute need not be provided in such cases. - * MOZ_NON_TEMPORARY_CLASS: Applies to all classes. Any class with this - * annotation is expected not to live in a temporary. If a member of another - * class uses this class or if another class inherits from this class, then it - * is considered to be a non-temporary class as well, although this attribute - * need not be provided in such cases. - * MOZ_RAII: Applies to all classes. Any class with this annotation is assumed - * to be a RAII guard, which is expected to live on the stack in an automatic - * allocation. It is prohibited from being allocated in a temporary, static - * storage, or on the heap. This is a combination of MOZ_STACK_CLASS and - * MOZ_NON_TEMPORARY_CLASS. - * MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS: Applies to all classes that are - * intended to prevent introducing static initializers. This attribute - * currently makes it a compile-time error to instantiate these classes - * anywhere other than at the global scope, or as a static member of a class. - * In non-debug mode, it also prohibits non-trivial constructors and - * destructors. - * MOZ_TRIVIAL_CTOR_DTOR: Applies to all classes that must have both a trivial - * or constexpr constructor and a trivial destructor. Setting this attribute - * on a class makes it a compile-time error for that class to get a - * non-trivial constructor or destructor for any reason. - * MOZ_HEAP_ALLOCATOR: Applies to any function. This indicates that the return - * value is allocated on the heap, and will as a result check such allocations - * during MOZ_STACK_CLASS and MOZ_NONHEAP_CLASS annotation checking. - * MOZ_IMPLICIT: Applies to constructors. Implicit conversion constructors - * are disallowed by default unless they are marked as MOZ_IMPLICIT. This - * attribute must be used for constructors which intend to provide implicit - * conversions. - * MOZ_IS_REFPTR: Applies to class declarations of ref pointer to mark them as - * such for use with static-analysis. - * A ref pointer is an object wrapping a pointer and automatically taking care - * of its refcounting upon construction/destruction/transfer of ownership. - * This annotation implies MOZ_IS_SMARTPTR_TO_REFCOUNTED. - * MOZ_IS_SMARTPTR_TO_REFCOUNTED: Applies to class declarations of smart - * pointers to ref counted classes to mark them as such for use with - * static-analysis. - * MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT: Applies to functions. Makes it a compile - * time error to pass arithmetic expressions on variables to the function. - * MOZ_OWNING_REF: Applies to declarations of pointers to reference counted - * types. This attribute tells the compiler that the raw pointer is a strong - * reference, where ownership through methods such as AddRef and Release is - * managed manually. This can make the compiler ignore these pointers when - * validating the usage of pointers otherwise. - * - * Example uses include owned pointers inside of unions, and pointers stored - * in POD types where a using a smart pointer class would make the object - * non-POD. - * MOZ_NON_OWNING_REF: Applies to declarations of pointers to reference counted - * types. This attribute tells the compiler that the raw pointer is a weak - * reference, which is ensured to be valid by a guarantee that the reference - * will be nulled before the pointer becomes invalid. This can make the compiler - * ignore these pointers when validating the usage of pointers otherwise. - * - * Examples include an mOwner pointer, which is nulled by the owning class's - * destructor, and is null-checked before dereferencing. - * MOZ_UNSAFE_REF: Applies to declarations of pointers to reference counted types. - * Occasionally there are non-owning references which are valid, but do not take - * the form of a MOZ_NON_OWNING_REF. Their safety may be dependent on the behaviour - * of API consumers. The string argument passed to this macro documents the safety - * conditions. This can make the compiler ignore these pointers when validating - * the usage of pointers elsewhere. - * - * Examples include an nsIAtom* member which is known at compile time to point to a - * static atom which is valid throughout the lifetime of the program, or an API which - * stores a pointer, but doesn't take ownership over it, instead requiring the API - * consumer to correctly null the value before it becomes invalid. - * - * Use of this annotation is discouraged when a strong reference or one of the above - * two annotations can be used instead. - * MOZ_NO_ADDREF_RELEASE_ON_RETURN: Applies to function declarations. Makes it - * a compile time error to call AddRef or Release on the return value of a - * function. This is intended to be used with operator->() of our smart - * pointer classes to ensure that the refcount of an object wrapped in a - * smart pointer is not manipulated directly. - * MOZ_MUST_USE_TYPE: Applies to type declarations. Makes it a compile time - * error to not use the return value of a function which has this type. This - * is intended to be used with types which it is an error to not use. - * MOZ_NEEDS_NO_VTABLE_TYPE: Applies to template class declarations. Makes it - * a compile time error to instantiate this template with a type parameter which - * has a VTable. - * MOZ_NON_MEMMOVABLE: Applies to class declarations for types that are not safe - * to be moved in memory using memmove(). - * MOZ_NEEDS_MEMMOVABLE_TYPE: Applies to template class declarations where the - * template arguments are required to be safe to move in memory using - * memmove(). Passing MOZ_NON_MEMMOVABLE types to these templates is a - * compile time error. - * MOZ_NEEDS_MEMMOVABLE_MEMBERS: Applies to class declarations where each member - * must be safe to move in memory using memmove(). MOZ_NON_MEMMOVABLE types - * used in members of these classes are compile time errors. - * MOZ_NO_DANGLING_ON_TEMPORARIES: Applies to method declarations which return - * a pointer that is freed when the destructor of the class is called. This - * prevents these methods from being called on temporaries of the class, - * reducing risks of use-after-free. - * This attribute cannot be applied to && methods. - * In some cases, adding a deleted &&-qualified overload is too restrictive as - * this method should still be callable as a non-escaping argument to another - * function. This annotation can be used in those cases. - * MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS: Applies to template class - * declarations where an instance of the template should be considered, for - * static analysis purposes, to inherit any type annotations (such as - * MOZ_MUST_USE_TYPE and MOZ_STACK_CLASS) from its template arguments. - * MOZ_INIT_OUTSIDE_CTOR: Applies to class member declarations. Occasionally - * there are class members that are not initialized in the constructor, - * but logic elsewhere in the class ensures they are initialized prior to use. - * Using this attribute on a member disables the check that this member must be - * initialized in constructors via list-initialization, in the constructor body, - * or via functions called from the constructor body. - * MOZ_IS_CLASS_INIT: Applies to class method declarations. Occasionally the - * constructor doesn't initialize all of the member variables and another function - * is used to initialize the rest. This marker is used to make the static analysis - * tool aware that the marked function is part of the initialization process - * and to include the marked function in the scan mechanism that determines witch - * member variables still remain uninitialized. - * MOZ_NON_PARAM: Applies to types. Makes it compile time error to use the type - * in parameter without pointer or reference. - * MOZ_NON_AUTOABLE: Applies to class declarations. Makes it a compile time error to - * use `auto` in place of this type in variable declarations. This is intended to - * be used with types which are intended to be implicitly constructed into other - * other types before being assigned to variables. - * MOZ_REQUIRED_BASE_METHOD: Applies to virtual class method declarations. - * Sometimes derived classes override methods that need to be called by their - * overridden counterparts. This marker indicates that the marked method must - * be called by the method that it overrides. - * MOZ_MUST_RETURN_FROM_CALLER: Applies to function or method declarations. - * Callers of the annotated function/method must return from that function - * within the calling block using an explicit `return` statement. - * Only calls to Constructors, references to local and member variables, - * and calls to functions or methods marked as MOZ_MAY_CALL_AFTER_MUST_RETURN - * may be made after the MUST_RETURN_FROM_CALLER call. - * MOZ_MAY_CALL_AFTER_MUST_RETURN: Applies to function or method declarations. - * Calls to these methods may be made in functions after calls a - * MOZ_MUST_RETURN_FROM_CALLER function or method. - */ -#ifdef MOZ_CLANG_PLUGIN -# define MOZ_CAN_RUN_SCRIPT __attribute__((annotate("moz_can_run_script"))) -# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) -# define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) -# define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) -# define MOZ_HEAP_CLASS __attribute__((annotate("moz_heap_class"))) -# define MOZ_NON_TEMPORARY_CLASS __attribute__((annotate("moz_non_temporary_class"))) -# define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor"))) -# ifdef DEBUG - /* in debug builds, these classes do have non-trivial constructors. */ -# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) -# else -# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) \ - MOZ_TRIVIAL_CTOR_DTOR -# endif -# define MOZ_IMPLICIT __attribute__((annotate("moz_implicit"))) -# define MOZ_IS_SMARTPTR_TO_REFCOUNTED __attribute__((annotate("moz_is_smartptr_to_refcounted"))) -# define MOZ_IS_REFPTR __attribute__((annotate("moz_is_refptr"))) \ - MOZ_IS_SMARTPTR_TO_REFCOUNTED -# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg"))) -# define MOZ_OWNING_REF __attribute__((annotate("moz_strong_ref"))) -# define MOZ_NON_OWNING_REF __attribute__((annotate("moz_weak_ref"))) -# define MOZ_UNSAFE_REF(reason) __attribute__((annotate("moz_weak_ref"))) -# define MOZ_NO_ADDREF_RELEASE_ON_RETURN __attribute__((annotate("moz_no_addref_release_on_return"))) -# define MOZ_MUST_USE_TYPE __attribute__((annotate("moz_must_use_type"))) -# define MOZ_NEEDS_NO_VTABLE_TYPE __attribute__((annotate("moz_needs_no_vtable_type"))) -# define MOZ_NON_MEMMOVABLE __attribute__((annotate("moz_non_memmovable"))) -# define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type"))) -# define MOZ_NEEDS_MEMMOVABLE_MEMBERS __attribute__((annotate("moz_needs_memmovable_members"))) -# define MOZ_NO_DANGLING_ON_TEMPORARIES __attribute__((annotate("moz_no_dangling_on_temporaries"))) -# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS \ - __attribute__((annotate("moz_inherit_type_annotations_from_template_args"))) -# define MOZ_NON_AUTOABLE __attribute__((annotate("moz_non_autoable"))) -# define MOZ_INIT_OUTSIDE_CTOR \ - __attribute__((annotate("moz_ignore_ctor_initialization"))) -# define MOZ_IS_CLASS_INIT \ - __attribute__((annotate("moz_is_class_init"))) -# define MOZ_NON_PARAM \ - __attribute__((annotate("moz_non_param"))) -# define MOZ_REQUIRED_BASE_METHOD \ - __attribute__((annotate("moz_required_base_method"))) -# define MOZ_MUST_RETURN_FROM_CALLER \ - __attribute__((annotate("moz_must_return_from_caller"))) -# define MOZ_MAY_CALL_AFTER_MUST_RETURN \ - __attribute__((annotate("moz_may_call_after_must_return"))) -/* - * It turns out that clang doesn't like void func() __attribute__ {} without a - * warning, so use pragmas to disable the warning. This code won't work on GCC - * anyways, so the warning is safe to ignore. - */ -# define MOZ_HEAP_ALLOCATOR \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((annotate("moz_heap_allocator"))) \ - _Pragma("clang diagnostic pop") -#else -# define MOZ_CAN_RUN_SCRIPT /* nothing */ -# define MOZ_MUST_OVERRIDE /* nothing */ -# define MOZ_STACK_CLASS /* nothing */ -# define MOZ_NONHEAP_CLASS /* nothing */ -# define MOZ_HEAP_CLASS /* nothing */ -# define MOZ_NON_TEMPORARY_CLASS /* nothing */ -# define MOZ_TRIVIAL_CTOR_DTOR /* nothing */ -# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */ -# define MOZ_IMPLICIT /* nothing */ -# define MOZ_IS_SMARTPTR_TO_REFCOUNTED /* nothing */ -# define MOZ_IS_REFPTR /* nothing */ -# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT /* nothing */ -# define MOZ_HEAP_ALLOCATOR /* nothing */ -# define MOZ_OWNING_REF /* nothing */ -# define MOZ_NON_OWNING_REF /* nothing */ -# define MOZ_UNSAFE_REF(reason) /* nothing */ -# define MOZ_NO_ADDREF_RELEASE_ON_RETURN /* nothing */ -# define MOZ_MUST_USE_TYPE /* nothing */ -# define MOZ_NEEDS_NO_VTABLE_TYPE /* nothing */ -# define MOZ_NON_MEMMOVABLE /* nothing */ -# define MOZ_NEEDS_MEMMOVABLE_TYPE /* nothing */ -# define MOZ_NEEDS_MEMMOVABLE_MEMBERS /* nothing */ -# define MOZ_NO_DANGLING_ON_TEMPORARIES /* nothing */ -# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS /* nothing */ -# define MOZ_INIT_OUTSIDE_CTOR /* nothing */ -# define MOZ_IS_CLASS_INIT /* nothing */ -# define MOZ_NON_PARAM /* nothing */ -# define MOZ_NON_AUTOABLE /* nothing */ -# define MOZ_REQUIRED_BASE_METHOD /* nothing */ -# define MOZ_MUST_RETURN_FROM_CALLER /* nothing */ -# define MOZ_MAY_CALL_AFTER_MUST_RETURN /* nothing */ -#endif /* MOZ_CLANG_PLUGIN */ - -#define MOZ_RAII MOZ_NON_TEMPORARY_CLASS MOZ_STACK_CLASS - -#endif /* __cplusplus */ - -/** - * Printf style formats. MOZ_FORMAT_PRINTF can be used to annotate a - * function or method that is "printf-like"; this will let (some) - * compilers check that the arguments match the template string. - * - * This macro takes two arguments. The first argument is the argument - * number of the template string. The second argument is the argument - * number of the '...' argument holding the arguments. - * - * Argument numbers start at 1. Note that the implicit "this" - * argument of a non-static member function counts as an argument. - * - * So, for a simple case like: - * void print_something (int whatever, const char *fmt, ...); - * The corresponding annotation would be - * MOZ_FORMAT_PRINTF(2, 3) - * However, if "print_something" were a non-static member function, - * then the annotation would be: - * MOZ_FORMAT_PRINTF(3, 4) - * - * The second argument should be 0 for vprintf-like functions; that - * is, those taking a va_list argument. - * - * Note that the checking is limited to standards-conforming - * printf-likes, and in particular this should not be used for - * PR_snprintf and friends, which are "printf-like" but which assign - * different meanings to the various formats. - * - * MinGW requires special handling due to different format specifiers - * on different platforms. The macro __MINGW_PRINTF_FORMAT maps to - * either gnu_printf or ms_printf depending on where we are compiling - * to avoid warnings on format specifiers that are legal. - */ -#ifdef __MINGW32__ -#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) \ - __attribute__ ((format (__MINGW_PRINTF_FORMAT, stringIndex, firstToCheck))) -#elif __GNUC__ -#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) \ - __attribute__ ((format (printf, stringIndex, firstToCheck))) -#else -#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) -#endif - -/** - * To manually declare an XPCOM ABI-compatible virtual function, the following - * macros can be used to handle the non-standard ABI used on Windows for COM - * compatibility. E.g.: - * - * virtual ReturnType MOZ_XPCOM_ABI foo(); - */ -#if defined(XP_WIN) -# define MOZ_XPCOM_ABI __stdcall -#else -# define MOZ_XPCOM_ABI -#endif - -#endif /* mozilla_Attributes_h */ diff --git a/sources/firefox/mozilla/Casting.h b/sources/firefox/mozilla/Casting.h deleted file mode 100644 index adf2c904..00000000 --- a/sources/firefox/mozilla/Casting.h +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Cast operations to supplement the built-in casting operations. */ - -#ifndef mozilla_Casting_h -#define mozilla_Casting_h - -#include "mozilla/Assertions.h" -#include "mozilla/TypeTraits.h" - -#include - -namespace mozilla { - -/** - * Sets the outparam value of type |To| with the same underlying bit pattern of - * |aFrom|. - * - * |To| and |From| must be types of the same size; be careful of cross-platform - * size differences, or this might fail to compile on some but not all - * platforms. - * - * There is also a variant that returns the value directly. In most cases, the - * two variants should be identical. However, in the specific case of x86 - * chips, the behavior differs: returning floating-point values directly is done - * through the x87 stack, and x87 loads and stores turn signaling NaNs into - * quiet NaNs... silently. Returning floating-point values via outparam, - * however, is done entirely within the SSE registers when SSE2 floating-point - * is enabled in the compiler, which has semantics-preserving behavior you would - * expect. - * - * If preserving the distinction between signaling NaNs and quiet NaNs is - * important to you, you should use the outparam version. In all other cases, - * you should use the direct return version. - */ -template -inline void -BitwiseCast(const From aFrom, To* aResult) -{ - static_assert(sizeof(From) == sizeof(To), - "To and From must have the same size"); - union - { - From mFrom; - To mTo; - } u; - u.mFrom = aFrom; - *aResult = u.mTo; -} - -template -inline To -BitwiseCast(const From aFrom) -{ - To temp; - BitwiseCast(aFrom, &temp); - return temp; -} - -namespace detail { - -enum ToSignedness { ToIsSigned, ToIsUnsigned }; -enum FromSignedness { FromIsSigned, FromIsUnsigned }; - -template::value ? FromIsSigned : FromIsUnsigned, - ToSignedness = IsSigned::value ? ToIsSigned : ToIsUnsigned> -struct BoundsCheckImpl; - -// Implicit conversions on operands to binary operations make this all a bit -// hard to verify. Attempt to ease the pain below by *only* comparing values -// that are obviously the same type (and will undergo no further conversions), -// even when it's not strictly necessary, for explicitness. - -enum UUComparison { FromIsBigger, FromIsNotBigger }; - -// Unsigned-to-unsigned range check - -template sizeof(To)) - ? FromIsBigger - : FromIsNotBigger> -struct UnsignedUnsignedCheck; - -template -struct UnsignedUnsignedCheck -{ -public: - static bool checkBounds(const From aFrom) - { - return aFrom <= From(To(-1)); - } -}; - -template -struct UnsignedUnsignedCheck -{ -public: - static bool checkBounds(const From aFrom) - { - return true; - } -}; - -template -struct BoundsCheckImpl -{ -public: - static bool checkBounds(const From aFrom) - { - return UnsignedUnsignedCheck::checkBounds(aFrom); - } -}; - -// Signed-to-unsigned range check - -template -struct BoundsCheckImpl -{ -public: - static bool checkBounds(const From aFrom) - { - if (aFrom < 0) { - return false; - } - if (sizeof(To) >= sizeof(From)) { - return true; - } - return aFrom <= From(To(-1)); - } -}; - -// Unsigned-to-signed range check - -enum USComparison { FromIsSmaller, FromIsNotSmaller }; - -template -struct UnsignedSignedCheck; - -template -struct UnsignedSignedCheck -{ -public: - static bool checkBounds(const From aFrom) - { - return true; - } -}; - -template -struct UnsignedSignedCheck -{ -public: - static bool checkBounds(const From aFrom) - { - const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); - return aFrom <= From(MaxValue); - } -}; - -template -struct BoundsCheckImpl -{ -public: - static bool checkBounds(const From aFrom) - { - return UnsignedSignedCheck::checkBounds(aFrom); - } -}; - -// Signed-to-signed range check - -template -struct BoundsCheckImpl -{ -public: - static bool checkBounds(const From aFrom) - { - if (sizeof(From) <= sizeof(To)) { - return true; - } - const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); - const To MinValue = -MaxValue - To(1); - return From(MinValue) <= aFrom && - From(aFrom) <= From(MaxValue); - } -}; - -template::value && - IsIntegral::value> -class BoundsChecker; - -template -class BoundsChecker -{ -public: - static bool checkBounds(const From aFrom) { return true; } -}; - -template -class BoundsChecker -{ -public: - static bool checkBounds(const From aFrom) - { - return BoundsCheckImpl::checkBounds(aFrom); - } -}; - -template -inline bool -IsInBounds(const From aFrom) -{ - return BoundsChecker::checkBounds(aFrom); -} - -} // namespace detail - -/** - * Cast a value of integral type |From| to a value of integral type |To|, - * asserting that the cast will be a safe cast per C++ (that is, that |to| is in - * the range of values permitted for the type |From|). - */ -template -inline To -AssertedCast(const From aFrom) -{ - MOZ_ASSERT((detail::IsInBounds(aFrom))); - return static_cast(aFrom); -} - -/** - * Cast a value of integral type |From| to a value of integral type |To|, - * release asserting that the cast will be a safe cast per C++ (that is, that - * |to| is in the range of values permitted for the type |From|). - */ -template -inline To -ReleaseAssertedCast(const From aFrom) -{ - MOZ_RELEASE_ASSERT((detail::IsInBounds(aFrom))); - return static_cast(aFrom); -} - -} // namespace mozilla - -#endif /* mozilla_Casting_h */ diff --git a/sources/firefox/mozilla/CheckedInt.h b/sources/firefox/mozilla/CheckedInt.h deleted file mode 100644 index 3eef2436..00000000 --- a/sources/firefox/mozilla/CheckedInt.h +++ /dev/null @@ -1,791 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Provides checked integers, detecting integer overflow and divide-by-0. */ - -#ifndef mozilla_CheckedInt_h -#define mozilla_CheckedInt_h - -#include -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/IntegerTypeTraits.h" - -namespace mozilla { - -template class CheckedInt; - -namespace detail { - -/* - * Step 1: manually record supported types - * - * What's nontrivial here is that there are different families of integer - * types: basic integer types and stdint types. It is merrily undefined which - * types from one family may be just typedefs for a type from another family. - * - * For example, on GCC 4.6, aside from the basic integer types, the only other - * type that isn't just a typedef for some of them, is int8_t. - */ - -struct UnsupportedType {}; - -template -struct IsSupportedPass2 -{ - static const bool value = false; -}; - -template -struct IsSupported -{ - static const bool value = IsSupportedPass2::value; -}; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - -template<> -struct IsSupported -{ static const bool value = true; }; - - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2 -{ static const bool value = true; }; - -/* - * Step 2: Implement the actual validity checks. - * - * Ideas taken from IntegerLib, code different. - */ - -template -struct TwiceBiggerType -{ - typedef typename detail::StdintTypeForSizeAndSignedness< - sizeof(IntegerType) * 2, - IsSigned::value - >::Type Type; -}; - -template -struct TwiceBiggerType -{ - typedef UnsupportedType Type; -}; - -template -inline bool -HasSignBit(T aX) -{ - // In C++, right bit shifts on negative values is undefined by the standard. - // Notice that signed-to-unsigned conversions are always well-defined in the - // standard, as the value congruent modulo 2**n as expected. By contrast, - // unsigned-to-signed is only well-defined if the value is representable. - return bool(typename MakeUnsigned::Type(aX) >> - PositionOfSignBit::value); -} - -// Bitwise ops may return a larger type, so it's good to use this inline -// helper guaranteeing that the result is really of type T. -template -inline T -BinaryComplement(T aX) -{ - return ~aX; -} - -template::value, - bool IsUSigned = IsSigned::value> -struct DoesRangeContainRange -{ -}; - -template -struct DoesRangeContainRange -{ - static const bool value = sizeof(T) >= sizeof(U); -}; - -template -struct DoesRangeContainRange -{ - static const bool value = sizeof(T) > sizeof(U); -}; - -template -struct DoesRangeContainRange -{ - static const bool value = false; -}; - -template::value, - bool IsUSigned = IsSigned::value, - bool DoesTRangeContainURange = DoesRangeContainRange::value> -struct IsInRangeImpl {}; - -template -struct IsInRangeImpl -{ - static bool constexpr run(U) - { - return true; - } -}; - -template -struct IsInRangeImpl -{ - static bool constexpr run(U aX) - { - return aX <= MaxValue::value && aX >= MinValue::value; - } -}; - -template -struct IsInRangeImpl -{ - static bool constexpr run(U aX) - { - return aX <= MaxValue::value; - } -}; - -template -struct IsInRangeImpl -{ - static bool constexpr run(U aX) - { - return sizeof(T) > sizeof(U) || aX <= U(MaxValue::value); - } -}; - -template -struct IsInRangeImpl -{ - static bool constexpr run(U aX) - { - return sizeof(T) >= sizeof(U) - ? aX >= 0 - : aX >= 0 && aX <= U(MaxValue::value); - } -}; - -template -inline constexpr bool -IsInRange(U aX) -{ - return IsInRangeImpl::run(aX); -} - -template -inline bool -IsAddValid(T aX, T aY) -{ - // Addition is valid if the sign of aX+aY is equal to either that of aX or - // that of aY. Since the value of aX+aY is undefined if we have a signed - // type, we compute it using the unsigned type of the same size. Beware! - // These bitwise operations can return a larger integer type, if T was a - // small type like int8_t, so we explicitly cast to T. - - typename MakeUnsigned::Type ux = aX; - typename MakeUnsigned::Type uy = aY; - typename MakeUnsigned::Type result = ux + uy; - return IsSigned::value - ? HasSignBit(BinaryComplement(T((result ^ aX) & (result ^ aY)))) - : BinaryComplement(aX) >= aY; -} - -template -inline bool -IsSubValid(T aX, T aY) -{ - // Subtraction is valid if either aX and aY have same sign, or aX-aY and aX - // have same sign. Since the value of aX-aY is undefined if we have a signed - // type, we compute it using the unsigned type of the same size. - typename MakeUnsigned::Type ux = aX; - typename MakeUnsigned::Type uy = aY; - typename MakeUnsigned::Type result = ux - uy; - - return IsSigned::value - ? HasSignBit(BinaryComplement(T((result ^ aX) & (aX ^ aY)))) - : aX >= aY; -} - -template::value, - bool TwiceBiggerTypeIsSupported = - IsSupported::Type>::value> -struct IsMulValidImpl {}; - -template -struct IsMulValidImpl -{ - static bool run(T aX, T aY) - { - typedef typename TwiceBiggerType::Type TwiceBiggerType; - TwiceBiggerType product = TwiceBiggerType(aX) * TwiceBiggerType(aY); - return IsInRange(product); - } -}; - -template -struct IsMulValidImpl -{ - static bool run(T aX, T aY) - { - const T max = MaxValue::value; - const T min = MinValue::value; - - if (aX == 0 || aY == 0) { - return true; - } - if (aX > 0) { - return aY > 0 - ? aX <= max / aY - : aY >= min / aX; - } - - // If we reach this point, we know that aX < 0. - return aY > 0 - ? aX >= min / aY - : aY >= max / aX; - } -}; - -template -struct IsMulValidImpl -{ - static bool run(T aX, T aY) - { - return aY == 0 || aX <= MaxValue::value / aY; - } -}; - -template -inline bool -IsMulValid(T aX, T aY) -{ - return IsMulValidImpl::run(aX, aY); -} - -template -inline bool -IsDivValid(T aX, T aY) -{ - // Keep in mind that in the signed case, min/-1 is invalid because - // abs(min)>max. - return aY != 0 && - !(IsSigned::value && aX == MinValue::value && aY == T(-1)); -} - -template::value> -struct IsModValidImpl; - -template -inline bool -IsModValid(T aX, T aY) -{ - return IsModValidImpl::run(aX, aY); -} - -/* - * Mod is pretty simple. - * For now, let's just use the ANSI C definition: - * If aX or aY are negative, the results are implementation defined. - * Consider these invalid. - * Undefined for aY=0. - * The result will never exceed either aX or aY. - * - * Checking that aX>=0 is a warning when T is unsigned. - */ - -template -struct IsModValidImpl -{ - static inline bool run(T aX, T aY) - { - return aY >= 1; - } -}; - -template -struct IsModValidImpl -{ - static inline bool run(T aX, T aY) - { - if (aX < 0) { - return false; - } - return aY >= 1; - } -}; - -template::value> -struct NegateImpl; - -template -struct NegateImpl -{ - static CheckedInt negate(const CheckedInt& aVal) - { - // Handle negation separately for signed/unsigned, for simpler code and to - // avoid an MSVC warning negating an unsigned value. - return CheckedInt(0, aVal.isValid() && aVal.mValue == 0); - } -}; - -template -struct NegateImpl -{ - static CheckedInt negate(const CheckedInt& aVal) - { - // Watch out for the min-value, which (with twos-complement) can't be - // negated as -min-value is then (max-value + 1). - if (!aVal.isValid() || aVal.mValue == MinValue::value) { - return CheckedInt(aVal.mValue, false); - } - return CheckedInt(-aVal.mValue, true); - } -}; - -} // namespace detail - - -/* - * Step 3: Now define the CheckedInt class. - */ - -/** - * @class CheckedInt - * @brief Integer wrapper class checking for integer overflow and other errors - * @param T the integer type to wrap. Can be any type among the following: - * - any basic integer type such as |int| - * - any stdint type such as |int8_t| - * - * This class implements guarded integer arithmetic. Do a computation, check - * that isValid() returns true, you then have a guarantee that no problem, such - * as integer overflow, happened during this computation, and you can call - * value() to get the plain integer value. - * - * The arithmetic operators in this class are guaranteed not to raise a signal - * (e.g. in case of a division by zero). - * - * For example, suppose that you want to implement a function that computes - * (aX+aY)/aZ, that doesn't crash if aZ==0, and that reports on error (divide by - * zero or integer overflow). You could code it as follows: - @code - bool computeXPlusYOverZ(int aX, int aY, int aZ, int* aResult) - { - CheckedInt checkedResult = (CheckedInt(aX) + aY) / aZ; - if (checkedResult.isValid()) { - *aResult = checkedResult.value(); - return true; - } else { - return false; - } - } - @endcode - * - * Implicit conversion from plain integers to checked integers is allowed. The - * plain integer is checked to be in range before being casted to the - * destination type. This means that the following lines all compile, and the - * resulting CheckedInts are correctly detected as valid or invalid: - * @code - // 1 is of type int, is found to be in range for uint8_t, x is valid - CheckedInt x(1); - // -1 is of type int, is found not to be in range for uint8_t, x is invalid - CheckedInt x(-1); - // -1 is of type int, is found to be in range for int8_t, x is valid - CheckedInt x(-1); - // 1000 is of type int16_t, is found not to be in range for int8_t, - // x is invalid - CheckedInt x(int16_t(1000)); - // 3123456789 is of type uint32_t, is found not to be in range for int32_t, - // x is invalid - CheckedInt x(uint32_t(3123456789)); - * @endcode - * Implicit conversion from - * checked integers to plain integers is not allowed. As shown in the - * above example, to get the value of a checked integer as a normal integer, - * call value(). - * - * Arithmetic operations between checked and plain integers is allowed; the - * result type is the type of the checked integer. - * - * Checked integers of different types cannot be used in the same arithmetic - * expression. - * - * There are convenience typedefs for all stdint types, of the following form - * (these are just 2 examples): - @code - typedef CheckedInt CheckedInt32; - typedef CheckedInt CheckedUint16; - @endcode - */ -template -class CheckedInt -{ -protected: - T mValue; - bool mIsValid; - - template - CheckedInt(U aValue, bool aIsValid) : mValue(aValue), mIsValid(aIsValid) - { - static_assert(detail::IsSupported::value && - detail::IsSupported::value, - "This type is not supported by CheckedInt"); - } - - friend struct detail::NegateImpl; - -public: - /** - * Constructs a checked integer with given @a value. The checked integer is - * initialized as valid or invalid depending on whether the @a value - * is in range. - * - * This constructor is not explicit. Instead, the type of its argument is a - * separate template parameter, ensuring that no conversion is performed - * before this constructor is actually called. As explained in the above - * documentation for class CheckedInt, this constructor checks that its - * argument is valid. - */ - template - MOZ_IMPLICIT constexpr CheckedInt(U aValue) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT - : mValue(T(aValue)), - mIsValid(detail::IsInRange(aValue)) - { - static_assert(detail::IsSupported::value && - detail::IsSupported::value, - "This type is not supported by CheckedInt"); - } - - template - friend class CheckedInt; - - template - CheckedInt toChecked() const - { - CheckedInt ret(mValue); - ret.mIsValid = ret.mIsValid && mIsValid; - return ret; - } - - /** Constructs a valid checked integer with initial value 0 */ - constexpr CheckedInt() : mValue(0), mIsValid(true) - { - static_assert(detail::IsSupported::value, - "This type is not supported by CheckedInt"); - } - - /** @returns the actual value */ - T value() const - { - MOZ_ASSERT(mIsValid, "Invalid checked integer (division by zero or integer overflow)"); - return mValue; - } - - /** - * @returns true if the checked integer is valid, i.e. is not the result - * of an invalid operation or of an operation involving an invalid checked - * integer - */ - bool isValid() const - { - return mIsValid; - } - - template - friend CheckedInt operator +(const CheckedInt& aLhs, - const CheckedInt& aRhs); - template - CheckedInt& operator +=(U aRhs); - CheckedInt& operator +=(const CheckedInt& aRhs); - - template - friend CheckedInt operator -(const CheckedInt& aLhs, - const CheckedInt& aRhs); - template - CheckedInt& operator -=(U aRhs); - CheckedInt& operator -=(const CheckedInt& aRhs); - - template - friend CheckedInt operator *(const CheckedInt& aLhs, - const CheckedInt& aRhs); - template - CheckedInt& operator *=(U aRhs); - CheckedInt& operator *=(const CheckedInt& aRhs); - - template - friend CheckedInt operator /(const CheckedInt& aLhs, - const CheckedInt& aRhs); - template - CheckedInt& operator /=(U aRhs); - CheckedInt& operator /=(const CheckedInt& aRhs); - - template - friend CheckedInt operator %(const CheckedInt& aLhs, - const CheckedInt& aRhs); - template - CheckedInt& operator %=(U aRhs); - CheckedInt& operator %=(const CheckedInt& aRhs); - - CheckedInt operator -() const - { - return detail::NegateImpl::negate(*this); - } - - /** - * @returns true if the left and right hand sides are valid - * and have the same value. - * - * Note that these semantics are the reason why we don't offer - * a operator!=. Indeed, we'd want to have a!=b be equivalent to !(a==b) - * but that would mean that whenever a or b is invalid, a!=b - * is always true, which would be very confusing. - * - * For similar reasons, operators <, >, <=, >= would be very tricky to - * specify, so we just avoid offering them. - * - * Notice that these == semantics are made more reasonable by these facts: - * 1. a==b implies equality at the raw data level - * (the converse is false, as a==b is never true among invalids) - * 2. This is similar to the behavior of IEEE floats, where a==b - * means that a and b have the same value *and* neither is NaN. - */ - bool operator ==(const CheckedInt& aOther) const - { - return mIsValid && aOther.mIsValid && mValue == aOther.mValue; - } - - /** prefix ++ */ - CheckedInt& operator++() - { - *this += 1; - return *this; - } - - /** postfix ++ */ - CheckedInt operator++(int) - { - CheckedInt tmp = *this; - *this += 1; - return tmp; - } - - /** prefix -- */ - CheckedInt& operator--() - { - *this -= 1; - return *this; - } - - /** postfix -- */ - CheckedInt operator--(int) - { - CheckedInt tmp = *this; - *this -= 1; - return tmp; - } - -private: - /** - * The !=, <, <=, >, >= operators are disabled: - * see the comment on operator==. - */ - template bool operator !=(U aOther) const = delete; - template bool operator < (U aOther) const = delete; - template bool operator <=(U aOther) const = delete; - template bool operator > (U aOther) const = delete; - template bool operator >=(U aOther) const = delete; -}; - -#define MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(NAME, OP) \ - template \ - inline CheckedInt \ - operator OP(const CheckedInt& aLhs, const CheckedInt& aRhs) \ - { \ - if (!detail::Is##NAME##Valid(aLhs.mValue, aRhs.mValue)) { \ - return CheckedInt(0, false); \ - } \ - return CheckedInt(aLhs.mValue OP aRhs.mValue, \ - aLhs.mIsValid && aRhs.mIsValid); \ - } - -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Add, +) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Sub, -) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mul, *) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Div, /) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %) - -#undef MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR - -// Implement castToCheckedInt(x), making sure that -// - it allows x to be either a CheckedInt or any integer type -// that can be casted to T -// - if x is already a CheckedInt, we just return a reference to it, -// instead of copying it (optimization) - -namespace detail { - -template -struct CastToCheckedIntImpl -{ - typedef CheckedInt ReturnType; - static CheckedInt run(U aU) { return aU; } -}; - -template -struct CastToCheckedIntImpl > -{ - typedef const CheckedInt& ReturnType; - static const CheckedInt& run(const CheckedInt& aU) { return aU; } -}; - -} // namespace detail - -template -inline typename detail::CastToCheckedIntImpl::ReturnType -castToCheckedInt(U aU) -{ - static_assert(detail::IsSupported::value && - detail::IsSupported::value, - "This type is not supported by CheckedInt"); - return detail::CastToCheckedIntImpl::run(aU); -} - -#define MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(OP, COMPOUND_OP) \ - template \ - template \ - CheckedInt& CheckedInt::operator COMPOUND_OP(U aRhs) \ - { \ - *this = *this OP castToCheckedInt(aRhs); \ - return *this; \ - } \ - template \ - CheckedInt& CheckedInt::operator COMPOUND_OP(const CheckedInt& aRhs) \ - { \ - *this = *this OP aRhs; \ - return *this; \ - } \ - template \ - inline CheckedInt operator OP(const CheckedInt& aLhs, U aRhs) \ - { \ - return aLhs OP castToCheckedInt(aRhs); \ - } \ - template \ - inline CheckedInt operator OP(U aLhs, const CheckedInt& aRhs) \ - { \ - return castToCheckedInt(aLhs) OP aRhs; \ - } - -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(+, +=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(*, *=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(-, -=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(/, /=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(%, %=) - -#undef MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS - -template -inline bool -operator ==(const CheckedInt& aLhs, U aRhs) -{ - return aLhs == castToCheckedInt(aRhs); -} - -template -inline bool -operator ==(U aLhs, const CheckedInt& aRhs) -{ - return castToCheckedInt(aLhs) == aRhs; -} - -// Convenience typedefs. -typedef CheckedInt CheckedInt8; -typedef CheckedInt CheckedUint8; -typedef CheckedInt CheckedInt16; -typedef CheckedInt CheckedUint16; -typedef CheckedInt CheckedInt32; -typedef CheckedInt CheckedUint32; -typedef CheckedInt CheckedInt64; -typedef CheckedInt CheckedUint64; - -} // namespace mozilla - -#endif /* mozilla_CheckedInt_h */ diff --git a/sources/firefox/mozilla/Compiler.h b/sources/firefox/mozilla/Compiler.h deleted file mode 100644 index 687202f5..00000000 --- a/sources/firefox/mozilla/Compiler.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Various compiler checks. */ - -#ifndef mozilla_Compiler_h -#define mozilla_Compiler_h - -#define MOZ_IS_GCC 0 -#define MOZ_IS_MSVC 0 - -#if !defined(__clang__) && defined(__GNUC__) - -# undef MOZ_IS_GCC -# define MOZ_IS_GCC 1 - /* - * These macros should simplify gcc version checking. For example, to check - * for gcc 4.7.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 7, 1)`. - */ -# define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel) \ - ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ - >= ((major) * 10000 + (minor) * 100 + (patchlevel))) -# define MOZ_GCC_VERSION_AT_MOST(major, minor, patchlevel) \ - ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ - <= ((major) * 10000 + (minor) * 100 + (patchlevel))) -# if !MOZ_GCC_VERSION_AT_LEAST(4, 9, 0) -# error "mfbt (and Gecko) require at least gcc 4.9 to build." -# endif - -#elif defined(_MSC_VER) - -# undef MOZ_IS_MSVC -# define MOZ_IS_MSVC 1 - -#endif - -/* - * The situation with standard libraries is a lot worse than with compilers, - * particularly as clang and gcc could end up using one of three or so standard - * libraries, and they may not be up-to-snuff with newer C++11 versions. To - * detect the library, we're going to include cstddef (which is a small header - * which will be transitively included by everybody else at some point) to grab - * the version macros and deduce macros from there. - */ -#ifdef __cplusplus -# include -# ifdef _STLPORT_MAJOR -# define MOZ_USING_STLPORT 1 -# define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) \ - (_STLPORT_VERSION >= ((major) << 8 | (minor) << 4 | (patch))) -# elif defined(_LIBCPP_VERSION) - /* - * libc++, unfortunately, doesn't appear to have useful versioning macros. - * Hopefully, the recommendations of N3694 with respect to standard libraries - * will get applied instead and we won't need to worry about version numbers - * here. - */ -# define MOZ_USING_LIBCXX 1 -# elif defined(__GLIBCXX__) -# define MOZ_USING_LIBSTDCXX 1 - /* - * libstdc++ is also annoying and doesn't give us useful versioning macros - * for the library. If we're using gcc, then assume that libstdc++ matches - * the compiler version. If we're using clang, we're going to have to fake - * major/minor combinations by looking for newly-defined config macros. - */ -# if MOZ_IS_GCC -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - MOZ_GCC_VERSION_AT_LEAST(major, minor, patch) -# elif defined(_GLIBCXX_THROW_OR_ABORT) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 8)) -# elif defined(_GLIBCXX_NOEXCEPT) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 7)) -# elif defined(_GLIBCXX_USE_DEPRECATED) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 6)) -# elif defined(_GLIBCXX_PSEUDO_VISIBILITY) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 5)) -# elif defined(_GLIBCXX_BEGIN_EXTERN_C) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 4)) -# elif defined(_GLIBCXX_VISIBILITY_ATTR) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 3)) -# elif defined(_GLIBCXX_VISIBILITY) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 2)) -# else -# error "Your version of libstdc++ is unknown to us and is likely too old." -# endif -# endif - - // Flesh out the defines for everyone else -# ifndef MOZ_USING_STLPORT -# define MOZ_USING_STLPORT 0 -# define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) 0 -# endif -# ifndef MOZ_USING_LIBCXX -# define MOZ_USING_LIBCXX 0 -# endif -# ifndef MOZ_USING_LIBSTDCXX -# define MOZ_USING_LIBSTDCXX 0 -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) 0 -# endif -#endif /* __cplusplus */ - -#endif /* mozilla_Compiler_h */ diff --git a/sources/firefox/mozilla/IntegerTypeTraits.h b/sources/firefox/mozilla/IntegerTypeTraits.h deleted file mode 100644 index 6144d208..00000000 --- a/sources/firefox/mozilla/IntegerTypeTraits.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Helpers to manipulate integer types that don't fit in TypeTraits.h */ - -#ifndef mozilla_IntegerTypeTraits_h -#define mozilla_IntegerTypeTraits_h - -#include "mozilla/TypeTraits.h" -#include - -namespace mozilla { - -namespace detail { - -/** - * StdintTypeForSizeAndSignedness returns the stdint integer type - * of given size (can be 1, 2, 4 or 8) and given signedness - * (false means unsigned, true means signed). - */ -template -struct StdintTypeForSizeAndSignedness; - -template<> -struct StdintTypeForSizeAndSignedness<1, true> -{ - typedef int8_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<1, false> -{ - typedef uint8_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<2, true> -{ - typedef int16_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<2, false> -{ - typedef uint16_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<4, true> -{ - typedef int32_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<4, false> -{ - typedef uint32_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<8, true> -{ - typedef int64_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<8, false> -{ - typedef uint64_t Type; -}; - -} // namespace detail - -template -struct UnsignedStdintTypeForSize - : detail::StdintTypeForSizeAndSignedness -{}; - -template -struct SignedStdintTypeForSize - : detail::StdintTypeForSizeAndSignedness -{}; - -template -struct PositionOfSignBit -{ - static_assert(IsIntegral::value, - "PositionOfSignBit is only for integral types"); - // 8 here should be CHAR_BIT from limits.h, but the world has moved on. - static const size_t value = 8 * sizeof(IntegerType) - 1; -}; - -/** - * MinValue returns the minimum value of the given integer type as a - * compile-time constant, which std::numeric_limits::min() - * cannot do in c++98. - */ -template -struct MinValue -{ -private: - static_assert(IsIntegral::value, - "MinValue is only for integral types"); - - typedef typename MakeUnsigned::Type UnsignedIntegerType; - static const size_t PosOfSignBit = PositionOfSignBit::value; - -public: - // Bitwise ops may return a larger type, that's why we cast explicitly. - // In C++, left bit shifts on signed values is undefined by the standard - // unless the shifted value is representable. - // Notice that signed-to-unsigned conversions are always well-defined in - // the standard as the value congruent to 2**n, as expected. By contrast, - // unsigned-to-signed is only well-defined if the value is representable. - static const IntegerType value = - IsSigned::value - ? IntegerType(UnsignedIntegerType(1) << PosOfSignBit) - : IntegerType(0); -}; - -/** - * MaxValue returns the maximum value of the given integer type as a - * compile-time constant, which std::numeric_limits::max() - * cannot do in c++98. - */ -template -struct MaxValue -{ - static_assert(IsIntegral::value, - "MaxValue is only for integral types"); - - // Tricksy, but covered by the CheckedInt unit test. - // Relies on the type of MinValue::value - // being IntegerType. - static const IntegerType value = ~MinValue::value; -}; - -} // namespace mozilla - -#endif // mozilla_IntegerTypeTraits_h diff --git a/sources/firefox/mozilla/Likely.h b/sources/firefox/mozilla/Likely.h deleted file mode 100644 index 4f216092..00000000 --- a/sources/firefox/mozilla/Likely.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a - * boolean predicate should be branch-predicted. - */ - -#ifndef mozilla_Likely_h -#define mozilla_Likely_h - -#if defined(__clang__) || defined(__GNUC__) -# define MOZ_LIKELY(x) (__builtin_expect(!!(x), 1)) -# define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0)) -#else -# define MOZ_LIKELY(x) (!!(x)) -# define MOZ_UNLIKELY(x) (!!(x)) -#endif - -#endif /* mozilla_Likely_h */ diff --git a/sources/firefox/mozilla/MacroArgs.h b/sources/firefox/mozilla/MacroArgs.h deleted file mode 100644 index 7f55cc7f..00000000 --- a/sources/firefox/mozilla/MacroArgs.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements various macros meant to ease the use of variadic macros. - */ - -#ifndef mozilla_MacroArgs_h -#define mozilla_MacroArgs_h - -// Concatenates pre-processor tokens in a way that can be used with __LINE__. -#define MOZ_CONCAT2(x, y) x ## y -#define MOZ_CONCAT(x, y) MOZ_CONCAT2(x, y) - -/* - * MOZ_ARG_COUNT(...) counts the number of variadic arguments. - * You must pass in between 0 and 50 (inclusive) variadic arguments. - * For example: - * - * MOZ_ARG_COUNT() expands to 0 - * MOZ_ARG_COUNT(a) expands to 1 - * MOZ_ARG_COUNT(a, b) expands to 2 - * - * Implementation notes: - * The `##__VA_ARGS__` form is a GCC extension that removes the comma if - * __VA_ARGS__ is empty. It is supported by Clang too. MSVC ignores ##, - * and its default behavior is already to strip the comma when __VA_ARGS__ - * is empty. - * - * So MOZ_MACROARGS_ARG_COUNT_HELPER() expands to - * (_, 50, 49, ...) - * MOZ_MACROARGS_ARG_COUNT_HELPER(a) expands to - * (_, a, 50, 49, ...) - * etc. - */ -#define MOZ_ARG_COUNT(...) \ - MOZ_MACROARGS_ARG_COUNT_HELPER2(MOZ_MACROARGS_ARG_COUNT_HELPER(__VA_ARGS__)) - -#define MOZ_MACROARGS_ARG_COUNT_HELPER(...) (_, ##__VA_ARGS__, \ - 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, \ - 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, \ - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, \ - 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, \ - 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) - -#define MOZ_MACROARGS_ARG_COUNT_HELPER2(aArgs) \ - MOZ_MACROARGS_ARG_COUNT_HELPER3 aArgs - -#define MOZ_MACROARGS_ARG_COUNT_HELPER3(a0, \ - a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, \ - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, \ - a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, \ - a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, \ - a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, \ - a51, ...) a51 - -/* - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) counts the number of variadic - * arguments and prefixes it with |aPrefix|. For example: - * - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(, foo, 42) expands to 2 - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(A, foo, 42, bar) expands to A3 - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(A) expands to A0 - * MOZ_PASTE_PREFIX_AND_ARG_COUNT() expands to 0, but MSVC warns there - * aren't enough arguments given. - * - * You must pass in between 0 and 50 (inclusive) variadic arguments, past - * |aPrefix|. - */ -#define MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE(a, b) a b -#define MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) \ - MOZ_PASTE_PREFIX_AND_ARG_COUNT_GLUE( \ - MOZ_CONCAT, (aPrefix, MOZ_ARG_COUNT(__VA_ARGS__))) - -/* - * MOZ_ARGS_AFTER_N expands to its arguments excluding the first |N| - * arguments. For example: - * - * MOZ_ARGS_AFTER_2(a, b, c, d) expands to: c, d - */ -#define MOZ_ARGS_AFTER_1(a1, ...) __VA_ARGS__ -#define MOZ_ARGS_AFTER_2(a1, a2, ...) __VA_ARGS__ - -/* - * MOZ_ARG_N expands to its |N|th argument. - */ -#define MOZ_ARG_1(a1, ...) a1 -#define MOZ_ARG_2(a1, a2, ...) a2 - -#endif /* mozilla_MacroArgs_h */ diff --git a/sources/firefox/mozilla/Move.h b/sources/firefox/mozilla/Move.h deleted file mode 100644 index f6d0bfc1..00000000 --- a/sources/firefox/mozilla/Move.h +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* C++11-style, but C++98-usable, "move references" implementation. */ - -#ifndef mozilla_Move_h -#define mozilla_Move_h - -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -/* - * "Move" References - * - * Some types can be copied much more efficiently if we know the original's - * value need not be preserved --- that is, if we are doing a "move", not a - * "copy". For example, if we have: - * - * Vector u; - * Vector v(u); - * - * the constructor for v must apply a copy constructor to each element of u --- - * taking time linear in the length of u. However, if we know we will not need u - * any more once v has been initialized, then we could initialize v very - * efficiently simply by stealing u's dynamically allocated buffer and giving it - * to v --- a constant-time operation, regardless of the size of u. - * - * Moves often appear in container implementations. For example, when we append - * to a vector, we may need to resize its buffer. This entails moving each of - * its extant elements from the old, smaller buffer to the new, larger buffer. - * But once the elements have been migrated, we're just going to throw away the - * old buffer; we don't care if they still have their values. So if the vector's - * element type can implement "move" more efficiently than "copy", the vector - * resizing should by all means use a "move" operation. Hash tables should also - * use moves when resizing their internal array as entries are added and - * removed. - * - * The details of the optimization, and whether it's worth applying, vary - * from one type to the next: copying an 'int' is as cheap as moving it, so - * there's no benefit in distinguishing 'int' moves from copies. And while - * some constructor calls for complex types are moves, many really have to - * be copies, and can't be optimized this way. So we need: - * - * 1) a way for a type (like Vector) to announce that it can be moved more - * efficiently than it can be copied, and provide an implementation of that - * move operation; and - * - * 2) a way for a particular invocation of a copy constructor to say that it's - * really a move, not a copy, and that the value of the original isn't - * important afterwards (although it must still be safe to destroy). - * - * If a constructor has a single argument of type 'T&&' (an 'rvalue reference - * to T'), that indicates that it is a 'move constructor'. That's 1). It should - * move, not copy, its argument into the object being constructed. It may leave - * the original in any safely-destructible state. - * - * If a constructor's argument is an rvalue, as in 'C(f(x))' or 'C(x + y)', as - * opposed to an lvalue, as in 'C(x)', then overload resolution will prefer the - * move constructor, if there is one. The 'mozilla::Move' function, defined in - * this file, is an identity function you can use in a constructor invocation to - * make any argument into an rvalue, like this: C(Move(x)). That's 2). (You - * could use any function that works, but 'Move' indicates your intention - * clearly.) - * - * Where we might define a copy constructor for a class C like this: - * - * C(const C& rhs) { ... copy rhs to this ... } - * - * we would declare a move constructor like this: - * - * C(C&& rhs) { .. move rhs to this ... } - * - * And where we might perform a copy like this: - * - * C c2(c1); - * - * we would perform a move like this: - * - * C c2(Move(c1)); - * - * Note that 'T&&' implicitly converts to 'T&'. So you can pass a 'T&&' to an - * ordinary copy constructor for a type that doesn't support a special move - * constructor, and you'll just get a copy. This means that templates can use - * Move whenever they know they won't use the original value any more, even if - * they're not sure whether the type at hand has a specialized move constructor. - * If it doesn't, the 'T&&' will just convert to a 'T&', and the ordinary copy - * constructor will apply. - * - * A class with a move constructor can also provide a move assignment operator. - * A generic definition would run this's destructor, and then apply the move - * constructor to *this's memory. A typical definition: - * - * C& operator=(C&& rhs) { - * MOZ_ASSERT(&rhs != this, "self-moves are prohibited"); - * this->~C(); - * new(this) C(Move(rhs)); - * return *this; - * } - * - * With that in place, one can write move assignments like this: - * - * c2 = Move(c1); - * - * This destroys c2, moves c1's value to c2, and leaves c1 in an undefined but - * destructible state. - * - * As we say, a move must leave the original in a "destructible" state. The - * original's destructor will still be called, so if a move doesn't - * actually steal all its resources, that's fine. We require only that the - * move destination must take on the original's value; and that destructing - * the original must not break the move destination. - * - * (Opinions differ on whether move assignment operators should deal with move - * assignment of an object onto itself. It seems wise to either handle that - * case, or assert that it does not occur.) - * - * Forwarding: - * - * Sometimes we want copy construction or assignment if we're passed an ordinary - * value, but move construction if passed an rvalue reference. For example, if - * our constructor takes two arguments and either could usefully be a move, it - * seems silly to write out all four combinations: - * - * C::C(X& x, Y& y) : x(x), y(y) { } - * C::C(X& x, Y&& y) : x(x), y(Move(y)) { } - * C::C(X&& x, Y& y) : x(Move(x)), y(y) { } - * C::C(X&& x, Y&& y) : x(Move(x)), y(Move(y)) { } - * - * To avoid this, C++11 has tweaks to make it possible to write what you mean. - * The four constructor overloads above can be written as one constructor - * template like so[0]: - * - * template - * C::C(XArg&& x, YArg&& y) : x(Forward(x)), y(Forward(y)) { } - * - * ("'Don't Repeat Yourself'? What's that?") - * - * This takes advantage of two new rules in C++11: - * - * - First, when a function template takes an argument that is an rvalue - * reference to a template argument (like 'XArg&& x' and 'YArg&& y' above), - * then when the argument is applied to an lvalue, the template argument - * resolves to 'T&'; and when it is applied to an rvalue, the template - * argument resolves to 'T'. Thus, in a call to C::C like: - * - * X foo(int); - * Y yy; - * - * C(foo(5), yy) - * - * XArg would resolve to 'X', and YArg would resolve to 'Y&'. - * - * - Second, Whereas C++ used to forbid references to references, C++11 defines - * 'collapsing rules': 'T& &', 'T&& &', and 'T& &&' (that is, any combination - * involving an lvalue reference) now collapse to simply 'T&'; and 'T&& &&' - * collapses to 'T&&'. - * - * Thus, in the call above, 'XArg&&' is 'X&&'; and 'YArg&&' is 'Y& &&', which - * collapses to 'Y&'. Because the arguments are declared as rvalue references - * to template arguments, the lvalue-ness "shines through" where present. - * - * Then, the 'Forward' function --- you must invoke 'Forward' with its type - * argument --- returns an lvalue reference or an rvalue reference to its - * argument, depending on what T is. In our unified constructor definition, that - * means that we'll invoke either the copy or move constructors for x and y, - * depending on what we gave C's constructor. In our call, we'll move 'foo()' - * into 'x', but copy 'yy' into 'y'. - * - * This header file defines Move and Forward in the mozilla namespace. It's up - * to individual containers to annotate moves as such, by calling Move; and it's - * up to individual types to define move constructors and assignment operators - * when valuable. - * - * (C++11 says that the header file should define 'std::move' and - * 'std::forward', which are just like our 'Move' and 'Forward'; but those - * definitions aren't available in that header on all our platforms, so we - * define them ourselves here.) - * - * 0. This pattern is known as "perfect forwarding". Interestingly, it is not - * actually perfect, and it can't forward all possible argument expressions! - * There is a C++11 issue: you can't form a reference to a bit-field. As a - * workaround, assign the bit-field to a local variable and use that: - * - * // C is as above - * struct S { int x : 1; } s; - * C(s.x, 0); // BAD: s.x is a reference to a bit-field, can't form those - * int tmp = s.x; - * C(tmp, 0); // OK: tmp not a bit-field - */ - -/** - * Identical to std::Move(); this is necessary until our stlport supports - * std::move(). - */ -template -inline typename RemoveReference::Type&& -Move(T&& aX) -{ - return static_cast::Type&&>(aX); -} - -/** - * These two overloads are identical to std::forward(); they are necessary until - * our stlport supports std::forward(). - */ -template -inline T&& -Forward(typename RemoveReference::Type& aX) -{ - return static_cast(aX); -} - -template -inline T&& -Forward(typename RemoveReference::Type&& aX) -{ - static_assert(!IsLvalueReference::value, - "misuse of Forward detected! try the other overload"); - return static_cast(aX); -} - -/** Swap |aX| and |aY| using move-construction if possible. */ -template -inline void -Swap(T& aX, T& aY) -{ - T tmp(Move(aX)); - aX = Move(aY); - aY = Move(tmp); -} - -} // namespace mozilla - -#endif /* mozilla_Move_h */ diff --git a/sources/firefox/mozilla/Pair.h b/sources/firefox/mozilla/Pair.h deleted file mode 100644 index ad7b86a2..00000000 --- a/sources/firefox/mozilla/Pair.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A class holding a pair of objects that tries to conserve storage space. */ - -#ifndef mozilla_Pair_h -#define mozilla_Pair_h - -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -namespace detail { - -enum StorageType { AsBase, AsMember }; - -// Optimize storage using the Empty Base Optimization -- that empty base classes -// don't take up space -- to optimize size when one or the other class is -// stateless and can be used as a base class. -// -// The extra conditions on storage for B are necessary so that PairHelper won't -// ambiguously inherit from either A or B, such that one or the other base class -// would be inaccessible. -template::value ? detail::AsBase : detail::AsMember, - detail::StorageType = - IsEmpty::value && !IsBaseOf::value && !IsBaseOf::value - ? detail::AsBase - : detail::AsMember> -struct PairHelper; - -template -struct PairHelper -{ -protected: - template - PairHelper(AArg&& aA, BArg&& aB) - : mFirstA(Forward(aA)), - mSecondB(Forward(aB)) - {} - - A& first() { return mFirstA; } - const A& first() const { return mFirstA; } - B& second() { return mSecondB; } - const B& second() const { return mSecondB; } - - void swap(PairHelper& aOther) - { - Swap(mFirstA, aOther.mFirstA); - Swap(mSecondB, aOther.mSecondB); - } - -private: - A mFirstA; - B mSecondB; -}; - -template -struct PairHelper : private B -{ -protected: - template - PairHelper(AArg&& aA, BArg&& aB) - : B(Forward(aB)), - mFirstA(Forward(aA)) - {} - - A& first() { return mFirstA; } - const A& first() const { return mFirstA; } - B& second() { return *this; } - const B& second() const { return *this; } - - void swap(PairHelper& aOther) - { - Swap(mFirstA, aOther.mFirstA); - Swap(static_cast(*this), static_cast(aOther)); - } - -private: - A mFirstA; -}; - -template -struct PairHelper : private A -{ -protected: - template - PairHelper(AArg&& aA, BArg&& aB) - : A(Forward(aA)), - mSecondB(Forward(aB)) - {} - - A& first() { return *this; } - const A& first() const { return *this; } - B& second() { return mSecondB; } - const B& second() const { return mSecondB; } - - void swap(PairHelper& aOther) - { - Swap(static_cast(*this), static_cast(aOther)); - Swap(mSecondB, aOther.mSecondB); - } - -private: - B mSecondB; -}; - -template -struct PairHelper : private A, private B -{ -protected: - template - PairHelper(AArg&& aA, BArg&& aB) - : A(Forward(aA)), - B(Forward(aB)) - {} - - A& first() { return static_cast(*this); } - const A& first() const { return static_cast(*this); } - B& second() { return static_cast(*this); } - const B& second() const { return static_cast(*this); } - - void swap(PairHelper& aOther) - { - Swap(static_cast(*this), static_cast(aOther)); - Swap(static_cast(*this), static_cast(aOther)); - } -}; - -} // namespace detail - -/** - * Pair is the logical concatenation of an instance of A with an instance B. - * Space is conserved when possible. Neither A nor B may be a final class. - * - * It's typically clearer to have individual A and B member fields. Except if - * you want the space-conserving qualities of Pair, you're probably better off - * not using this! - * - * No guarantees are provided about the memory layout of A and B, the order of - * initialization or destruction of A and B, and so on. (This is approximately - * required to optimize space usage.) The first/second names are merely - * conceptual! - */ -template -struct Pair - : private detail::PairHelper -{ - typedef typename detail::PairHelper Base; - -public: - template - Pair(AArg&& aA, BArg&& aB) - : Base(Forward(aA), Forward(aB)) - {} - - Pair(Pair&& aOther) - : Base(Move(aOther.first()), Move(aOther.second())) - { } - - Pair(const Pair& aOther) = default; - - Pair& operator=(Pair&& aOther) - { - MOZ_ASSERT(this != &aOther, "Self-moves are prohibited"); - - first() = Move(aOther.first()); - second() = Move(aOther.second()); - - return *this; - } - - Pair& operator=(const Pair& aOther) = default; - - /** The A instance. */ - using Base::first; - /** The B instance. */ - using Base::second; - - /** Swap this pair with another pair. */ - void swap(Pair& aOther) { Base::swap(aOther); } -}; - -template -void -Swap(Pair& aX, Pair& aY) -{ - aX.swap(aY); -} - -/** - * MakePair allows you to construct a Pair instance using type inference. A call - * like this: - * - * MakePair(Foo(), Bar()) - * - * will return a Pair. - */ -template -Pair::Type>::Type, - typename RemoveCV::Type>::Type> -MakePair(A&& aA, B&& aB) -{ - return - Pair::Type>::Type, - typename RemoveCV::Type>::Type>( - Forward(aA), - Forward(aB)); -} - -} // namespace mozilla - -#endif /* mozilla_Pair_h */ diff --git a/sources/firefox/mozilla/StaticAnalysisFunctions.h b/sources/firefox/mozilla/StaticAnalysisFunctions.h deleted file mode 100644 index ac0c09a4..00000000 --- a/sources/firefox/mozilla/StaticAnalysisFunctions.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_StaticAnalysisFunctions_h -#define mozilla_StaticAnalysisFunctions_h - -#ifndef __cplusplus -#ifndef bool -#include -#endif -#endif -/* - * Functions that are used as markers in Gecko code for static analysis. Their - * purpose is to have different AST nodes generated during compile time and to - * match them based on different checkers implemented in build/clang-plugin - */ - -#ifdef MOZ_CLANG_PLUGIN - -#ifdef __cplusplus -/** - * MOZ_KnownLive - used to opt an argument out of the CanRunScript checker so - * that we don't check it if is a strong ref. - * - * Example: - * canRunScript(MOZ_KnownLive(rawPointer)); - */ -template -static MOZ_ALWAYS_INLINE T* MOZ_KnownLive(T* ptr) { return ptr; } - -extern "C" { -#endif - -/** - * MOZ_AssertAssignmentTest - used in MOZ_ASSERT in order to test the possible - * presence of assignment instead of logical comparisons. - * - * Example: - * MOZ_ASSERT(retVal = true); - */ -static MOZ_ALWAYS_INLINE bool MOZ_AssertAssignmentTest(bool exprResult) { - return exprResult; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) MOZ_AssertAssignmentTest(!!(expr)) - -#else - -#define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) (!!(expr)) - -#endif /* MOZ_CLANG_PLUGIN */ -#endif /* StaticAnalysisFunctions_h */ \ No newline at end of file diff --git a/sources/firefox/mozilla/TypeTraits.h b/sources/firefox/mozilla/TypeTraits.h deleted file mode 100644 index e566a7ce..00000000 --- a/sources/firefox/mozilla/TypeTraits.h +++ /dev/null @@ -1,1314 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Template-based metaprogramming and type-testing facilities. */ - -#ifndef mozilla_TypeTraits_h -#define mozilla_TypeTraits_h - -#include "mozilla/Types.h" - -/* - * These traits are approximate copies of the traits and semantics from C++11's - * header. Don't add traits not in that header! When all - * platforms provide that header, we can convert all users and remove this one. - */ - -#include - -namespace mozilla { - -/* Forward declarations. */ - -template struct RemoveCV; -template struct AddRvalueReference; - -/* 20.2.4 Function template declval [declval] */ - -/** - * DeclVal simplifies the definition of expressions which occur as unevaluated - * operands. It converts T to a reference type, making it possible to use in - * decltype expressions even if T does not have a default constructor, e.g.: - * decltype(DeclVal().foo()) - */ -template -typename AddRvalueReference::Type DeclVal(); - -/* 20.9.3 Helper classes [meta.help] */ - -/** - * Helper class used as a base for various type traits, exposed publicly - * because exposes it as well. - */ -template -struct IntegralConstant -{ - static constexpr T value = Value; - typedef T ValueType; - typedef IntegralConstant Type; -}; - -/** Convenient aliases. */ -typedef IntegralConstant TrueType; -typedef IntegralConstant FalseType; - -/* 20.9.4 Unary type traits [meta.unary] */ - -/* 20.9.4.1 Primary type categories [meta.unary.cat] */ - -namespace detail { - -template -struct IsVoidHelper : FalseType {}; - -template<> -struct IsVoidHelper : TrueType {}; - -} // namespace detail - -/** - * IsVoid determines whether a type is void. - * - * mozilla::IsVoid::value is false; - * mozilla::IsVoid::value is true; - * mozilla::IsVoid::value is false; - * mozilla::IsVoid::value is true. - */ -template -struct IsVoid : detail::IsVoidHelper::Type> {}; - -namespace detail { - -template -struct IsIntegralHelper : FalseType {}; - -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; -template<> struct IsIntegralHelper : TrueType {}; - -} /* namespace detail */ - -/** - * IsIntegral determines whether a type is an integral type. - * - * mozilla::IsIntegral::value is true; - * mozilla::IsIntegral::value is true; - * mozilla::IsIntegral::value is true; - * mozilla::IsIntegral::value is false; - * mozilla::IsIntegral::value is false; - */ -template -struct IsIntegral : detail::IsIntegralHelper::Type> -{}; - -template -struct IsSame; - -namespace detail { - -template -struct IsFloatingPointHelper - : IntegralConstant::value || - IsSame::value || - IsSame::value> -{}; - -} // namespace detail - -/** - * IsFloatingPoint determines whether a type is a floating point type (float, - * double, long double). - * - * mozilla::IsFloatingPoint::value is false; - * mozilla::IsFloatingPoint::value is true; - * mozilla::IsFloatingPoint::value is true; - * mozilla::IsFloatingPoint::value is false. - */ -template -struct IsFloatingPoint - : detail::IsFloatingPointHelper::Type> -{}; - -namespace detail { - -template -struct IsArrayHelper : FalseType {}; - -template -struct IsArrayHelper : TrueType {}; - -template -struct IsArrayHelper : TrueType {}; - -} // namespace detail - -/** - * IsArray determines whether a type is an array type, of known or unknown - * length. - * - * mozilla::IsArray::value is false; - * mozilla::IsArray::value is true; - * mozilla::IsArray::value is true. - */ -template -struct IsArray : detail::IsArrayHelper::Type> -{}; - -namespace detail { - -template -struct IsFunPtr; - -template -struct IsFunPtr - : public FalseType -{}; - -template -struct IsFunPtr - : public TrueType -{}; - -}; // namespace detail - -/** - * IsFunction determines whether a type is a function type. Function pointers - * don't qualify here--only the type of an actual function symbol. We do not - * correctly handle varags function types because of a bug in MSVC. - * - * Given the function: - * void f(int) {} - * - * mozilla::IsFunction is true; - * mozilla::IsFunction is false; - * mozilla::IsFunction is true. - */ -template -struct IsFunction - : public detail::IsFunPtr::Type *> -{}; - -namespace detail { - -template -struct IsPointerHelper : FalseType {}; - -template -struct IsPointerHelper : TrueType {}; - -} // namespace detail - -/** - * IsPointer determines whether a type is a possibly-CV-qualified pointer type - * (but not a pointer-to-member type). - * - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is true; - * mozilla::IsPointer::value is false; - * mozilla::IsPointer::value is false. - * mozilla::IsPointer::value is false - */ -template -struct IsPointer : detail::IsPointerHelper::Type> -{}; - -/** - * IsLvalueReference determines whether a type is an lvalue reference. - * - * mozilla::IsLvalueReference::value is false; - * mozilla::IsLvalueReference::value is false; - * mozilla::IsLvalueReference::value is false; - * mozilla::IsLvalueReference::value is false; - * mozilla::IsLvalueReference::value is false; - * mozilla::IsLvalueReference::value is true; - * mozilla::IsLvalueReference::value is false. - */ -template -struct IsLvalueReference : FalseType {}; - -template -struct IsLvalueReference : TrueType {}; - -/** - * IsRvalueReference determines whether a type is an rvalue reference. - * - * mozilla::IsRvalueReference::value is false; - * mozilla::IsRvalueReference::value is false; - * mozilla::IsRvalueReference::value is false; - * mozilla::IsRvalueReference::value is false; - * mozilla::IsRvalueReference::value is false; - * mozilla::IsRvalueReference::value is false; - * mozilla::IsRvalueReference::value is true. - */ -template -struct IsRvalueReference : FalseType {}; - -template -struct IsRvalueReference : TrueType {}; - -namespace detail { - -// __is_enum is a supported extension across all of our supported compilers. -template -struct IsEnumHelper - : IntegralConstant -{}; - -} // namespace detail - -/** - * IsEnum determines whether a type is an enum type. - * - * mozilla::IsEnum::value is true; - * mozilla::IsEnum::value is false; - * mozilla::IsEnum::value is false; - */ -template -struct IsEnum - : detail::IsEnumHelper::Type> -{}; - -namespace detail { - -// __is_class is a supported extension across all of our supported compilers: -// http://llvm.org/releases/3.0/docs/ClangReleaseNotes.html -// http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Type-Traits.html#Type-Traits -// http://msdn.microsoft.com/en-us/library/ms177194%28v=vs.100%29.aspx -template -struct IsClassHelper - : IntegralConstant -{}; - -} // namespace detail - -/** - * IsClass determines whether a type is a class type (but not a union). - * - * struct S {}; - * union U {}; - * mozilla::IsClass::value is false; - * mozilla::IsClass::value is true; - * mozilla::IsClass::value is false; - */ -template -struct IsClass - : detail::IsClassHelper::Type> -{}; - -/* 20.9.4.2 Composite type traits [meta.unary.comp] */ - -/** - * IsReference determines whether a type is an lvalue or rvalue reference. - * - * mozilla::IsReference::value is false; - * mozilla::IsReference::value is false; - * mozilla::IsReference::value is true; - * mozilla::IsReference::value is false; - * mozilla::IsReference::value is true; - * mozilla::IsReference::value is false; - * mozilla::IsReference::value is false; - * mozilla::IsReference::value is true; - * mozilla::IsReference::value is true; - * mozilla::IsReference::value is true. - */ -template -struct IsReference - : IntegralConstant::value || IsRvalueReference::value> -{}; - -/** - * IsArithmetic determines whether a type is arithmetic. A type is arithmetic - * iff it is an integral type or a floating point type. - * - * mozilla::IsArithmetic::value is true; - * mozilla::IsArithmetic::value is true; - * mozilla::IsArithmetic::value is false. - */ -template -struct IsArithmetic - : IntegralConstant::value || IsFloatingPoint::value> -{}; - -namespace detail { - -template -struct IsMemberPointerHelper : FalseType {}; - -template -struct IsMemberPointerHelper : TrueType {}; - -} // namespace detail - -/** - * IsMemberPointer determines whether a type is pointer to non-static member - * object or a pointer to non-static member function. - * - * mozilla::IsMemberPointer::value is true - * mozilla::IsMemberPointer::value is false - */ -template -struct IsMemberPointer - : detail::IsMemberPointerHelper::Type> -{}; - -/** - * IsScalar determines whether a type is a scalar type. - * - * mozilla::IsScalar::value is true - * mozilla::IsScalar::value is true - * mozilla::IsScalar::value is false - */ -template -struct IsScalar - : IntegralConstant::value || IsEnum::value || - IsPointer::value || IsMemberPointer::value> -{}; - -/* 20.9.4.3 Type properties [meta.unary.prop] */ - -/** - * IsConst determines whether a type is const or not. - * - * mozilla::IsConst::value is false; - * mozilla::IsConst::value is true; - * mozilla::IsConst::value is false. - */ -template -struct IsConst : FalseType {}; - -template -struct IsConst : TrueType {}; - -/** - * IsVolatile determines whether a type is volatile or not. - * - * mozilla::IsVolatile::value is false; - * mozilla::IsVolatile::value is true; - * mozilla::IsVolatile::value is false. - */ -template -struct IsVolatile : FalseType {}; - -template -struct IsVolatile : TrueType {}; - -/** - * Traits class for identifying POD types. Until C++11 there's no automatic - * way to detect PODs, so for the moment this is done manually. Users may - * define specializations of this class that inherit from mozilla::TrueType and - * mozilla::FalseType (or equivalently mozilla::IntegralConstant, or conveniently from mozilla::IsPod for composite types) as needed to - * ensure correct IsPod behavior. - */ -template -struct IsPod : public FalseType {}; - -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template<> struct IsPod : TrueType {}; -template struct IsPod : TrueType {}; - -namespace detail { - -// __is_empty is a supported extension across all of our supported compilers: -// http://llvm.org/releases/3.0/docs/ClangReleaseNotes.html -// http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Type-Traits.html#Type-Traits -// http://msdn.microsoft.com/en-us/library/ms177194%28v=vs.100%29.aspx -template -struct IsEmptyHelper - : IntegralConstant::value && __is_empty(T)> -{}; - -} // namespace detail - -/** - * IsEmpty determines whether a type is a class (but not a union) that is empty. - * - * A class is empty iff it and all its base classes have no non-static data - * members (except bit-fields of length 0) and no virtual member functions, and - * no base class is empty or a virtual base class. - * - * Intuitively, empty classes don't have any data that has to be stored in - * instances of those classes. (The size of the class must still be non-zero, - * because distinct array elements of any type must have different addresses. - * However, if the Empty Base Optimization is implemented by the compiler [most - * compilers implement it, and in certain cases C++11 requires it], the size of - * a class inheriting from an empty |Base| class need not be inflated by - * |sizeof(Base)|.) And intuitively, non-empty classes have data members and/or - * vtable pointers that must be stored in each instance for proper behavior. - * - * static_assert(!mozilla::IsEmpty::value, "not a class => not empty"); - * union U1 { int x; }; - * static_assert(!mozilla::IsEmpty::value, "not a class => not empty"); - * struct E1 {}; - * struct E2 { int : 0 }; - * struct E3 : E1 {}; - * struct E4 : E2 {}; - * static_assert(mozilla::IsEmpty::value && - * mozilla::IsEmpty::value && - * mozilla::IsEmpty::value && - * mozilla::IsEmpty::value, - * "all empty"); - * union U2 { E1 e1; }; - * static_assert(!mozilla::IsEmpty::value, "not a class => not empty"); - * struct NE1 { int x; }; - * struct NE2 : virtual E1 {}; - * struct NE3 : E2 { virtual ~NE3() {} }; - * struct NE4 { virtual void f() {} }; - * static_assert(!mozilla::IsEmpty::value && - * !mozilla::IsEmpty::value && - * !mozilla::IsEmpty::value && - * !mozilla::IsEmpty::value, - * "all empty"); - */ -template -struct IsEmpty : detail::IsEmptyHelper::Type> -{}; - - -namespace detail { - -template::value, - bool = IsIntegral::value, - typename NoCV = typename RemoveCV::Type> -struct IsSignedHelper; - -// Floating point is signed. -template -struct IsSignedHelper : TrueType {}; - -// Integral is conditionally signed. -template -struct IsSignedHelper - : IntegralConstant -{}; - -// Non-floating point, non-integral is not signed. -template -struct IsSignedHelper : FalseType {}; - -} // namespace detail - -/** - * IsSigned determines whether a type is a signed arithmetic type. |char| is - * considered a signed type if it has the same representation as |signed char|. - * - * mozilla::IsSigned::value is true; - * mozilla::IsSigned::value is false; - * mozilla::IsSigned::value is false; - * mozilla::IsSigned::value is true. - */ -template -struct IsSigned : detail::IsSignedHelper {}; - -namespace detail { - -template::value, - bool = IsIntegral::value, - typename NoCV = typename RemoveCV::Type> -struct IsUnsignedHelper; - -// Floating point is not unsigned. -template -struct IsUnsignedHelper : FalseType {}; - -// Integral is conditionally unsigned. -template -struct IsUnsignedHelper - : IntegralConstant::value || bool(NoCV(1) < NoCV(-1)))> -{}; - -// Non-floating point, non-integral is not unsigned. -template -struct IsUnsignedHelper : FalseType {}; - -} // namespace detail - -/** - * IsUnsigned determines whether a type is an unsigned arithmetic type. - * - * mozilla::IsUnsigned::value is false; - * mozilla::IsUnsigned::value is true; - * mozilla::IsUnsigned::value is true; - * mozilla::IsUnsigned::value is false. - */ -template -struct IsUnsigned : detail::IsUnsignedHelper {}; - -namespace detail { - -struct DoIsDefaultConstructibleImpl -{ - template - static TrueType test(int); - template - static FalseType test(...); -}; - -template -struct IsDefaultConstructibleImpl : public DoIsDefaultConstructibleImpl -{ - typedef decltype(test(0)) Type; -}; - -} // namespace detail - -/** - * IsDefaultConstructible determines whether a type has a public default - * constructor. - * - * struct S0 {}; // Implicit default constructor. - * struct S1 { S1(); }; - * struct S2 { explicit S2(int); }; // No implicit default constructor when - * // another one is present. - * struct S3 { S3() = delete; }; - * class C4 { C4(); }; // Default constructor is private. - * - * mozilla::IsDefaultConstructible::value is true; - * mozilla::IsDefaultConstructible::value is true; - * mozilla::IsDefaultConstructible::value is true; - * mozilla::IsDefaultConstructible::value is false; - * mozilla::IsDefaultConstructible::value is false; - * mozilla::IsDefaultConstructible::value is false. - */ -template -struct IsDefaultConstructible - : public detail::IsDefaultConstructibleImpl::Type -{}; - -namespace detail { - -struct DoIsDestructibleImpl -{ - template().~T())> - static TrueType test(int); - template - static FalseType test(...); -}; - -template -struct IsDestructibleImpl : public DoIsDestructibleImpl -{ - typedef decltype(test(0)) Type; -}; - -} // namespace detail - -/** - * IsDestructible determines whether a type has a public destructor. - * - * struct S0 {}; // Implicit default destructor. - * struct S1 { ~S1(); }; - * class C2 { ~C2(); }; // private destructor. - * - * mozilla::IsDestructible::value is true; - * mozilla::IsDestructible::value is true; - * mozilla::IsDestructible::value is false. - */ -template -struct IsDestructible : public detail::IsDestructibleImpl::Type {}; - -/* 20.9.5 Type property queries [meta.unary.prop.query] */ - -/* 20.9.6 Relationships between types [meta.rel] */ - -/** - * IsSame tests whether two types are the same type. - * - * mozilla::IsSame::value is true; - * mozilla::IsSame::value is true; - * mozilla::IsSame::value is false; - * mozilla::IsSame::value is true; - * mozilla::IsSame::value is false; - * mozilla::IsSame::value is true. - */ -template -struct IsSame : FalseType {}; - -template -struct IsSame : TrueType {}; - -namespace detail { - -#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) - -template -struct BaseOfTester : IntegralConstant {}; - -#else - -// The trickery used to implement IsBaseOf here makes it possible to use it for -// the cases of private and multiple inheritance. This code was inspired by the -// sample code here: -// -// http://stackoverflow.com/questions/2910979/how-is-base-of-works -template -struct BaseOfHelper -{ -public: - operator Base*() const; - operator Derived*(); -}; - -template -struct BaseOfTester -{ -private: - template - static char test(Derived*, T); - static int test(Base*, int); - -public: - static const bool value = - sizeof(test(BaseOfHelper(), int())) == sizeof(char); -}; - -template -struct BaseOfTester -{ -private: - template - static char test(Derived*, T); - static int test(Base*, int); - -public: - static const bool value = - sizeof(test(BaseOfHelper(), int())) == sizeof(char); -}; - -template -struct BaseOfTester : FalseType {}; - -template -struct BaseOfTester : TrueType {}; - -template -struct BaseOfTester : TrueType {}; - -#endif - -} /* namespace detail */ - -/* - * IsBaseOf allows to know whether a given class is derived from another. - * - * Consider the following class definitions: - * - * class A {}; - * class B : public A {}; - * class C {}; - * - * mozilla::IsBaseOf::value is true; - * mozilla::IsBaseOf::value is false; - */ -template -struct IsBaseOf - : IntegralConstant::value> -{}; - -namespace detail { - -template -struct ConvertibleTester -{ -private: - template - static char test_helper(To1); - - template - static decltype(test_helper(DeclVal())) test(int); - - template - static int test(...); - -public: - static const bool value = - sizeof(test(0)) == sizeof(char); -}; - -} // namespace detail - -/** - * IsConvertible determines whether a value of type From will implicitly convert - * to a value of type To. For example: - * - * struct A {}; - * struct B : public A {}; - * struct C {}; - * - * mozilla::IsConvertible::value is true; - * mozilla::IsConvertible::value is true; - * mozilla::IsConvertible::value is true; - * mozilla::IsConvertible::value is true; - * mozilla::IsConvertible::value is false; - * mozilla::IsConvertible::value is false; - * mozilla::IsConvertible::value is false; - * mozilla::IsConvertible::value is false. - * - * For obscure reasons, you can't use IsConvertible when the types being tested - * are related through private inheritance, and you'll get a compile error if - * you try. Just don't do it! - * - * Note - we need special handling for void, which ConvertibleTester doesn't - * handle. The void handling here doesn't handle const/volatile void correctly, - * which could be easily fixed if the need arises. - */ -template -struct IsConvertible - : IntegralConstant::value> -{}; - -template -struct IsConvertible - : IntegralConstant::value> -{}; - -template -struct IsConvertible - : IntegralConstant::value> -{}; - -template<> -struct IsConvertible - : TrueType -{}; - -/* 20.9.7 Transformations between types [meta.trans] */ - -/* 20.9.7.1 Const-volatile modifications [meta.trans.cv] */ - -/** - * RemoveConst removes top-level const qualifications on a type. - * - * mozilla::RemoveConst::Type is int; - * mozilla::RemoveConst::Type is int; - * mozilla::RemoveConst::Type is const int*; - * mozilla::RemoveConst::Type is int*. - */ -template -struct RemoveConst -{ - typedef T Type; -}; - -template -struct RemoveConst -{ - typedef T Type; -}; - -/** - * RemoveVolatile removes top-level volatile qualifications on a type. - * - * mozilla::RemoveVolatile::Type is int; - * mozilla::RemoveVolatile::Type is int; - * mozilla::RemoveVolatile::Type is volatile int*; - * mozilla::RemoveVolatile::Type is int*. - */ -template -struct RemoveVolatile -{ - typedef T Type; -}; - -template -struct RemoveVolatile -{ - typedef T Type; -}; - -/** - * RemoveCV removes top-level const and volatile qualifications on a type. - * - * mozilla::RemoveCV::Type is int; - * mozilla::RemoveCV::Type is int; - * mozilla::RemoveCV::Type is int; - * mozilla::RemoveCV::Type is int*. - */ -template -struct RemoveCV -{ - typedef typename RemoveConst::Type>::Type Type; -}; - -/* 20.9.7.2 Reference modifications [meta.trans.ref] */ - -/** - * Converts reference types to the underlying types. - * - * mozilla::RemoveReference::Type is T; - * mozilla::RemoveReference::Type is T; - * mozilla::RemoveReference::Type is T; - */ - -template -struct RemoveReference -{ - typedef T Type; -}; - -template -struct RemoveReference -{ - typedef T Type; -}; - -template -struct RemoveReference -{ - typedef T Type; -}; - -template -struct Conditional; - -namespace detail { - -enum Voidness { TIsVoid, TIsNotVoid }; - -template::value ? TIsVoid : TIsNotVoid> -struct AddLvalueReferenceHelper; - -template -struct AddLvalueReferenceHelper -{ - typedef void Type; -}; - -template -struct AddLvalueReferenceHelper -{ - typedef T& Type; -}; - -} // namespace detail - -/** - * AddLvalueReference adds an lvalue & reference to T if one isn't already - * present. (Note: adding an lvalue reference to an rvalue && reference in - * essence replaces the && with a &&, per C+11 reference collapsing rules. For - * example, int&& would become int&.) - * - * The final computed type will only *not* be an lvalue reference if T is void. - * - * mozilla::AddLvalueReference::Type is int&; - * mozilla::AddLvalueRference::Type is volatile int&; - * mozilla::AddLvalueReference::Type is void*&; - * mozilla::AddLvalueReference::Type is void; - * mozilla::AddLvalueReference::Type is struct S&. - */ -template -struct AddLvalueReference - : detail::AddLvalueReferenceHelper -{}; - -namespace detail { - -template::value ? TIsVoid : TIsNotVoid> -struct AddRvalueReferenceHelper; - -template -struct AddRvalueReferenceHelper -{ - typedef void Type; -}; - -template -struct AddRvalueReferenceHelper -{ - typedef T&& Type; -}; - -} // namespace detail - -/** - * AddRvalueReference adds an rvalue && reference to T if one isn't already - * present. (Note: adding an rvalue reference to an lvalue & reference in - * essence keeps the &, per C+11 reference collapsing rules. For example, - * int& would remain int&.) - * - * The final computed type will only *not* be a reference if T is void. - * - * mozilla::AddRvalueReference::Type is int&&; - * mozilla::AddRvalueRference::Type is volatile int&; - * mozilla::AddRvalueRference::Type is const int&&; - * mozilla::AddRvalueReference::Type is void*&&; - * mozilla::AddRvalueReference::Type is void; - * mozilla::AddRvalueReference::Type is struct S&. - */ -template -struct AddRvalueReference - : detail::AddRvalueReferenceHelper -{}; - -/* 20.9.7.3 Sign modifications [meta.trans.sign] */ - -template -struct EnableIf; - -namespace detail { - -template -struct WithC : Conditional -{}; - -template -struct WithV : Conditional -{}; - - -template -struct WithCV : WithC::Type> -{}; - -template -struct CorrespondingSigned; - -template<> -struct CorrespondingSigned { typedef signed char Type; }; -template<> -struct CorrespondingSigned { typedef signed char Type; }; -template<> -struct CorrespondingSigned { typedef short Type; }; -template<> -struct CorrespondingSigned { typedef int Type; }; -template<> -struct CorrespondingSigned { typedef long Type; }; -template<> -struct CorrespondingSigned { typedef long long Type; }; - -template::Type, - bool IsSignedIntegerType = IsSigned::value && - !IsSame::value> -struct MakeSigned; - -template -struct MakeSigned -{ - typedef T Type; -}; - -template -struct MakeSigned - : WithCV::value, IsVolatile::value, - typename CorrespondingSigned::Type> -{}; - -} // namespace detail - -/** - * MakeSigned produces the corresponding signed integer type for a given - * integral type T, with the const/volatile qualifiers of T. T must be a - * possibly-const/volatile-qualified integral type that isn't bool. - * - * If T is already a signed integer type (not including char!), then T is - * produced. - * - * Otherwise, if T is an unsigned integer type, the signed variety of T, with - * T's const/volatile qualifiers, is produced. - * - * Otherwise, the integral type of the same size as T, with the lowest rank, - * with T's const/volatile qualifiers, is produced. (This basically only acts - * to produce signed char when T = char.) - * - * mozilla::MakeSigned::Type is signed long; - * mozilla::MakeSigned::Type is volatile int; - * mozilla::MakeSigned::Type is const signed short; - * mozilla::MakeSigned::Type is const signed char; - * mozilla::MakeSigned is an error; - * mozilla::MakeSigned is an error. - */ -template -struct MakeSigned - : EnableIf::value && - !IsSame::Type>::value, - typename detail::MakeSigned - >::Type -{}; - -namespace detail { - -template -struct CorrespondingUnsigned; - -template<> -struct CorrespondingUnsigned { typedef unsigned char Type; }; -template<> -struct CorrespondingUnsigned { typedef unsigned char Type; }; -template<> -struct CorrespondingUnsigned { typedef unsigned short Type; }; -template<> -struct CorrespondingUnsigned { typedef unsigned int Type; }; -template<> -struct CorrespondingUnsigned { typedef unsigned long Type; }; -template<> -struct CorrespondingUnsigned { typedef unsigned long long Type; }; - - -template::Type, - bool IsUnsignedIntegerType = IsUnsigned::value && - !IsSame::value> -struct MakeUnsigned; - -template -struct MakeUnsigned -{ - typedef T Type; -}; - -template -struct MakeUnsigned - : WithCV::value, IsVolatile::value, - typename CorrespondingUnsigned::Type> -{}; - -} // namespace detail - -/** - * MakeUnsigned produces the corresponding unsigned integer type for a given - * integral type T, with the const/volatile qualifiers of T. T must be a - * possibly-const/volatile-qualified integral type that isn't bool. - * - * If T is already an unsigned integer type (not including char!), then T is - * produced. - * - * Otherwise, if T is an signed integer type, the unsigned variety of T, with - * T's const/volatile qualifiers, is produced. - * - * Otherwise, the unsigned integral type of the same size as T, with the lowest - * rank, with T's const/volatile qualifiers, is produced. (This basically only - * acts to produce unsigned char when T = char.) - * - * mozilla::MakeUnsigned::Type is unsigned long; - * mozilla::MakeUnsigned::Type is volatile unsigned int; - * mozilla::MakeUnsigned::Type is const unsigned short; - * mozilla::MakeUnsigned::Type is const unsigned char; - * mozilla::MakeUnsigned is an error; - * mozilla::MakeUnsigned is an error. - */ -template -struct MakeUnsigned - : EnableIf::value && - !IsSame::Type>::value, - typename detail::MakeUnsigned - >::Type -{}; - -/* 20.9.7.4 Array modifications [meta.trans.arr] */ - -/** - * RemoveExtent produces either the type of the elements of the array T, or T - * itself. - * - * mozilla::RemoveExtent::Type is int; - * mozilla::RemoveExtent::Type is const int; - * mozilla::RemoveExtent::Type is volatile int; - * mozilla::RemoveExtent::Type is long[17]. - */ -template -struct RemoveExtent -{ - typedef T Type; -}; - -template -struct RemoveExtent -{ - typedef T Type; -}; - -template -struct RemoveExtent -{ - typedef T Type; -}; - -/* 20.9.7.5 Pointer modifications [meta.trans.ptr] */ - -namespace detail { - -template -struct RemovePointerHelper -{ - typedef T Type; -}; - -template -struct RemovePointerHelper -{ - typedef Pointee Type; -}; - -} // namespace detail - -/** - * Produces the pointed-to type if a pointer is provided, else returns the input - * type. Note that this does not dereference pointer-to-member pointers. - * - * struct S { bool m; void f(); }; - * mozilla::RemovePointer::Type is int; - * mozilla::RemovePointer::Type is int; - * mozilla::RemovePointer::Type is int; - * mozilla::RemovePointer::Type is int; - * mozilla::RemovePointer::Type is const long; - * mozilla::RemovePointer::Type is void; - * mozilla::RemovePointer::Type is void (S::*)(); - * mozilla::RemovePointer::Type is void(); - * mozilla::RemovePointer::Type is bool S::*. - */ -template -struct RemovePointer - : detail::RemovePointerHelper::Type> -{}; - -/** - * Converts T& to T*. Otherwise returns T* given T. Note that C++17 wants - * std::add_pointer to work differently for function types. We don't implement - * that behavior here. - * - * mozilla::AddPointer is int*; - * mozilla::AddPointer is int**; - * mozilla::AddPointer is int*; - * mozilla::AddPointer is int** const. - */ -template -struct AddPointer -{ - typedef typename RemoveReference::Type* Type; -}; - -/* 20.9.7.6 Other transformations [meta.trans.other] */ - -/** - * EnableIf is a struct containing a typedef of T if and only if B is true. - * - * mozilla::EnableIf::Type is int; - * mozilla::EnableIf::Type is a compile-time error. - * - * Use this template to implement SFINAE-style (Substitution Failure Is not An - * Error) requirements. For example, you might use it to impose a restriction - * on a template parameter: - * - * template - * class PodVector // vector optimized to store POD (memcpy-able) types - * { - * EnableIf::value, T>::Type* vector; - * size_t length; - * ... - * }; - */ -template -struct EnableIf -{}; - -template -struct EnableIf -{ - typedef T Type; -}; - -/** - * Conditional selects a class between two, depending on a given boolean value. - * - * mozilla::Conditional::Type is A; - * mozilla::Conditional::Type is B; - */ -template -struct Conditional -{ - typedef A Type; -}; - -template -struct Conditional -{ - typedef B Type; -}; - -namespace detail { - -template::value, - bool IsFunction = IsFunction::value> -struct DecaySelector; - -template -struct DecaySelector -{ - typedef typename RemoveCV::Type Type; -}; - -template -struct DecaySelector -{ - typedef typename RemoveExtent::Type* Type; -}; - -template -struct DecaySelector -{ - typedef typename AddPointer::Type Type; -}; - -}; // namespace detail - -/** - * Strips const/volatile off a type and decays it from an lvalue to an - * rvalue. So function types are converted to function pointers, arrays to - * pointers, and references are removed. - * - * mozilla::Decay::Type is int - * mozilla::Decay::Type is int - * mozilla::Decay::Type is int - * mozilla::Decay::Type is int - * mozilla::Decay::Type is int* - * mozilla::Decay::Type is int(*)(int) - */ -template -class Decay - : public detail::DecaySelector::Type> -{ -}; - -} /* namespace mozilla */ - -#endif /* mozilla_TypeTraits_h */ diff --git a/sources/firefox/mozilla/Types.h b/sources/firefox/mozilla/Types.h deleted file mode 100644 index 30f4ea3d..00000000 --- a/sources/firefox/mozilla/Types.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* mfbt foundational types and macros. */ - -#ifndef mozilla_Types_h -#define mozilla_Types_h - -/* - * This header must be valid C and C++, includable by code embedding either - * SpiderMonkey or Gecko. - */ - -/* Expose all types and size_t. */ -#include -#include - -/* Implement compiler and linker macros needed for APIs. */ - -/* - * MOZ_EXPORT is used to declare and define a symbol or type which is externally - * visible to users of the current library. It encapsulates various decorations - * needed to properly export the method's symbol. - * - * api.h: - * extern MOZ_EXPORT int MeaningOfLife(void); - * extern MOZ_EXPORT int LuggageCombination; - * - * api.c: - * int MeaningOfLife(void) { return 42; } - * int LuggageCombination = 12345; - * - * If you are merely sharing a method across files, just use plain |extern|. - * These macros are designed for use by library interfaces -- not for normal - * methods or data used cross-file. - */ -#if defined(WIN32) -# define MOZ_EXPORT __declspec(dllexport) -#else /* Unix */ -# ifdef HAVE_VISIBILITY_ATTRIBUTE -# define MOZ_EXPORT __attribute__((visibility("default"))) -# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# define MOZ_EXPORT __global -# else -# define MOZ_EXPORT /* nothing */ -# endif -#endif - - -/* - * Whereas implementers use MOZ_EXPORT to declare and define library symbols, - * users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to access them. Most often the - * implementer of the library will expose an API macro which expands to either - * the export or import version of the macro, depending upon the compilation - * mode. - */ -#ifdef _WIN32 -# if defined(__MWERKS__) -# define MOZ_IMPORT_API /* nothing */ -# else -# define MOZ_IMPORT_API __declspec(dllimport) -# endif -#else -# define MOZ_IMPORT_API MOZ_EXPORT -#endif - -#if defined(_WIN32) && !defined(__MWERKS__) -# define MOZ_IMPORT_DATA __declspec(dllimport) -#else -# define MOZ_IMPORT_DATA MOZ_EXPORT -#endif - -/* - * Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose - * export mfbt declarations when building mfbt, and they expose import mfbt - * declarations when using mfbt. - */ -#if defined(IMPL_MFBT) || (defined(JS_STANDALONE) && !defined(MOZ_MEMORY) && (defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API))) -# define MFBT_API MOZ_EXPORT -# define MFBT_DATA MOZ_EXPORT -#else -# if defined(JS_STANDALONE) && !defined(MOZ_MEMORY) && defined(STATIC_JS_API) -# define MFBT_API -# define MFBT_DATA -# else - /* - * On linux mozglue is linked in the program and we link libxul.so with - * -z,defs. Normally that causes the linker to reject undefined references in - * libxul.so, but as a loophole it allows undefined references to weak - * symbols. We add the weak attribute to the import version of the MFBT API - * macros to exploit this. - */ -# if defined(MOZ_GLUE_IN_PROGRAM) -# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API -# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA -# else -# define MFBT_API MOZ_IMPORT_API -# define MFBT_DATA MOZ_IMPORT_DATA -# endif -# endif -#endif - -/* - * C symbols in C++ code must be declared immediately within |extern "C"| - * blocks. However, in C code, they need not be declared specially. This - * difference is abstracted behind the MOZ_BEGIN_EXTERN_C and MOZ_END_EXTERN_C - * macros, so that the user need not know whether he is being used in C or C++ - * code. - * - * MOZ_BEGIN_EXTERN_C - * - * extern MOZ_EXPORT int MostRandomNumber(void); - * ...other declarations... - * - * MOZ_END_EXTERN_C - * - * This said, it is preferable to just use |extern "C"| in C++ header files for - * its greater clarity. - */ -#ifdef __cplusplus -# define MOZ_BEGIN_EXTERN_C extern "C" { -# define MOZ_END_EXTERN_C } -#else -# define MOZ_BEGIN_EXTERN_C -# define MOZ_END_EXTERN_C -#endif - -/* - * GCC's typeof is available when decltype is not. - */ -#if defined(__GNUC__) && defined(__cplusplus) && \ - !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L -# define decltype __typeof__ -#endif - -#endif /* mozilla_Types_h */ diff --git a/sources/firefox/mozilla/UniquePtr.h b/sources/firefox/mozilla/UniquePtr.h deleted file mode 100644 index 7e1035bc..00000000 --- a/sources/firefox/mozilla/UniquePtr.h +++ /dev/null @@ -1,697 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Smart pointer managing sole ownership of a resource. */ - -#ifndef mozilla_UniquePtr_h -#define mozilla_UniquePtr_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/Move.h" -#include "mozilla/Pair.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -template class DefaultDelete; -template> class UniquePtr; - -} // namespace mozilla - -namespace mozilla { - -namespace detail { - -struct HasPointerTypeHelper -{ - template static double Test(...); - template static char Test(typename U::pointer* = 0); -}; - -template -class HasPointerType : public IntegralConstant(0)) == 1> -{ -}; - -template ::value> -struct PointerTypeImpl -{ - typedef typename D::pointer Type; -}; - -template -struct PointerTypeImpl -{ - typedef T* Type; -}; - -template -struct PointerType -{ - typedef typename PointerTypeImpl::Type>::Type Type; -}; - -} // namespace detail - -/** - * UniquePtr is a smart pointer that wholly owns a resource. Ownership may be - * transferred out of a UniquePtr through explicit action, but otherwise the - * resource is destroyed when the UniquePtr is destroyed. - * - * UniquePtr is similar to C++98's std::auto_ptr, but it improves upon auto_ptr - * in one crucial way: it's impossible to copy a UniquePtr. Copying an auto_ptr - * obviously *can't* copy ownership of its singly-owned resource. So what - * happens if you try to copy one? Bizarrely, ownership is implicitly - * *transferred*, preserving single ownership but breaking code that assumes a - * copy of an object is identical to the original. (This is why auto_ptr is - * prohibited in STL containers.) - * - * UniquePtr solves this problem by being *movable* rather than copyable. - * Instead of passing a |UniquePtr u| directly to the constructor or assignment - * operator, you pass |Move(u)|. In doing so you indicate that you're *moving* - * ownership out of |u|, into the target of the construction/assignment. After - * the transfer completes, |u| contains |nullptr| and may be safely destroyed. - * This preserves single ownership but also allows UniquePtr to be moved by - * algorithms that have been made move-safe. (Note: if |u| is instead a - * temporary expression, don't use |Move()|: just pass the expression, because - * it's already move-ready. For more information see Move.h.) - * - * UniquePtr is also better than std::auto_ptr in that the deletion operation is - * customizable. An optional second template parameter specifies a class that - * (through its operator()(T*)) implements the desired deletion policy. If no - * policy is specified, mozilla::DefaultDelete is used -- which will either - * |delete| or |delete[]| the resource, depending whether the resource is an - * array. Custom deletion policies ideally should be empty classes (no member - * fields, no member fields in base classes, no virtual methods/inheritance), - * because then UniquePtr can be just as efficient as a raw pointer. - * - * Use of UniquePtr proceeds like so: - * - * UniquePtr g1; // initializes to nullptr - * g1.reset(new int); // switch resources using reset() - * g1 = nullptr; // clears g1, deletes the int - * - * UniquePtr g2(new int); // owns that int - * int* p = g2.release(); // g2 leaks its int -- still requires deletion - * delete p; // now freed - * - * struct S { int x; S(int x) : x(x) {} }; - * UniquePtr g3, g4(new S(5)); - * g3 = Move(g4); // g3 owns the S, g4 cleared - * S* p = g3.get(); // g3 still owns |p| - * assert(g3->x == 5); // operator-> works (if .get() != nullptr) - * assert((*g3).x == 5); // also operator* (again, if not cleared) - * Swap(g3, g4); // g4 now owns the S, g3 cleared - * g3.swap(g4); // g3 now owns the S, g4 cleared - * UniquePtr g5(Move(g3)); // g5 owns the S, g3 cleared - * g5.reset(); // deletes the S, g5 cleared - * - * struct FreePolicy { void operator()(void* p) { free(p); } }; - * UniquePtr g6(static_cast(malloc(sizeof(int)))); - * int* ptr = g6.get(); - * g6 = nullptr; // calls free(ptr) - * - * Now, carefully note a few things you *can't* do: - * - * UniquePtr b1; - * b1 = new int; // BAD: can only assign another UniquePtr - * int* ptr = b1; // BAD: no auto-conversion to pointer, use get() - * - * UniquePtr b2(b1); // BAD: can't copy a UniquePtr - * UniquePtr b3 = b1; // BAD: can't copy-assign a UniquePtr - * - * (Note that changing a UniquePtr to store a direct |new| expression is - * permitted, but usually you should use MakeUnique, defined at the end of this - * header.) - * - * A few miscellaneous notes: - * - * UniquePtr, when not instantiated for an array type, can be move-constructed - * and move-assigned, not only from itself but from "derived" UniquePtr - * instantiations where U converts to T and E converts to D. If you want to use - * this, you're going to have to specify a deletion policy for both UniquePtr - * instantations, and T pretty much has to have a virtual destructor. In other - * words, this doesn't work: - * - * struct Base { virtual ~Base() {} }; - * struct Derived : Base {}; - * - * UniquePtr b1; - * // BAD: DefaultDelete and DefaultDelete don't interconvert - * UniquePtr d1(Move(b)); - * - * UniquePtr b2; - * UniquePtr> d2(Move(b2)); // okay - * - * UniquePtr is specialized for array types. Specializing with an array type - * creates a smart-pointer version of that array -- not a pointer to such an - * array. - * - * UniquePtr arr(new int[5]); - * arr[0] = 4; - * - * What else is different? Deletion of course uses |delete[]|. An operator[] - * is provided. Functionality that doesn't make sense for arrays is removed. - * The constructors and mutating methods only accept array pointers (not T*, U* - * that converts to T*, or UniquePtr or UniquePtr) or |nullptr|. - * - * It's perfectly okay for a function to return a UniquePtr. This transfers - * the UniquePtr's sole ownership of the data, to the fresh UniquePtr created - * in the calling function, that will then solely own that data. Such functions - * can return a local variable UniquePtr, |nullptr|, |UniquePtr(ptr)| where - * |ptr| is a |T*|, or a UniquePtr |Move()|'d from elsewhere. - * - * UniquePtr will commonly be a member of a class, with lifetime equivalent to - * that of that class. If you want to expose the related resource, you could - * expose a raw pointer via |get()|, but ownership of a raw pointer is - * inherently unclear. So it's better to expose a |const UniquePtr&| instead. - * This prohibits mutation but still allows use of |get()| when needed (but - * operator-> is preferred). Of course, you can only use this smart pointer as - * long as the enclosing class instance remains live -- no different than if you - * exposed the |get()| raw pointer. - * - * To pass a UniquePtr-managed resource as a pointer, use a |const UniquePtr&| - * argument. To specify an inout parameter (where the method may or may not - * take ownership of the resource, or reset it), or to specify an out parameter - * (where simply returning a |UniquePtr| isn't possible), use a |UniquePtr&| - * argument. To unconditionally transfer ownership of a UniquePtr - * into a method, use a |UniquePtr| argument. To conditionally transfer - * ownership of a resource into a method, should the method want it, use a - * |UniquePtr&&| argument. - */ -template -class UniquePtr -{ -public: - typedef T ElementType; - typedef D DeleterType; - typedef typename detail::PointerType::Type Pointer; - -private: - Pair mTuple; - - Pointer& ptr() { return mTuple.first(); } - const Pointer& ptr() const { return mTuple.first(); } - - DeleterType& del() { return mTuple.second(); } - const DeleterType& del() const { return mTuple.second(); } - -public: - /** - * Construct a UniquePtr containing |nullptr|. - */ - constexpr UniquePtr() - : mTuple(static_cast(nullptr), DeleterType()) - { - static_assert(!IsPointer::value, "must provide a deleter instance"); - static_assert(!IsReference::value, "must provide a deleter instance"); - } - - /** - * Construct a UniquePtr containing |aPtr|. - */ - explicit UniquePtr(Pointer aPtr) - : mTuple(aPtr, DeleterType()) - { - static_assert(!IsPointer::value, "must provide a deleter instance"); - static_assert(!IsReference::value, "must provide a deleter instance"); - } - - UniquePtr(Pointer aPtr, - typename Conditional::value, - D, - const D&>::Type aD1) - : mTuple(aPtr, aD1) - {} - - // If you encounter an error with MSVC10 about RemoveReference below, along - // the lines that "more than one partial specialization matches the template - // argument list": don't use UniquePtr! Ideally - // you should make deletion use the same function every time, using a - // deleter policy: - // - // // BAD, won't compile with MSVC10, deleter doesn't need to be a - // // variable at all - // typedef void (&FreeSignature)(void*); - // UniquePtr ptr((int*) malloc(sizeof(int)), free); - // - // // GOOD, compiles with MSVC10, deletion behavior statically known and - // // optimizable - // struct DeleteByFreeing - // { - // void operator()(void* aPtr) { free(aPtr); } - // }; - // - // If deletion really, truly, must be a variable: you might be able to work - // around this with a deleter class that contains the function reference. - // But this workaround is untried and untested, because variable deletion - // behavior really isn't something you should use. - UniquePtr(Pointer aPtr, - typename RemoveReference::Type&& aD2) - : mTuple(aPtr, Move(aD2)) - { - static_assert(!IsReference::value, - "rvalue deleter can't be stored by reference"); - } - - UniquePtr(UniquePtr&& aOther) - : mTuple(aOther.release(), Forward(aOther.get_deleter())) - {} - - MOZ_IMPLICIT - UniquePtr(decltype(nullptr)) - : mTuple(nullptr, DeleterType()) - { - static_assert(!IsPointer::value, "must provide a deleter instance"); - static_assert(!IsReference::value, "must provide a deleter instance"); - } - - template - MOZ_IMPLICIT - UniquePtr(UniquePtr&& aOther, - typename EnableIf::Pointer, - Pointer>::value && - !IsArray::value && - (IsReference::value - ? IsSame::value - : IsConvertible::value), - int>::Type aDummy = 0) - : mTuple(aOther.release(), Forward(aOther.get_deleter())) - { - } - - ~UniquePtr() { reset(nullptr); } - - UniquePtr& operator=(UniquePtr&& aOther) - { - reset(aOther.release()); - get_deleter() = Forward(aOther.get_deleter()); - return *this; - } - - template - UniquePtr& operator=(UniquePtr&& aOther) - { - static_assert(IsConvertible::Pointer, - Pointer>::value, - "incompatible UniquePtr pointees"); - static_assert(!IsArray::value, - "can't assign from UniquePtr holding an array"); - - reset(aOther.release()); - get_deleter() = Forward(aOther.get_deleter()); - return *this; - } - - UniquePtr& operator=(decltype(nullptr)) - { - reset(nullptr); - return *this; - } - - T& operator*() const { return *get(); } - Pointer operator->() const - { - MOZ_ASSERT(get(), "dereferencing a UniquePtr containing nullptr"); - return get(); - } - - explicit operator bool() const { return get() != nullptr; } - - Pointer get() const { return ptr(); } - - DeleterType& get_deleter() { return del(); } - const DeleterType& get_deleter() const { return del(); } - - MOZ_MUST_USE Pointer release() - { - Pointer p = ptr(); - ptr() = nullptr; - return p; - } - - void reset(Pointer aPtr = Pointer()) - { - Pointer old = ptr(); - ptr() = aPtr; - if (old != nullptr) { - get_deleter()(old); - } - } - - void swap(UniquePtr& aOther) - { - mTuple.swap(aOther.mTuple); - } - - UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()! - void operator=(const UniquePtr& aOther) = delete; // assign using Move()! -}; - -// In case you didn't read the comment by the main definition (you should!): the -// UniquePtr specialization exists to manage array pointers. It deletes -// such pointers using delete[], it will reject construction and modification -// attempts using U* or U[]. Otherwise it works like the normal UniquePtr. -template -class UniquePtr -{ -public: - typedef T* Pointer; - typedef T ElementType; - typedef D DeleterType; - -private: - Pair mTuple; - -public: - /** - * Construct a UniquePtr containing nullptr. - */ - constexpr UniquePtr() - : mTuple(static_cast(nullptr), DeleterType()) - { - static_assert(!IsPointer::value, "must provide a deleter instance"); - static_assert(!IsReference::value, "must provide a deleter instance"); - } - - /** - * Construct a UniquePtr containing |aPtr|. - */ - explicit UniquePtr(Pointer aPtr) - : mTuple(aPtr, DeleterType()) - { - static_assert(!IsPointer::value, "must provide a deleter instance"); - static_assert(!IsReference::value, "must provide a deleter instance"); - } - - // delete[] knows how to handle *only* an array of a single class type. For - // delete[] to work correctly, it must know the size of each element, the - // fields and base classes of each element requiring destruction, and so on. - // So forbid all overloads which would end up invoking delete[] on a pointer - // of the wrong type. - template - UniquePtr(U&& aU, - typename EnableIf::value && - IsConvertible::value, - int>::Type aDummy = 0) - = delete; - - UniquePtr(Pointer aPtr, - typename Conditional::value, - D, - const D&>::Type aD1) - : mTuple(aPtr, aD1) - {} - - // If you encounter an error with MSVC10 about RemoveReference below, along - // the lines that "more than one partial specialization matches the template - // argument list": don't use UniquePtr! See the - // comment by this constructor in the non-T[] specialization above. - UniquePtr(Pointer aPtr, - typename RemoveReference::Type&& aD2) - : mTuple(aPtr, Move(aD2)) - { - static_assert(!IsReference::value, - "rvalue deleter can't be stored by reference"); - } - - // Forbidden for the same reasons as stated above. - template - UniquePtr(U&& aU, V&& aV, - typename EnableIf::value && - IsConvertible::value, - int>::Type aDummy = 0) - = delete; - - UniquePtr(UniquePtr&& aOther) - : mTuple(aOther.release(), Forward(aOther.get_deleter())) - {} - - MOZ_IMPLICIT - UniquePtr(decltype(nullptr)) - : mTuple(nullptr, DeleterType()) - { - static_assert(!IsPointer::value, "must provide a deleter instance"); - static_assert(!IsReference::value, "must provide a deleter instance"); - } - - ~UniquePtr() { reset(nullptr); } - - UniquePtr& operator=(UniquePtr&& aOther) - { - reset(aOther.release()); - get_deleter() = Forward(aOther.get_deleter()); - return *this; - } - - UniquePtr& operator=(decltype(nullptr)) - { - reset(); - return *this; - } - - explicit operator bool() const { return get() != nullptr; } - - T& operator[](decltype(sizeof(int)) aIndex) const { return get()[aIndex]; } - Pointer get() const { return mTuple.first(); } - - DeleterType& get_deleter() { return mTuple.second(); } - const DeleterType& get_deleter() const { return mTuple.second(); } - - MOZ_MUST_USE Pointer release() - { - Pointer p = mTuple.first(); - mTuple.first() = nullptr; - return p; - } - - void reset(Pointer aPtr = Pointer()) - { - Pointer old = mTuple.first(); - mTuple.first() = aPtr; - if (old != nullptr) { - mTuple.second()(old); - } - } - - void reset(decltype(nullptr)) - { - Pointer old = mTuple.first(); - mTuple.first() = nullptr; - if (old != nullptr) { - mTuple.second()(old); - } - } - - template - void reset(U) = delete; - - void swap(UniquePtr& aOther) { mTuple.swap(aOther.mTuple); } - - UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()! - void operator=(const UniquePtr& aOther) = delete; // assign using Move()! -}; - -/** - * A default deletion policy using plain old operator delete. - * - * Note that this type can be specialized, but authors should beware of the risk - * that the specialization may at some point cease to match (either because it - * gets moved to a different compilation unit or the signature changes). If the - * non-specialized (|delete|-based) version compiles for that type but does the - * wrong thing, bad things could happen. - * - * This is a non-issue for types which are always incomplete (i.e. opaque handle - * types), since |delete|-ing such a type will always trigger a compilation - * error. - */ -template -class DefaultDelete -{ -public: - constexpr DefaultDelete() {} - - template - MOZ_IMPLICIT DefaultDelete(const DefaultDelete& aOther, - typename EnableIf::value, - int>::Type aDummy = 0) - {} - - void operator()(T* aPtr) const - { - static_assert(sizeof(T) > 0, "T must be complete"); - delete aPtr; - } -}; - -/** A default deletion policy using operator delete[]. */ -template -class DefaultDelete -{ -public: - constexpr DefaultDelete() {} - - void operator()(T* aPtr) const - { - static_assert(sizeof(T) > 0, "T must be complete"); - delete[] aPtr; - } - - template - void operator()(U* aPtr) const = delete; -}; - -template -void -Swap(UniquePtr& aX, UniquePtr& aY) -{ - aX.swap(aY); -} - -template -bool -operator==(const UniquePtr& aX, const UniquePtr& aY) -{ - return aX.get() == aY.get(); -} - -template -bool -operator!=(const UniquePtr& aX, const UniquePtr& aY) -{ - return aX.get() != aY.get(); -} - -template -bool -operator==(const UniquePtr& aX, decltype(nullptr)) -{ - return !aX; -} - -template -bool -operator==(decltype(nullptr), const UniquePtr& aX) -{ - return !aX; -} - -template -bool -operator!=(const UniquePtr& aX, decltype(nullptr)) -{ - return bool(aX); -} - -template -bool -operator!=(decltype(nullptr), const UniquePtr& aX) -{ - return bool(aX); -} - -// No operator<, operator>, operator<=, operator>= for now because simplicity. - -namespace detail { - -template -struct UniqueSelector -{ - typedef UniquePtr SingleObject; -}; - -template -struct UniqueSelector -{ - typedef UniquePtr UnknownBound; -}; - -template -struct UniqueSelector -{ - typedef UniquePtr KnownBound; -}; - -} // namespace detail - -/** - * MakeUnique is a helper function for allocating new'd objects and arrays, - * returning a UniquePtr containing the resulting pointer. The semantics of - * MakeUnique(...) are as follows. - * - * If Type is an array T[n]: - * Disallowed, deleted, no overload for you! - * If Type is an array T[]: - * MakeUnique(size_t) is the only valid overload. The pointer returned - * is as if by |new T[n]()|, which value-initializes each element. (If T - * isn't a class type, this will zero each element. If T is a class type, - * then roughly speaking, each element will be constructed using its default - * constructor. See C++11 [dcl.init]p7 for the full gory details.) - * If Type is non-array T: - * The arguments passed to MakeUnique(...) are forwarded into a - * |new T(...)| call, initializing the T as would happen if executing - * |T(...)|. - * - * There are various benefits to using MakeUnique instead of |new| expressions. - * - * First, MakeUnique eliminates use of |new| from code entirely. If objects are - * only created through UniquePtr, then (assuming all explicit release() calls - * are safe, including transitively, and no type-safety casting funniness) - * correctly maintained ownership of the UniquePtr guarantees no leaks are - * possible. (This pays off best if a class is only ever created through a - * factory method on the class, using a private constructor.) - * - * Second, initializing a UniquePtr using a |new| expression requires repeating - * the name of the new'd type, whereas MakeUnique in concert with the |auto| - * keyword names it only once: - * - * UniquePtr ptr1(new char()); // repetitive - * auto ptr2 = MakeUnique(); // shorter - * - * Of course this assumes the reader understands the operation MakeUnique - * performs. In the long run this is probably a reasonable assumption. In the - * short run you'll have to use your judgment about what readers can be expected - * to know, or to quickly look up. - * - * Third, a call to MakeUnique can be assigned directly to a UniquePtr. In - * contrast you can't assign a pointer into a UniquePtr without using the - * cumbersome reset(). - * - * UniquePtr p; - * p = new char; // ERROR - * p.reset(new char); // works, but fugly - * p = MakeUnique(); // preferred - * - * (And third, although not relevant to Mozilla: MakeUnique is exception-safe. - * An exception thrown after |new T| succeeds will leak that memory, unless the - * pointer is assigned to an object that will manage its ownership. UniquePtr - * ably serves this function.) - */ - -template -typename detail::UniqueSelector::SingleObject -MakeUnique(Args&&... aArgs) -{ - return UniquePtr(new T(Forward(aArgs)...)); -} - -template -typename detail::UniqueSelector::UnknownBound -MakeUnique(decltype(sizeof(int)) aN) -{ - typedef typename RemoveExtent::Type ArrayType; - return UniquePtr(new ArrayType[aN]()); -} - -template -typename detail::UniqueSelector::KnownBound -MakeUnique(Args&&... aArgs) = delete; - -} // namespace mozilla - -#endif /* mozilla_UniquePtr_h */ diff --git a/sources/poly2tri/common/shapes.cc b/sources/poly2tri/common/shapes.cc deleted file mode 100644 index d0de13e6..00000000 --- a/sources/poly2tri/common/shapes.cc +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "shapes.h" -#include - -namespace p2t { - -Triangle::Triangle(Point& a, Point& b, Point& c) -{ - points_[0] = &a; points_[1] = &b; points_[2] = &c; - neighbors_[0] = NULL; neighbors_[1] = NULL; neighbors_[2] = NULL; - constrained_edge[0] = constrained_edge[1] = constrained_edge[2] = false; - delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false; - interior_ = false; -} - -// Update neighbor pointers -void Triangle::MarkNeighbor(Point* p1, Point* p2, Triangle* t) -{ - if ((p1 == points_[2] && p2 == points_[1]) || (p1 == points_[1] && p2 == points_[2])) - neighbors_[0] = t; - else if ((p1 == points_[0] && p2 == points_[2]) || (p1 == points_[2] && p2 == points_[0])) - neighbors_[1] = t; - else if ((p1 == points_[0] && p2 == points_[1]) || (p1 == points_[1] && p2 == points_[0])) - neighbors_[2] = t; - else - assert(0); -} - -// Exhaustive search to update neighbor pointers -void Triangle::MarkNeighbor(Triangle& t) -{ - if (t.Contains(points_[1], points_[2])) { - neighbors_[0] = &t; - t.MarkNeighbor(points_[1], points_[2], this); - } else if (t.Contains(points_[0], points_[2])) { - neighbors_[1] = &t; - t.MarkNeighbor(points_[0], points_[2], this); - } else if (t.Contains(points_[0], points_[1])) { - neighbors_[2] = &t; - t.MarkNeighbor(points_[0], points_[1], this); - } -} - -/** - * Clears all references to all other triangles and points - */ -void Triangle::Clear() -{ - Triangle *t; - for( int i=0; i<3; i++ ) - { - t = neighbors_[i]; - if( t != NULL ) - { - t->ClearNeighbor( this ); - } - } - ClearNeighbors(); - points_[0]=points_[1]=points_[2] = NULL; -} - -void Triangle::ClearNeighbor(const Triangle *triangle ) -{ - if( neighbors_[0] == triangle ) - { - neighbors_[0] = NULL; - } - else if( neighbors_[1] == triangle ) - { - neighbors_[1] = NULL; - } - else - { - neighbors_[2] = NULL; - } -} - -void Triangle::ClearNeighbors() -{ - neighbors_[0] = NULL; - neighbors_[1] = NULL; - neighbors_[2] = NULL; -} - -void Triangle::ClearDelunayEdges() -{ - delaunay_edge[0] = delaunay_edge[1] = delaunay_edge[2] = false; -} - -Point* Triangle::OppositePoint(Triangle& t, const Point& p) -{ - Point *cw = t.PointCW(p); - return PointCW(*cw); -} - -// Legalized triangle by rotating clockwise around point(0) -void Triangle::Legalize(Point& point) -{ - points_[1] = points_[0]; - points_[0] = points_[2]; - points_[2] = &point; -} - -// Legalize triagnle by rotating clockwise around oPoint -void Triangle::Legalize(Point& opoint, Point& npoint) -{ - if (&opoint == points_[0]) { - points_[1] = points_[0]; - points_[0] = points_[2]; - points_[2] = &npoint; - } else if (&opoint == points_[1]) { - points_[2] = points_[1]; - points_[1] = points_[0]; - points_[0] = &npoint; - } else if (&opoint == points_[2]) { - points_[0] = points_[2]; - points_[2] = points_[1]; - points_[1] = &npoint; - } else { - assert(0); - } -} - -int Triangle::Index(const Point* p) -{ - if (p == points_[0]) { - return 0; - } else if (p == points_[1]) { - return 1; - } else if (p == points_[2]) { - return 2; - } - assert(0); - return -1; -} - -int Triangle::EdgeIndex(const Point* p1, const Point* p2) -{ - if (points_[0] == p1) { - if (points_[1] == p2) { - return 2; - } else if (points_[2] == p2) { - return 1; - } - } else if (points_[1] == p1) { - if (points_[2] == p2) { - return 0; - } else if (points_[0] == p2) { - return 2; - } - } else if (points_[2] == p1) { - if (points_[0] == p2) { - return 1; - } else if (points_[1] == p2) { - return 0; - } - } - return -1; -} - -void Triangle::MarkConstrainedEdge(int index) -{ - constrained_edge[index] = true; -} - -void Triangle::MarkConstrainedEdge(Edge& edge) -{ - MarkConstrainedEdge(edge.p, edge.q); -} - -// Mark edge as constrained -void Triangle::MarkConstrainedEdge(Point* p, Point* q) -{ - if ((q == points_[0] && p == points_[1]) || (q == points_[1] && p == points_[0])) { - constrained_edge[2] = true; - } else if ((q == points_[0] && p == points_[2]) || (q == points_[2] && p == points_[0])) { - constrained_edge[1] = true; - } else if ((q == points_[1] && p == points_[2]) || (q == points_[2] && p == points_[1])) { - constrained_edge[0] = true; - } -} - -// The point counter-clockwise to given point -Point* Triangle::PointCW(const Point& point) -{ - if (&point == points_[0]) { - return points_[2]; - } else if (&point == points_[1]) { - return points_[0]; - } else if (&point == points_[2]) { - return points_[1]; - } - assert(0); - return NULL; -} - -// The point counter-clockwise to given point -Point* Triangle::PointCCW(const Point& point) -{ - if (&point == points_[0]) { - return points_[1]; - } else if (&point == points_[1]) { - return points_[2]; - } else if (&point == points_[2]) { - return points_[0]; - } - assert(0); - return NULL; -} - -// The neighbor clockwise to given point -Triangle* Triangle::NeighborCW(const Point& point) -{ - if (&point == points_[0]) { - return neighbors_[1]; - } else if (&point == points_[1]) { - return neighbors_[2]; - } - return neighbors_[0]; -} - -// The neighbor counter-clockwise to given point -Triangle* Triangle::NeighborCCW(const Point& point) -{ - if (&point == points_[0]) { - return neighbors_[2]; - } else if (&point == points_[1]) { - return neighbors_[0]; - } - return neighbors_[1]; -} - -bool Triangle::GetConstrainedEdgeCCW(const Point& p) -{ - if (&p == points_[0]) { - return constrained_edge[2]; - } else if (&p == points_[1]) { - return constrained_edge[0]; - } - return constrained_edge[1]; -} - -bool Triangle::GetConstrainedEdgeCW(const Point& p) -{ - if (&p == points_[0]) { - return constrained_edge[1]; - } else if (&p == points_[1]) { - return constrained_edge[2]; - } - return constrained_edge[0]; -} - -void Triangle::SetConstrainedEdgeCCW(const Point& p, bool ce) -{ - if (&p == points_[0]) { - constrained_edge[2] = ce; - } else if (&p == points_[1]) { - constrained_edge[0] = ce; - } else { - constrained_edge[1] = ce; - } -} - -void Triangle::SetConstrainedEdgeCW(const Point& p, bool ce) -{ - if (&p == points_[0]) { - constrained_edge[1] = ce; - } else if (&p == points_[1]) { - constrained_edge[2] = ce; - } else { - constrained_edge[0] = ce; - } -} - -bool Triangle::GetDelunayEdgeCCW(const Point& p) -{ - if (&p == points_[0]) { - return delaunay_edge[2]; - } else if (&p == points_[1]) { - return delaunay_edge[0]; - } - return delaunay_edge[1]; -} - -bool Triangle::GetDelunayEdgeCW(const Point& p) -{ - if (&p == points_[0]) { - return delaunay_edge[1]; - } else if (&p == points_[1]) { - return delaunay_edge[2]; - } - return delaunay_edge[0]; -} - -void Triangle::SetDelunayEdgeCCW(const Point& p, bool e) -{ - if (&p == points_[0]) { - delaunay_edge[2] = e; - } else if (&p == points_[1]) { - delaunay_edge[0] = e; - } else { - delaunay_edge[1] = e; - } -} - -void Triangle::SetDelunayEdgeCW(const Point& p, bool e) -{ - if (&p == points_[0]) { - delaunay_edge[1] = e; - } else if (&p == points_[1]) { - delaunay_edge[2] = e; - } else { - delaunay_edge[0] = e; - } -} - -// The neighbor across to given point -Triangle& Triangle::NeighborAcross(const Point& opoint) -{ - if (&opoint == points_[0]) { - return *neighbors_[0]; - } else if (&opoint == points_[1]) { - return *neighbors_[1]; - } - return *neighbors_[2]; -} - -void Triangle::DebugPrint() -{ - using namespace std; - cout << points_[0]->x << "," << points_[0]->y << " "; - cout << points_[1]->x << "," << points_[1]->y << " "; - cout << points_[2]->x << "," << points_[2]->y << endl; -} - -} \ No newline at end of file diff --git a/sources/poly2tri/common/shapes.h b/sources/poly2tri/common/shapes.h deleted file mode 100644 index aa582b1d..00000000 --- a/sources/poly2tri/common/shapes.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Include guard -#ifndef SHAPES_H -#define SHAPES_H - -#include -#include -#include -#include - -namespace p2t { - -struct Edge; - -struct Point { - - double x, y; - - /// Default constructor does nothing (for performance). - Point() - { - x = 0.0; - y = 0.0; - } - - /// The edges this point constitutes an upper ending point - std::vector edge_list; - - /// Construct using coordinates. - Point(double x, double y) : x(x), y(y) {} - - /// Set this point to all zeros. - void set_zero() - { - x = 0.0; - y = 0.0; - } - - /// Set this point to some specified coordinates. - void set(double x_, double y_) - { - x = x_; - y = y_; - } - - /// Negate this point. - Point operator -() const - { - Point v; - v.set(-x, -y); - return v; - } - - /// Add a point to this point. - void operator +=(const Point& v) - { - x += v.x; - y += v.y; - } - - /// Subtract a point from this point. - void operator -=(const Point& v) - { - x -= v.x; - y -= v.y; - } - - /// Multiply this point by a scalar. - void operator *=(double a) - { - x *= a; - y *= a; - } - - /// Get the length of this point (the norm). - double Length() const - { - return sqrt(x * x + y * y); - } - - /// Convert this point into a unit point. Returns the Length. - double Normalize() - { - const double len = Length(); - x /= len; - y /= len; - return len; - } - -}; - -// Represents a simple polygon's edge -struct Edge { - - Point* p, *q; - - /// Constructor - Edge(Point& p1, Point& p2) : p(&p1), q(&p2) - { - if (p1.y > p2.y) { - q = &p1; - p = &p2; - } else if (p1.y == p2.y) { - if (p1.x > p2.x) { - q = &p1; - p = &p2; - } else if (p1.x == p2.x) { - // Repeat points - assert(false); - } - } - - q->edge_list.push_back(this); - } -}; - -// Triangle-based data structures are know to have better performance than quad-edge structures -// See: J. Shewchuk, "Triangle: Engineering a 2D Quality Mesh Generator and Delaunay Triangulator" -// "Triangulations in CGAL" -class Triangle { -public: - -/// Constructor -Triangle(Point& a, Point& b, Point& c); - -/// Flags to determine if an edge is a Constrained edge -bool constrained_edge[3]; -/// Flags to determine if an edge is a Delauney edge -bool delaunay_edge[3]; - -Point* GetPoint(int index); -Point* PointCW(const Point& point); -Point* PointCCW(const Point& point); -Point* OppositePoint(Triangle& t, const Point& p); - -Triangle* GetNeighbor(int index); -void MarkNeighbor(Point* p1, Point* p2, Triangle* t); -void MarkNeighbor(Triangle& t); - -void MarkConstrainedEdge(int index); -void MarkConstrainedEdge(Edge& edge); -void MarkConstrainedEdge(Point* p, Point* q); - -int Index(const Point* p); -int EdgeIndex(const Point* p1, const Point* p2); - -Triangle* NeighborCW(const Point& point); -Triangle* NeighborCCW(const Point& point); -bool GetConstrainedEdgeCCW(const Point& p); -bool GetConstrainedEdgeCW(const Point& p); -void SetConstrainedEdgeCCW(const Point& p, bool ce); -void SetConstrainedEdgeCW(const Point& p, bool ce); -bool GetDelunayEdgeCCW(const Point& p); -bool GetDelunayEdgeCW(const Point& p); -void SetDelunayEdgeCCW(const Point& p, bool e); -void SetDelunayEdgeCW(const Point& p, bool e); - -bool Contains(const Point* p); -bool Contains(const Edge& e); -bool Contains(const Point* p, const Point* q); -void Legalize(Point& point); -void Legalize(Point& opoint, Point& npoint); -/** - * Clears all references to all other triangles and points - */ -void Clear(); -void ClearNeighbor(const Triangle *triangle); -void ClearNeighbors(); -void ClearDelunayEdges(); - -inline bool IsInterior(); -inline void IsInterior(bool b); - -Triangle& NeighborAcross(const Point& opoint); - -void DebugPrint(); - -private: - -/// Triangle points -Point* points_[3]; -/// Neighbor list -Triangle* neighbors_[3]; - -/// Has this triangle been marked as an interior triangle? -bool interior_; -}; - -inline bool cmp(const Point* a, const Point* b) -{ - if (a->y < b->y) { - return true; - } else if (a->y == b->y) { - // Make sure q is point with greater x value - if (a->x < b->x) { - return true; - } - } - return false; -} - -/// Add two points_ component-wise. -inline Point operator +(const Point& a, const Point& b) -{ - return Point(a.x + b.x, a.y + b.y); -} - -/// Subtract two points_ component-wise. -inline Point operator -(const Point& a, const Point& b) -{ - return Point(a.x - b.x, a.y - b.y); -} - -/// Multiply point by scalar -inline Point operator *(double s, const Point& a) -{ - return Point(s * a.x, s * a.y); -} - -inline bool operator ==(const Point& a, const Point& b) -{ - return a.x == b.x && a.y == b.y; -} - -inline bool operator !=(const Point& a, const Point& b) -{ - return !(a.x == b.x) && !(a.y == b.y); -} - -/// Peform the dot product on two vectors. -inline double Dot(const Point& a, const Point& b) -{ - return a.x * b.x + a.y * b.y; -} - -/// Perform the cross product on two vectors. In 2D this produces a scalar. -inline double Cross(const Point& a, const Point& b) -{ - return a.x * b.y - a.y * b.x; -} - -/// Perform the cross product on a point and a scalar. In 2D this produces -/// a point. -inline Point Cross(const Point& a, double s) -{ - return Point(s * a.y, -s * a.x); -} - -/// Perform the cross product on a scalar and a point. In 2D this produces -/// a point. -inline Point Cross(double s, const Point& a) -{ - return Point(-s * a.y, s * a.x); -} - -inline Point* Triangle::GetPoint(int index) -{ - return points_[index]; -} - -inline Triangle* Triangle::GetNeighbor(int index) -{ - return neighbors_[index]; -} - -inline bool Triangle::Contains(const Point* p) -{ - return p == points_[0] || p == points_[1] || p == points_[2]; -} - -inline bool Triangle::Contains(const Edge& e) -{ - return Contains(e.p) && Contains(e.q); -} - -inline bool Triangle::Contains(const Point* p, const Point* q) -{ - return Contains(p) && Contains(q); -} - -inline bool Triangle::IsInterior() -{ - return interior_; -} - -inline void Triangle::IsInterior(bool b) -{ - interior_ = b; -} - -} - -#endif \ No newline at end of file diff --git a/sources/poly2tri/common/utils.h b/sources/poly2tri/common/utils.h deleted file mode 100644 index 2424c712..00000000 --- a/sources/poly2tri/common/utils.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef UTILS_H -#define UTILS_H - -// Otherwise #defines like M_PI are undeclared under Visual Studio -#define _USE_MATH_DEFINES - -#include -#include - -// C99 removes M_PI from math.h -#ifndef M_PI -#define M_PI 3.14159265358979323846264338327 -#endif - -namespace p2t { - -const double PI_3div4 = 3 * M_PI / 4; -const double PI_div2 = 1.57079632679489661923; -const double EPSILON = 1e-12; - -enum Orientation { CW, CCW, COLLINEAR }; - -/** - * Forumla to calculate signed area
- * Positive if CCW
- * Negative if CW
- * 0 if collinear
- *
- * A[P1,P2,P3]  =  (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
- *              =  (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
- * 
- */ -Orientation Orient2d(const Point& pa, const Point& pb, const Point& pc) -{ - double detleft = (pa.x - pc.x) * (pb.y - pc.y); - double detright = (pa.y - pc.y) * (pb.x - pc.x); - double val = detleft - detright; - if (val > -EPSILON && val < EPSILON) { - return COLLINEAR; - } else if (val > 0) { - return CCW; - } - return CW; -} - -/* -bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd) -{ - double pdx = pd.x; - double pdy = pd.y; - double adx = pa.x - pdx; - double ady = pa.y - pdy; - double bdx = pb.x - pdx; - double bdy = pb.y - pdy; - - double adxbdy = adx * bdy; - double bdxady = bdx * ady; - double oabd = adxbdy - bdxady; - - if (oabd <= EPSILON) { - return false; - } - - double cdx = pc.x - pdx; - double cdy = pc.y - pdy; - - double cdxady = cdx * ady; - double adxcdy = adx * cdy; - double ocad = cdxady - adxcdy; - - if (ocad <= EPSILON) { - return false; - } - - return true; -} - -*/ - -bool InScanArea(const Point& pa, const Point& pb, const Point& pc, const Point& pd) -{ - double oadb = (pa.x - pb.x)*(pd.y - pb.y) - (pd.x - pb.x)*(pa.y - pb.y); - if (oadb >= -EPSILON) { - return false; - } - - double oadc = (pa.x - pc.x)*(pd.y - pc.y) - (pd.x - pc.x)*(pa.y - pc.y); - if (oadc <= EPSILON) { - return false; - } - return true; -} - -} - -#endif diff --git a/sources/poly2tri/poly2tri.h b/sources/poly2tri/poly2tri.h deleted file mode 100644 index 29a08d05..00000000 --- a/sources/poly2tri/poly2tri.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef POLY2TRI_H -#define POLY2TRI_H - -#include "common/shapes.h" -#include "sweep/cdt.h" - -#endif \ No newline at end of file diff --git a/sources/poly2tri/sweep/advancing_front.cc b/sources/poly2tri/sweep/advancing_front.cc deleted file mode 100644 index 38723bee..00000000 --- a/sources/poly2tri/sweep/advancing_front.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "advancing_front.h" - -namespace p2t { - -AdvancingFront::AdvancingFront(Node& head, Node& tail) -{ - head_ = &head; - tail_ = &tail; - search_node_ = &head; -} - -Node* AdvancingFront::LocateNode(double x) -{ - Node* node = search_node_; - - if (x < node->value) { - while ((node = node->prev) != NULL) { - if (x >= node->value) { - search_node_ = node; - return node; - } - } - } else { - while ((node = node->next) != NULL) { - if (x < node->value) { - search_node_ = node->prev; - return node->prev; - } - } - } - return NULL; -} - -Node* AdvancingFront::FindSearchNode(double x) -{ - (void)x; // suppress compiler warnings "unused parameter 'x'" - // TODO: implement BST index - return search_node_; -} - -Node* AdvancingFront::LocatePoint(const Point* point) -{ - const double px = point->x; - Node* node = FindSearchNode(px); - const double nx = node->point->x; - - if (px == nx) { - if (point != node->point) { - // We might have two nodes with same x value for a short time - if (point == node->prev->point) { - node = node->prev; - } else if (point == node->next->point) { - node = node->next; - } else { - assert(0); - } - } - } else if (px < nx) { - while ((node = node->prev) != NULL) { - if (point == node->point) { - break; - } - } - } else { - while ((node = node->next) != NULL) { - if (point == node->point) - break; - } - } - if(node) search_node_ = node; - return node; -} - -AdvancingFront::~AdvancingFront() -{ -} - -} \ No newline at end of file diff --git a/sources/poly2tri/sweep/advancing_front.h b/sources/poly2tri/sweep/advancing_front.h deleted file mode 100644 index 645dcec9..00000000 --- a/sources/poly2tri/sweep/advancing_front.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ADVANCED_FRONT_H -#define ADVANCED_FRONT_H - -#include "../common/shapes.h" - -namespace p2t { - -struct Node; - -// Advancing front node -struct Node { - Point* point; - Triangle* triangle; - - Node* next; - Node* prev; - - double value; - - Node(Point& p) : point(&p), triangle(NULL), next(NULL), prev(NULL), value(p.x) - { - } - - Node(Point& p, Triangle& t) : point(&p), triangle(&t), next(NULL), prev(NULL), value(p.x) - { - } - -}; - -// Advancing front -class AdvancingFront { -public: - -AdvancingFront(Node& head, Node& tail); -// Destructor -~AdvancingFront(); - -Node* head(); -void set_head(Node* node); -Node* tail(); -void set_tail(Node* node); -Node* search(); -void set_search(Node* node); - -/// Locate insertion point along advancing front -Node* LocateNode(double x); - -Node* LocatePoint(const Point* point); - -private: - -Node* head_, *tail_, *search_node_; - -Node* FindSearchNode(double x); -}; - -inline Node* AdvancingFront::head() -{ - return head_; -} -inline void AdvancingFront::set_head(Node* node) -{ - head_ = node; -} - -inline Node* AdvancingFront::tail() -{ - return tail_; -} -inline void AdvancingFront::set_tail(Node* node) -{ - tail_ = node; -} - -inline Node* AdvancingFront::search() -{ - return search_node_; -} - -inline void AdvancingFront::set_search(Node* node) -{ - search_node_ = node; -} - -} - -#endif \ No newline at end of file diff --git a/sources/poly2tri/sweep/cdt.cc b/sources/poly2tri/sweep/cdt.cc deleted file mode 100644 index 09d088ae..00000000 --- a/sources/poly2tri/sweep/cdt.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "cdt.h" - -namespace p2t { - -CDT::CDT(const std::vector& polyline) -{ - sweep_context_ = new SweepContext(polyline); - sweep_ = new Sweep; -} - -void CDT::AddHole(const std::vector& polyline) -{ - sweep_context_->AddHole(polyline); -} - -void CDT::AddPoint(Point* point) { - sweep_context_->AddPoint(point); -} - -void CDT::Triangulate() -{ - sweep_->Triangulate(*sweep_context_); -} - -std::vector CDT::GetTriangles() -{ - return sweep_context_->GetTriangles(); -} - -std::list CDT::GetMap() -{ - return sweep_context_->GetMap(); -} - -CDT::~CDT() -{ - delete sweep_context_; - delete sweep_; -} - -} \ No newline at end of file diff --git a/sources/poly2tri/sweep/cdt.h b/sources/poly2tri/sweep/cdt.h deleted file mode 100644 index ea3286d9..00000000 --- a/sources/poly2tri/sweep/cdt.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef CDT_H -#define CDT_H - -#include "advancing_front.h" -#include "sweep_context.h" -#include "sweep.h" - -/** - * - * @author Mason Green - * - */ - -namespace p2t { - -class CDT -{ -public: - - /** - * Constructor - add polyline with non repeating points - * - * @param polyline - */ - CDT(const std::vector& polyline); - - /** - * Destructor - clean up memory - */ - ~CDT(); - - /** - * Add a hole - * - * @param polyline - */ - void AddHole(const std::vector& polyline); - - /** - * Add a steiner point - * - * @param point - */ - void AddPoint(Point* point); - - /** - * Triangulate - do this AFTER you've added the polyline, holes, and Steiner points - */ - void Triangulate(); - - /** - * Get CDT triangles - */ - std::vector GetTriangles(); - - /** - * Get triangle map - */ - std::list GetMap(); - - private: - - /** - * Internals - */ - - SweepContext* sweep_context_; - Sweep* sweep_; - -}; - -} - -#endif \ No newline at end of file diff --git a/sources/poly2tri/sweep/sweep.cc b/sources/poly2tri/sweep/sweep.cc deleted file mode 100644 index e31ffdec..00000000 --- a/sources/poly2tri/sweep/sweep.cc +++ /dev/null @@ -1,794 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include "sweep.h" -#include "sweep_context.h" -#include "advancing_front.h" -#include "../common/utils.h" - -namespace p2t { - -// Triangulate simple polygon with holes -void Sweep::Triangulate(SweepContext& tcx) -{ - tcx.InitTriangulation(); - tcx.CreateAdvancingFront(nodes_); - // Sweep points; build mesh - SweepPoints(tcx); - // Clean up - FinalizationPolygon(tcx); -} - -void Sweep::SweepPoints(SweepContext& tcx) -{ - for (size_t i = 1; i < tcx.point_count(); i++) { - Point& point = *tcx.GetPoint(i); - Node* node = &PointEvent(tcx, point); - for (unsigned int i = 0; i < point.edge_list.size(); i++) { - EdgeEvent(tcx, point.edge_list[i], node); - } - } -} - -void Sweep::FinalizationPolygon(SweepContext& tcx) -{ - // Get an Internal triangle to start with - Triangle* t = tcx.front()->head()->next->triangle; - Point* p = tcx.front()->head()->next->point; - while (!t->GetConstrainedEdgeCW(*p)) { - t = t->NeighborCCW(*p); - } - - // Collect interior triangles constrained by edges - tcx.MeshClean(*t); -} - -Node& Sweep::PointEvent(SweepContext& tcx, Point& point) -{ - Node& node = tcx.LocateNode(point); - Node& new_node = NewFrontTriangle(tcx, point, node); - - // Only need to check +epsilon since point never have smaller - // x value than node due to how we fetch nodes from the front - if (point.x <= node.point->x + EPSILON) { - Fill(tcx, node); - } - - //tcx.AddNode(new_node); - - FillAdvancingFront(tcx, new_node); - return new_node; -} - -void Sweep::EdgeEvent(SweepContext& tcx, Edge* edge, Node* node) -{ - tcx.edge_event.constrained_edge = edge; - tcx.edge_event.right = (edge->p->x > edge->q->x); - - if (IsEdgeSideOfTriangle(*node->triangle, *edge->p, *edge->q)) { - return; - } - - // For now we will do all needed filling - // TODO: integrate with flip process might give some better performance - // but for now this avoid the issue with cases that needs both flips and fills - FillEdgeEvent(tcx, edge, node); - EdgeEvent(tcx, *edge->p, *edge->q, node->triangle, *edge->q); -} - -void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Point& point) -{ - if (IsEdgeSideOfTriangle(*triangle, ep, eq)) { - return; - } - - Point* p1 = triangle->PointCCW(point); - Orientation o1 = Orient2d(eq, *p1, ep); - if (o1 == COLLINEAR) { - if( triangle->Contains(&eq, p1)) { - triangle->MarkConstrainedEdge(&eq, p1 ); - // We are modifying the constraint maybe it would be better to - // not change the given constraint and just keep a variable for the new constraint - tcx.edge_event.constrained_edge->q = p1; - triangle = &triangle->NeighborAcross(point); - EdgeEvent( tcx, ep, *p1, triangle, *p1 ); - } else { - std::runtime_error("EdgeEvent - collinear points not supported"); - assert(0); - } - return; - } - - Point* p2 = triangle->PointCW(point); - Orientation o2 = Orient2d(eq, *p2, ep); - if (o2 == COLLINEAR) { - if( triangle->Contains(&eq, p2)) { - triangle->MarkConstrainedEdge(&eq, p2 ); - // We are modifying the constraint maybe it would be better to - // not change the given constraint and just keep a variable for the new constraint - tcx.edge_event.constrained_edge->q = p2; - triangle = &triangle->NeighborAcross(point); - EdgeEvent( tcx, ep, *p2, triangle, *p2 ); - } else { - std::runtime_error("EdgeEvent - collinear points not supported"); - assert(0); - } - return; - } - - if (o1 == o2) { - // Need to decide if we are rotating CW or CCW to get to a triangle - // that will cross edge - if (o1 == CW) { - triangle = triangle->NeighborCCW(point); - } else{ - triangle = triangle->NeighborCW(point); - } - EdgeEvent(tcx, ep, eq, triangle, point); - } else { - // This triangle crosses constraint so lets flippin start! - FlipEdgeEvent(tcx, ep, eq, triangle, point); - } -} - -bool Sweep::IsEdgeSideOfTriangle(Triangle& triangle, Point& ep, Point& eq) -{ - const int index = triangle.EdgeIndex(&ep, &eq); - - if (index != -1) { - triangle.MarkConstrainedEdge(index); - Triangle* t = triangle.GetNeighbor(index); - if (t) { - t->MarkConstrainedEdge(&ep, &eq); - } - return true; - } - return false; -} - -Node& Sweep::NewFrontTriangle(SweepContext& tcx, Point& point, Node& node) -{ - Triangle* triangle = new Triangle(point, *node.point, *node.next->point); - - triangle->MarkNeighbor(*node.triangle); - tcx.AddToMap(triangle); - - Node* new_node = new Node(point); - nodes_.push_back(new_node); - - new_node->next = node.next; - new_node->prev = &node; - node.next->prev = new_node; - node.next = new_node; - - if (!Legalize(tcx, *triangle)) { - tcx.MapTriangleToNodes(*triangle); - } - - return *new_node; -} - -void Sweep::Fill(SweepContext& tcx, Node& node) -{ - Triangle* triangle = new Triangle(*node.prev->point, *node.point, *node.next->point); - - // TODO: should copy the constrained_edge value from neighbor triangles - // for now constrained_edge values are copied during the legalize - triangle->MarkNeighbor(*node.prev->triangle); - triangle->MarkNeighbor(*node.triangle); - - tcx.AddToMap(triangle); - - // Update the advancing front - node.prev->next = node.next; - node.next->prev = node.prev; - - // If it was legalized the triangle has already been mapped - if (!Legalize(tcx, *triangle)) { - tcx.MapTriangleToNodes(*triangle); - } - -} - -void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n) -{ - - // Fill right holes - Node* node = n.next; - - while (node->next) { - // if HoleAngle exceeds 90 degrees then break. - if (LargeHole_DontFill(node)) break; - Fill(tcx, *node); - node = node->next; - } - - // Fill left holes - node = n.prev; - - while (node->prev) { - // if HoleAngle exceeds 90 degrees then break. - if (LargeHole_DontFill(node)) break; - Fill(tcx, *node); - node = node->prev; - } - - // Fill right basins - if (n.next && n.next->next) { - const double angle = BasinAngle(n); - if (angle < PI_3div4) { - FillBasin(tcx, n); - } - } -} - -// True if HoleAngle exceeds 90 degrees. -bool Sweep::LargeHole_DontFill(const Node* node) const { - - const Node* nextNode = node->next; - const Node* prevNode = node->prev; - if (!AngleExceeds90Degrees(node->point, nextNode->point, prevNode->point)) - return false; - - // Check additional points on front. - const Node* next2Node = nextNode->next; - // "..Plus.." because only want angles on same side as point being added. - if ((next2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, next2Node->point, prevNode->point)) - return false; - - const Node* prev2Node = prevNode->prev; - // "..Plus.." because only want angles on same side as point being added. - if ((prev2Node != NULL) && !AngleExceedsPlus90DegreesOrIsNegative(node->point, nextNode->point, prev2Node->point)) - return false; - - return true; -} - -bool Sweep::AngleExceeds90Degrees(const Point* origin, const Point* pa, const Point* pb) const { - const double angle = Angle(origin, pa, pb); - return ((angle > PI_div2) || (angle < -PI_div2)); -} - -bool Sweep::AngleExceedsPlus90DegreesOrIsNegative(const Point* origin, const Point* pa, const Point* pb) const { - const double angle = Angle(origin, pa, pb); - return (angle > PI_div2) || (angle < 0); -} - -double Sweep::Angle(const Point* origin, const Point* pa, const Point* pb) const { - /* Complex plane - * ab = cosA +i*sinA - * ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx) - * atan2(y,x) computes the principal value of the argument function - * applied to the complex number x+iy - * Where x = ax*bx + ay*by - * y = ax*by - ay*bx - */ - const double px = origin->x; - const double py = origin->y; - const double ax = pa->x- px; - const double ay = pa->y - py; - const double bx = pb->x - px; - const double by = pb->y - py; - const double x = ax * by - ay * bx; - const double y = ax * bx + ay * by; - return atan2(x, y); -} - -double Sweep::BasinAngle(const Node& node) const -{ - const double ax = node.point->x - node.next->next->point->x; - const double ay = node.point->y - node.next->next->point->y; - return atan2(ay, ax); -} - -double Sweep::HoleAngle(const Node& node) const -{ - /* Complex plane - * ab = cosA +i*sinA - * ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx) - * atan2(y,x) computes the principal value of the argument function - * applied to the complex number x+iy - * Where x = ax*bx + ay*by - * y = ax*by - ay*bx - */ - const double ax = node.next->point->x - node.point->x; - const double ay = node.next->point->y - node.point->y; - const double bx = node.prev->point->x - node.point->x; - const double by = node.prev->point->y - node.point->y; - return atan2(ax * by - ay * bx, ax * bx + ay * by); -} - -bool Sweep::Legalize(SweepContext& tcx, Triangle& t) -{ - // To legalize a triangle we start by finding if any of the three edges - // violate the Delaunay condition - for (int i = 0; i < 3; i++) { - if (t.delaunay_edge[i]) - continue; - - Triangle* ot = t.GetNeighbor(i); - - if (ot) { - Point* p = t.GetPoint(i); - Point* op = ot->OppositePoint(t, *p); - int oi = ot->Index(op); - - // If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization) - // then we should not try to legalize - if (ot->constrained_edge[oi] || ot->delaunay_edge[oi]) { - t.constrained_edge[i] = ot->constrained_edge[oi]; - continue; - } - - bool inside = Incircle(*p, *t.PointCCW(*p), *t.PointCW(*p), *op); - - if (inside) { - // Lets mark this shared edge as Delaunay - t.delaunay_edge[i] = true; - ot->delaunay_edge[oi] = true; - - // Lets rotate shared edge one vertex CW to legalize it - RotateTrianglePair(t, *p, *ot, *op); - - // We now got one valid Delaunay Edge shared by two triangles - // This gives us 4 new edges to check for Delaunay - - // Make sure that triangle to node mapping is done only one time for a specific triangle - bool not_legalized = !Legalize(tcx, t); - if (not_legalized) { - tcx.MapTriangleToNodes(t); - } - - not_legalized = !Legalize(tcx, *ot); - if (not_legalized) - tcx.MapTriangleToNodes(*ot); - - // Reset the Delaunay edges, since they only are valid Delaunay edges - // until we add a new triangle or point. - // XXX: need to think about this. Can these edges be tried after we - // return to previous recursive level? - t.delaunay_edge[i] = false; - ot->delaunay_edge[oi] = false; - - // If triangle have been legalized no need to check the other edges since - // the recursive legalization will handles those so we can end here. - return true; - } - } - } - return false; -} - -bool Sweep::Incircle(const Point& pa, const Point& pb, const Point& pc, const Point& pd) const -{ - const double adx = pa.x - pd.x; - const double ady = pa.y - pd.y; - const double bdx = pb.x - pd.x; - const double bdy = pb.y - pd.y; - - const double adxbdy = adx * bdy; - const double bdxady = bdx * ady; - const double oabd = adxbdy - bdxady; - - if (oabd <= 0) - return false; - - const double cdx = pc.x - pd.x; - const double cdy = pc.y - pd.y; - - const double cdxady = cdx * ady; - const double adxcdy = adx * cdy; - const double ocad = cdxady - adxcdy; - - if (ocad <= 0) - return false; - - const double bdxcdy = bdx * cdy; - const double cdxbdy = cdx * bdy; - - const double alift = adx * adx + ady * ady; - const double blift = bdx * bdx + bdy * bdy; - const double clift = cdx * cdx + cdy * cdy; - - const double det = alift * (bdxcdy - cdxbdy) + blift * ocad + clift * oabd; - - return det > 0; -} - -void Sweep::RotateTrianglePair(Triangle& t, Point& p, Triangle& ot, Point& op) const -{ - Triangle* n1, *n2, *n3, *n4; - n1 = t.NeighborCCW(p); - n2 = t.NeighborCW(p); - n3 = ot.NeighborCCW(op); - n4 = ot.NeighborCW(op); - - bool ce1, ce2, ce3, ce4; - ce1 = t.GetConstrainedEdgeCCW(p); - ce2 = t.GetConstrainedEdgeCW(p); - ce3 = ot.GetConstrainedEdgeCCW(op); - ce4 = ot.GetConstrainedEdgeCW(op); - - bool de1, de2, de3, de4; - de1 = t.GetDelunayEdgeCCW(p); - de2 = t.GetDelunayEdgeCW(p); - de3 = ot.GetDelunayEdgeCCW(op); - de4 = ot.GetDelunayEdgeCW(op); - - t.Legalize(p, op); - ot.Legalize(op, p); - - // Remap delaunay_edge - ot.SetDelunayEdgeCCW(p, de1); - t.SetDelunayEdgeCW(p, de2); - t.SetDelunayEdgeCCW(op, de3); - ot.SetDelunayEdgeCW(op, de4); - - // Remap constrained_edge - ot.SetConstrainedEdgeCCW(p, ce1); - t.SetConstrainedEdgeCW(p, ce2); - t.SetConstrainedEdgeCCW(op, ce3); - ot.SetConstrainedEdgeCW(op, ce4); - - // Remap neighbors - // XXX: might optimize the markNeighbor by keeping track of - // what side should be assigned to what neighbor after the - // rotation. Now mark neighbor does lots of testing to find - // the right side. - t.ClearNeighbors(); - ot.ClearNeighbors(); - if (n1) ot.MarkNeighbor(*n1); - if (n2) t.MarkNeighbor(*n2); - if (n3) t.MarkNeighbor(*n3); - if (n4) ot.MarkNeighbor(*n4); - t.MarkNeighbor(ot); -} - -void Sweep::FillBasin(SweepContext& tcx, Node& node) -{ - if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) { - tcx.basin.left_node = node.next->next; - } else { - tcx.basin.left_node = node.next; - } - - // Find the bottom and right node - tcx.basin.bottom_node = tcx.basin.left_node; - while (tcx.basin.bottom_node->next - && tcx.basin.bottom_node->point->y >= tcx.basin.bottom_node->next->point->y) { - tcx.basin.bottom_node = tcx.basin.bottom_node->next; - } - if (tcx.basin.bottom_node == tcx.basin.left_node) { - // No valid basin - return; - } - - tcx.basin.right_node = tcx.basin.bottom_node; - while (tcx.basin.right_node->next - && tcx.basin.right_node->point->y < tcx.basin.right_node->next->point->y) { - tcx.basin.right_node = tcx.basin.right_node->next; - } - if (tcx.basin.right_node == tcx.basin.bottom_node) { - // No valid basins - return; - } - - tcx.basin.width = tcx.basin.right_node->point->x - tcx.basin.left_node->point->x; - tcx.basin.left_highest = tcx.basin.left_node->point->y > tcx.basin.right_node->point->y; - - FillBasinReq(tcx, tcx.basin.bottom_node); -} - -void Sweep::FillBasinReq(SweepContext& tcx, Node* node) -{ - // if shallow stop filling - if (IsShallow(tcx, *node)) { - return; - } - - Fill(tcx, *node); - - if (node->prev == tcx.basin.left_node && node->next == tcx.basin.right_node) { - return; - } else if (node->prev == tcx.basin.left_node) { - Orientation o = Orient2d(*node->point, *node->next->point, *node->next->next->point); - if (o == CW) { - return; - } - node = node->next; - } else if (node->next == tcx.basin.right_node) { - Orientation o = Orient2d(*node->point, *node->prev->point, *node->prev->prev->point); - if (o == CCW) { - return; - } - node = node->prev; - } else { - // Continue with the neighbor node with lowest Y value - if (node->prev->point->y < node->next->point->y) { - node = node->prev; - } else { - node = node->next; - } - } - - FillBasinReq(tcx, node); -} - -bool Sweep::IsShallow(SweepContext& tcx, Node& node) -{ - double height; - - if (tcx.basin.left_highest) { - height = tcx.basin.left_node->point->y - node.point->y; - } else { - height = tcx.basin.right_node->point->y - node.point->y; - } - - // if shallow stop filling - if (tcx.basin.width > height) { - return true; - } - return false; -} - -void Sweep::FillEdgeEvent(SweepContext& tcx, Edge* edge, Node* node) -{ - if (tcx.edge_event.right) { - FillRightAboveEdgeEvent(tcx, edge, node); - } else { - FillLeftAboveEdgeEvent(tcx, edge, node); - } -} - -void Sweep::FillRightAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node) -{ - while (node->next->point->x < edge->p->x) { - // Check if next node is below the edge - if (Orient2d(*edge->q, *node->next->point, *edge->p) == CCW) { - FillRightBelowEdgeEvent(tcx, edge, *node); - } else { - node = node->next; - } - } -} - -void Sweep::FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) -{ - if (node.point->x < edge->p->x) { - if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) { - // Concave - FillRightConcaveEdgeEvent(tcx, edge, node); - } else{ - // Convex - FillRightConvexEdgeEvent(tcx, edge, node); - // Retry this one - FillRightBelowEdgeEvent(tcx, edge, node); - } - } -} - -void Sweep::FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) -{ - Fill(tcx, *node.next); - if (node.next->point != edge->p) { - // Next above or below edge? - if (Orient2d(*edge->q, *node.next->point, *edge->p) == CCW) { - // Below - if (Orient2d(*node.point, *node.next->point, *node.next->next->point) == CCW) { - // Next is concave - FillRightConcaveEdgeEvent(tcx, edge, node); - } else { - // Next is convex - } - } - } - -} - -void Sweep::FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) -{ - // Next concave or convex? - if (Orient2d(*node.next->point, *node.next->next->point, *node.next->next->next->point) == CCW) { - // Concave - FillRightConcaveEdgeEvent(tcx, edge, *node.next); - } else{ - // Convex - // Next above or below edge? - if (Orient2d(*edge->q, *node.next->next->point, *edge->p) == CCW) { - // Below - FillRightConvexEdgeEvent(tcx, edge, *node.next); - } else{ - // Above - } - } -} - -void Sweep::FillLeftAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node) -{ - while (node->prev->point->x > edge->p->x) { - // Check if next node is below the edge - if (Orient2d(*edge->q, *node->prev->point, *edge->p) == CW) { - FillLeftBelowEdgeEvent(tcx, edge, *node); - } else { - node = node->prev; - } - } -} - -void Sweep::FillLeftBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) -{ - if (node.point->x > edge->p->x) { - if (Orient2d(*node.point, *node.prev->point, *node.prev->prev->point) == CW) { - // Concave - FillLeftConcaveEdgeEvent(tcx, edge, node); - } else { - // Convex - FillLeftConvexEdgeEvent(tcx, edge, node); - // Retry this one - FillLeftBelowEdgeEvent(tcx, edge, node); - } - } -} - -void Sweep::FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) -{ - // Next concave or convex? - if (Orient2d(*node.prev->point, *node.prev->prev->point, *node.prev->prev->prev->point) == CW) { - // Concave - FillLeftConcaveEdgeEvent(tcx, edge, *node.prev); - } else{ - // Convex - // Next above or below edge? - if (Orient2d(*edge->q, *node.prev->prev->point, *edge->p) == CW) { - // Below - FillLeftConvexEdgeEvent(tcx, edge, *node.prev); - } else{ - // Above - } - } -} - -void Sweep::FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node) -{ - Fill(tcx, *node.prev); - if (node.prev->point != edge->p) { - // Next above or below edge? - if (Orient2d(*edge->q, *node.prev->point, *edge->p) == CW) { - // Below - if (Orient2d(*node.point, *node.prev->point, *node.prev->prev->point) == CW) { - // Next is concave - FillLeftConcaveEdgeEvent(tcx, edge, node); - } else{ - // Next is convex - } - } - } - -} - -void Sweep::FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p) -{ - Triangle& ot = t->NeighborAcross(p); - Point& op = *ot.OppositePoint(*t, p); - - if (InScanArea(p, *t->PointCCW(p), *t->PointCW(p), op)) { - // Lets rotate shared edge one vertex CW - RotateTrianglePair(*t, p, ot, op); - tcx.MapTriangleToNodes(*t); - tcx.MapTriangleToNodes(ot); - - if (p == eq && op == ep) { - if (eq == *tcx.edge_event.constrained_edge->q && ep == *tcx.edge_event.constrained_edge->p) { - t->MarkConstrainedEdge(&ep, &eq); - ot.MarkConstrainedEdge(&ep, &eq); - Legalize(tcx, *t); - Legalize(tcx, ot); - } else { - // XXX: I think one of the triangles should be legalized here? - } - } else { - Orientation o = Orient2d(eq, op, ep); - t = &NextFlipTriangle(tcx, (int)o, *t, ot, p, op); - FlipEdgeEvent(tcx, ep, eq, t, p); - } - } else { - Point& newP = NextFlipPoint(ep, eq, ot, op); - FlipScanEdgeEvent(tcx, ep, eq, *t, ot, newP); - EdgeEvent(tcx, ep, eq, t, p); - } -} - -Triangle& Sweep::NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangle& ot, Point& p, Point& op) -{ - if (o == CCW) { - // ot is not crossing edge after flip - int edge_index = ot.EdgeIndex(&p, &op); - ot.delaunay_edge[edge_index] = true; - Legalize(tcx, ot); - ot.ClearDelunayEdges(); - return t; - } - - // t is not crossing edge after flip - int edge_index = t.EdgeIndex(&p, &op); - - t.delaunay_edge[edge_index] = true; - Legalize(tcx, t); - t.ClearDelunayEdges(); - return ot; -} - -Point& Sweep::NextFlipPoint(Point& ep, Point& eq, Triangle& ot, Point& op) -{ - Orientation o2d = Orient2d(eq, op, ep); - if (o2d == CW) { - // Right - return *ot.PointCCW(op); - } else if (o2d == CCW) { - // Left - return *ot.PointCW(op); - } - throw std::runtime_error("[Unsupported] Opposing point on constrained edge"); -} - -void Sweep::FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& flip_triangle, - Triangle& t, Point& p) -{ - Triangle& ot = t.NeighborAcross(p); - Point& op = *ot.OppositePoint(t, p); - - if (InScanArea(eq, *flip_triangle.PointCCW(eq), *flip_triangle.PointCW(eq), op)) { - // flip with new edge op->eq - FlipEdgeEvent(tcx, eq, op, &ot, op); - // TODO: Actually I just figured out that it should be possible to - // improve this by getting the next ot and op before the the above - // flip and continue the flipScanEdgeEvent here - // set new ot and op here and loop back to inScanArea test - // also need to set a new flip_triangle first - // Turns out at first glance that this is somewhat complicated - // so it will have to wait. - } else{ - Point& newP = NextFlipPoint(ep, eq, ot, op); - FlipScanEdgeEvent(tcx, ep, eq, flip_triangle, ot, newP); - } -} - -Sweep::~Sweep() { - - // Clean up memory - for(size_t i = 0; i < nodes_.size(); i++) { - delete nodes_[i]; - } - -} - -} - diff --git a/sources/poly2tri/sweep/sweep.h b/sources/poly2tri/sweep/sweep.h deleted file mode 100644 index 33e34a71..00000000 --- a/sources/poly2tri/sweep/sweep.h +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V. and - * Zalik, B.(2008)'Sweep-line algorithm for constrained Delaunay triangulation', - * International Journal of Geographical Information Science - * - * "FlipScan" Constrained Edge Algorithm invented by Thomas ?hl?n, thahlen@gmail.com - */ - -#ifndef SWEEP_H -#define SWEEP_H - -#include - -namespace p2t { - -class SweepContext; -struct Node; -struct Point; -struct Edge; -class Triangle; - -class Sweep -{ -public: - - /** - * Triangulate - * - * @param tcx - */ - void Triangulate(SweepContext& tcx); - - /** - * Destructor - clean up memory - */ - ~Sweep(); - -private: - - /** - * Start sweeping the Y-sorted point set from bottom to top - * - * @param tcx - */ - void SweepPoints(SweepContext& tcx); - - /** - * Find closes node to the left of the new point and - * create a new triangle. If needed new holes and basins - * will be filled to. - * - * @param tcx - * @param point - * @return - */ - Node& PointEvent(SweepContext& tcx, Point& point); - - /** - * - * - * @param tcx - * @param edge - * @param node - */ - void EdgeEvent(SweepContext& tcx, Edge* edge, Node* node); - - void EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangle, Point& point); - - /** - * Creates a new front triangle and legalize it - * - * @param tcx - * @param point - * @param node - * @return - */ - Node& NewFrontTriangle(SweepContext& tcx, Point& point, Node& node); - - /** - * Adds a triangle to the advancing front to fill a hole. - * @param tcx - * @param node - middle node, that is the bottom of the hole - */ - void Fill(SweepContext& tcx, Node& node); - - /** - * Returns true if triangle was legalized - */ - bool Legalize(SweepContext& tcx, Triangle& t); - - /** - * Requirement:
- * 1. a,b and c form a triangle.
- * 2. a and d is know to be on opposite side of bc
- *
-   *                a
-   *                +
-   *               / \
-   *              /   \
-   *            b/     \c
-   *            +-------+
-   *           /    d    \
-   *          /           \
-   * 
- * Fact: d has to be in area B to have a chance to be inside the circle formed by - * a,b and c
- * d is outside B if orient2d(a,b,d) or orient2d(c,a,d) is CW
- * This preknowledge gives us a way to optimize the incircle test - * @param a - triangle point, opposite d - * @param b - triangle point - * @param c - triangle point - * @param d - point opposite a - * @return true if d is inside circle, false if on circle edge - */ - bool Incircle(const Point& pa, const Point& pb, const Point& pc, const Point& pd) const; - - /** - * Rotates a triangle pair one vertex CW - *
-   *       n2                    n2
-   *  P +-----+             P +-----+
-   *    | t  /|               |\  t |
-   *    |   / |               | \   |
-   *  n1|  /  |n3           n1|  \  |n3
-   *    | /   |    after CW   |   \ |
-   *    |/ oT |               | oT \|
-   *    +-----+ oP            +-----+
-   *       n4                    n4
-   * 
- */ - void RotateTrianglePair(Triangle& t, Point& p, Triangle& ot, Point& op) const; - - /** - * Fills holes in the Advancing Front - * - * - * @param tcx - * @param n - */ - void FillAdvancingFront(SweepContext& tcx, Node& n); - - // Decision-making about when to Fill hole. - // Contributed by ToolmakerSteve2 - bool LargeHole_DontFill(const Node* node) const; - bool AngleExceeds90Degrees(const Point* origin, const Point* pa, const Point* pb) const; - bool AngleExceedsPlus90DegreesOrIsNegative(const Point* origin, const Point* pa, const Point* pb) const; - double Angle(const Point* origin, const Point* pa, const Point* pb) const; - - /** - * - * @param node - middle node - * @return the angle between 3 front nodes - */ - double HoleAngle(const Node& node) const; - - /** - * The basin angle is decided against the horizontal line [1,0] - */ - double BasinAngle(const Node& node) const; - - /** - * Fills a basin that has formed on the Advancing Front to the right - * of given node.
- * First we decide a left,bottom and right node that forms the - * boundaries of the basin. Then we do a reqursive fill. - * - * @param tcx - * @param node - starting node, this or next node will be left node - */ - void FillBasin(SweepContext& tcx, Node& node); - - /** - * Recursive algorithm to fill a Basin with triangles - * - * @param tcx - * @param node - bottom_node - * @param cnt - counter used to alternate on even and odd numbers - */ - void FillBasinReq(SweepContext& tcx, Node* node); - - bool IsShallow(SweepContext& tcx, Node& node); - - bool IsEdgeSideOfTriangle(Triangle& triangle, Point& ep, Point& eq); - - void FillEdgeEvent(SweepContext& tcx, Edge* edge, Node* node); - - void FillRightAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node); - - void FillRightBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node); - - void FillRightConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node); - - void FillRightConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node); - - void FillLeftAboveEdgeEvent(SweepContext& tcx, Edge* edge, Node* node); - - void FillLeftBelowEdgeEvent(SweepContext& tcx, Edge* edge, Node& node); - - void FillLeftConcaveEdgeEvent(SweepContext& tcx, Edge* edge, Node& node); - - void FillLeftConvexEdgeEvent(SweepContext& tcx, Edge* edge, Node& node); - - void FlipEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* t, Point& p); - - /** - * After a flip we have two triangles and know that only one will still be - * intersecting the edge. So decide which to contiune with and legalize the other - * - * @param tcx - * @param o - should be the result of an orient2d( eq, op, ep ) - * @param t - triangle 1 - * @param ot - triangle 2 - * @param p - a point shared by both triangles - * @param op - another point shared by both triangles - * @return returns the triangle still intersecting the edge - */ - Triangle& NextFlipTriangle(SweepContext& tcx, int o, Triangle& t, Triangle& ot, Point& p, Point& op); - - /** - * When we need to traverse from one triangle to the next we need - * the point in current triangle that is the opposite point to the next - * triangle. - * - * @param ep - * @param eq - * @param ot - * @param op - * @return - */ - Point& NextFlipPoint(Point& ep, Point& eq, Triangle& ot, Point& op); - - /** - * Scan part of the FlipScan algorithm
- * When a triangle pair isn't flippable we will scan for the next - * point that is inside the flip triangle scan area. When found - * we generate a new flipEdgeEvent - * - * @param tcx - * @param ep - last point on the edge we are traversing - * @param eq - first point on the edge we are traversing - * @param flipTriangle - the current triangle sharing the point eq with edge - * @param t - * @param p - */ - void FlipScanEdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle& flip_triangle, Triangle& t, Point& p); - - void FinalizationPolygon(SweepContext& tcx); - - std::vector nodes_; - -}; - -} - -#endif \ No newline at end of file diff --git a/sources/poly2tri/sweep/sweep_context.cc b/sources/poly2tri/sweep/sweep_context.cc deleted file mode 100644 index a9f1fdf8..00000000 --- a/sources/poly2tri/sweep/sweep_context.cc +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include "sweep_context.h" -#include -#include "advancing_front.h" - -namespace p2t { - -SweepContext::SweepContext(const std::vector& polyline) : points_(polyline), - front_(0), - head_(0), - tail_(0), - af_head_(0), - af_middle_(0), - af_tail_(0) -{ - InitEdges(points_); -} - -void SweepContext::AddHole(const std::vector& polyline) -{ - InitEdges(polyline); - for(unsigned int i = 0; i < polyline.size(); i++) { - points_.push_back(polyline[i]); - } -} - -void SweepContext::AddPoint(Point* point) { - points_.push_back(point); -} - -std::vector &SweepContext::GetTriangles() -{ - return triangles_; -} - -std::list &SweepContext::GetMap() -{ - return map_; -} - -void SweepContext::InitTriangulation() -{ - double xmax(points_[0]->x), xmin(points_[0]->x); - double ymax(points_[0]->y), ymin(points_[0]->y); - - // Calculate bounds. - for (unsigned int i = 0; i < points_.size(); i++) { - Point& p = *points_[i]; - if (p.x > xmax) - xmax = p.x; - if (p.x < xmin) - xmin = p.x; - if (p.y > ymax) - ymax = p.y; - if (p.y < ymin) - ymin = p.y; - } - - double dx = kAlpha * (xmax - xmin); - double dy = kAlpha * (ymax - ymin); - head_ = new Point(xmax + dx, ymin - dy); - tail_ = new Point(xmin - dx, ymin - dy); - - // Sort points along y-axis - std::sort(points_.begin(), points_.end(), cmp); - -} - -void SweepContext::InitEdges(const std::vector& polyline) -{ - size_t num_points = polyline.size(); - for (size_t i = 0; i < num_points; i++) { - size_t j = i < num_points - 1 ? i + 1 : 0; - edge_list.push_back(new Edge(*polyline[i], *polyline[j])); - } -} - -Point* SweepContext::GetPoint(size_t index) -{ - return points_[index]; -} - -void SweepContext::AddToMap(Triangle* triangle) -{ - map_.push_back(triangle); -} - -Node& SweepContext::LocateNode(const Point& point) -{ - // TODO implement search tree - return *front_->LocateNode(point.x); -} - -void SweepContext::CreateAdvancingFront(const std::vector& nodes) -{ - - (void) nodes; - // Initial triangle - Triangle* triangle = new Triangle(*points_[0], *tail_, *head_); - - map_.push_back(triangle); - - af_head_ = new Node(*triangle->GetPoint(1), *triangle); - af_middle_ = new Node(*triangle->GetPoint(0), *triangle); - af_tail_ = new Node(*triangle->GetPoint(2)); - front_ = new AdvancingFront(*af_head_, *af_tail_); - - // TODO: More intuitive if head is middles next and not previous? - // so swap head and tail - af_head_->next = af_middle_; - af_middle_->next = af_tail_; - af_middle_->prev = af_head_; - af_tail_->prev = af_middle_; -} - -void SweepContext::RemoveNode(Node* node) -{ - delete node; -} - -void SweepContext::MapTriangleToNodes(Triangle& t) -{ - for (int i = 0; i < 3; i++) { - if (!t.GetNeighbor(i)) { - Node* n = front_->LocatePoint(t.PointCW(*t.GetPoint(i))); - if (n) - n->triangle = &t; - } - } -} - -void SweepContext::RemoveFromMap(Triangle* triangle) -{ - map_.remove(triangle); -} - -void SweepContext::MeshClean(Triangle& triangle) -{ - std::vector triangles; - triangles.push_back(&triangle); - - while(!triangles.empty()){ - Triangle *t = triangles.back(); - triangles.pop_back(); - - if (t != NULL && !t->IsInterior()) { - t->IsInterior(true); - triangles_.push_back(t); - for (int i = 0; i < 3; i++) { - if (!t->constrained_edge[i]) - triangles.push_back(t->GetNeighbor(i)); - } - } - } -} - -SweepContext::~SweepContext() -{ - - // Clean up memory - - delete head_; - delete tail_; - delete front_; - delete af_head_; - delete af_middle_; - delete af_tail_; - - typedef std::list type_list; - - for(type_list::iterator iter = map_.begin(); iter != map_.end(); ++iter) { - Triangle* ptr = *iter; - delete ptr; - } - - for(unsigned int i = 0; i < edge_list.size(); i++) { - delete edge_list[i]; - } - -} - -} diff --git a/sources/poly2tri/sweep/sweep_context.h b/sources/poly2tri/sweep/sweep_context.h deleted file mode 100644 index ba0d0658..00000000 --- a/sources/poly2tri/sweep/sweep_context.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors - * http://code.google.com/p/poly2tri/ - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Poly2Tri nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef SWEEP_CONTEXT_H -#define SWEEP_CONTEXT_H - -#include -#include -#include - -namespace p2t { - -// Inital triangle factor, seed triangle will extend 30% of -// PointSet width to both left and right. -const double kAlpha = 0.3; - -struct Point; -class Triangle; -struct Node; -struct Edge; -class AdvancingFront; - -class SweepContext { -public: - -/// Constructor -SweepContext(const std::vector& polyline); -/// Destructor -~SweepContext(); - -void set_head(Point* p1); - -Point* head() const; - -void set_tail(Point* p1); - -Point* tail() const; - -size_t point_count() const; - -Node& LocateNode(const Point& point); - -void RemoveNode(Node* node); - -void CreateAdvancingFront(const std::vector& nodes); - -/// Try to map a node to all sides of this triangle that don't have a neighbor -void MapTriangleToNodes(Triangle& t); - -void AddToMap(Triangle* triangle); - -Point* GetPoint(size_t index); - -Point* GetPoints(); - -void RemoveFromMap(Triangle* triangle); - -void AddHole(const std::vector& polyline); - -void AddPoint(Point* point); - -AdvancingFront* front() const; - -void MeshClean(Triangle& triangle); - -std::vector &GetTriangles(); -std::list &GetMap(); - -std::vector edge_list; - -struct Basin { - Node* left_node; - Node* bottom_node; - Node* right_node; - double width; - bool left_highest; - - Basin() : left_node(NULL), bottom_node(NULL), right_node(NULL), width(0.0), left_highest(false) - { - } - - void Clear() - { - left_node = NULL; - bottom_node = NULL; - right_node = NULL; - width = 0.0; - left_highest = false; - } -}; - -struct EdgeEvent { - Edge* constrained_edge; - bool right; - - EdgeEvent() : constrained_edge(NULL), right(false) - { - } -}; - -Basin basin; -EdgeEvent edge_event; - -private: - -friend class Sweep; - -std::vector triangles_; -std::list map_; -std::vector points_; - -// Advancing front -AdvancingFront* front_; -// head point used with advancing front -Point* head_; -// tail point used with advancing front -Point* tail_; - -Node *af_head_, *af_middle_, *af_tail_; - -void InitTriangulation(); -void InitEdges(const std::vector& polyline); - -}; - -inline AdvancingFront* SweepContext::front() const -{ - return front_; -} - -inline size_t SweepContext::point_count() const -{ - return points_.size(); -} - -inline void SweepContext::set_head(Point* p1) -{ - head_ = p1; -} - -inline Point* SweepContext::head() const -{ - return head_; -} - -inline void SweepContext::set_tail(Point* p1) -{ - tail_ = p1; -} - -inline Point* SweepContext::tail() const -{ - return tail_; -} - -} - -#endif