text
stringlengths
1
24.5M
/* * Copyright (c) 2025 Chris Giles * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies. * Chris Giles makes no representations about the suitability * of this softwa...
/* * Copyright (c) 2025 Chris Giles * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies. * Chris Giles makes no representations about the suitability * of this softwa...
/* * Copyright (c) 2025 Chris Giles * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies. * Chris Giles makes no representations about the suitability * of this softwa...
long double dm2x(long double v) { return v * 10.33; }
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2020-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2023 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2023 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2022 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2021-2023 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2021-2022 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2021 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2021 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2023 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2022 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2023 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2023 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2019-2025 Arm Limited // Copyright 2008 Jose Fonseca // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the Licens...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2019-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2020-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2019-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2019-2025 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2019-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2019-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2021 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of ...
// sgs spec, define sgs macros and structs, can be include anywhere // match with axslcc-1.9.0 #pragma once #include <stdint.h> #define sgs_makefourcc(_a, _b, _c, _d) \ (((uint32_t)(_a) | ((uint32_t)(_b) << 8) | ((uint32_t)(_c) << 16) | ((uint32_t)(_d) << 24))) #pragma pack(push, 1) #define SGS_CHUNK ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include <stdint.h> // clang-format off // // Shared library macros #if defined( _MSC_VER ) && defined( box2d_EXPORTS ) // build the Windows DLL #define BOX2D_EXPORT __declspec( dllexport ) #elif defined( _MSC_VER ) && defined...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "base.h" #include "collision.h" #include "id.h" #include "types.h" #include <stdbool.h> /** * @defgroup world World * These functions allow you to create a simulation world. * * You can add rigid bodies and joint co...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "base.h" #include "math_functions.h" #include <stdbool.h> typedef struct b2SimplexCache b2SimplexCache; typedef struct b2Hull b2Hull; /** * @defgroup geometry Geometry * @brief Geometry types and algorithms * * Def...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "base.h" #include <stdint.h> /** * @defgroup id Ids * These ids serve as handles to internal Box2D objects. * These should be considered opaque data and passed by value. * Include this header if you need the id type...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "base.h" #include <float.h> #include <math.h> #include <stdbool.h> /** * @defgroup math Math * @brief Vector math types and functions * @{ */ /// 2D vector /// This can be used to represent a point or free vector t...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "base.h" #include "collision.h" #include "id.h" #include "math_functions.h" #include <stdbool.h> #include <stdint.h> #define B2_DEFAULT_CATEGORY_BITS 1 #define B2_DEFAULT_MASK_BITS UINT64_MAX /// Task interface /// Thi...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "aabb.h" #include "box2d/math_functions.h" #include <float.h> bool b2IsValidAABB( b2AABB a ) { b2Vec2 d = b2Sub( a.upperBound, a.lowerBound ); bool valid = d.x >= 0.0f && d.y >= 0.0f; valid = valid && b2IsValidVec2( a.lowerBound ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "box2d/types.h" // Ray cast an AABB b2CastOutput b2AABB_RayCast( b2AABB a, b2Vec2 p1, b2Vec2 p2 ); // Get surface area of an AABB (the perimeter length) static inline float b2Perimeter( b2AABB a ) { float wx = a.upperB...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "arena_allocator.h" #include "array.h" #include "core.h" #include <stdbool.h> #include <stddef.h> B2_ARRAY_SOURCE( b2ArenaEntry, b2ArenaEntry ) b2ArenaAllocator b2CreateArenaAllocator( int capacity ) { B2_ASSERT( capacity >= 0 ); ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" B2_ARRAY_DECLARE( b2ArenaEntry, b2ArenaEntry ); typedef struct b2ArenaEntry { char* data; const char* name; int size; bool usedMalloc; } b2ArenaEntry; // This is a stack-like arena allocator used for fast...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "array.h" #include <stddef.h> B2_ARRAY_SOURCE( int, b2Int )
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "core.h" // Macro generated functions for dynamic arrays // Pros // - type safe // - array data debuggable (visible count and capacity) // - bounds checking // - forward declaration // - simple implementation // - genera...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "core.h" #include <stdint.h> #if defined( _MSC_VER ) #include <intrin.h> #endif static inline void b2AtomicStoreInt( b2AtomicInt* a, int value ) { #if defined( _MSC_VER ) (void)_InterlockedExchange( (long*)&a->value, ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "bitset.h" #include <string.h> b2BitSet b2CreateBitSet( uint32_t bitCapacity ) { b2BitSet bitSet = { 0 }; bitSet.blockCapacity = ( bitCapacity + sizeof( uint64_t ) * 8 - 1 ) / ( sizeof( uint64_t ) * 8 ); bitSet.blockCount = 0; b...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "core.h" #include <stdbool.h> #include <stdint.h> // Bit set provides fast operations on large arrays of bits. typedef struct b2BitSet { uint64_t* bits; uint32_t blockCapacity; uint32_t blockCount; } b2BitSet; b2Bit...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "body.h" #include "aabb.h" #include "array.h" #include "contact.h" #include "core.h" #include "id_pool.h" #include "island.h" #include "joint.h" #include "shape.h" #include "solver_set.h" #include "world.h" // needed for dll export #...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "box2d/math_functions.h" #include "box2d/types.h" typedef struct b2World b2World; // Body organizational details that are not used in the solver. typedef struct b2Body { char name[32]; void* userD...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #if defined( _MSC_VER ) && !defined( _CRT_SECURE_NO_WARNINGS ) #define _CRT_SECURE_NO_WARNINGS #endif #include "broad_phase.h" #include "aabb.h" #include "array.h" #include "atomic.h" #include "body.h" #include "contact.h" #include "core.h" #...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "table.h" #include "box2d/collision.h" #include "box2d/types.h" typedef struct b2Shape b2Shape; typedef struct b2MovePair b2MovePair; typedef struct b2MoveResult b2MoveResult; typedef struct b2ArenaAl...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once extern float b2_lengthUnitsPerMeter; // Used to detect bad values. Positions greater than about 16km will have precision // problems, so 100km as a limit should be fine in all cases. #define B2_HUGE ( 100000.0f * b2_lengthUnitsPe...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "constraint_graph.h" #include "array.h" #include "bitset.h" #include "body.h" #include "contact.h" #include "joint.h" #include "solver_set.h" #include "world.h" #include <string.h> // Solver using graph coloring. Islands are only us...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "bitset.h" #include "constants.h" typedef struct b2Body b2Body; typedef struct b2ContactSim b2ContactSim; typedef struct b2Contact b2Contact; typedef struct b2ContactConstraint b2ContactConstraint; typ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "contact.h" #include "array.h" #include "body.h" #include "core.h" #include "island.h" #include "shape.h" #include "solver_set.h" #include "table.h" #include "world.h" #include "box2d/collision.h" #include <float.h> #include <math.h...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "core.h" #include "box2d/collision.h" #include "box2d/types.h" typedef struct b2Shape b2Shape; typedef struct b2World b2World; enum b2ContactFlags { // Set when the solid shapes are touching. b2_co...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "contact_solver.h" #include "body.h" #include "constraint_graph.h" #include "contact.h" #include "core.h" #include "solver_set.h" #include "world.h" #include <stddef.h> // contact separation for sub-stepping // s = s0 + dot(cB + rB ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "solver.h" typedef struct b2ContactSim b2ContactSim; typedef struct b2ContactConstraintPoint { b2Vec2 anchorA, anchorB; float baseSeparation; float relativeVelocity; float normalImpulse; float tangentImpulse; floa...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "core.h" #if defined( B2_COMPILER_MSVC ) #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #include <stdlib.h> #else #include <stdlib.h> #endif #include <stdio.h> #include <string.h> #ifdef BOX2D_PROFILE #include <tracy/TracyC.h> #defi...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "box2d/math_functions.h" // clang-format off #define B2_NULL_INDEX ( -1 ) // for performance comparisons #define B2_RESTRICT restrict #ifdef NDEBUG #define B2_DEBUG 0 #else #define B2_DEBUG 1 #endif #if defined( BO...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include <stdbool.h> #include <stdint.h> #if defined( _MSC_VER ) && !defined( __clang__ ) #include <intrin.h> // https://en.wikipedia.org/wiki/Find_first_set static inline uint32_t b2CTZ32( uint32_t block ) { unsigned long in...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "constants.h" #include "core.h" #include "box2d/collision.h" #include "box2d/math_functions.h" #include <float.h> #include <stddef.h> b2Transform b2GetSweepTransform( const b2Sweep* sweep, float time ) { // https://fgiesen.wordpre...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #if defined( _MSC_VER ) && !defined( _CRT_SECURE_NO_WARNINGS ) #define _CRT_SECURE_NO_WARNINGS #endif #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll expo...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "aabb.h" #include "constants.h" #include "core.h" #include "box2d/collision.h" #include "box2d/math_functions.h" #include <float.h> #include <string.h> #define B2_TREE_STACK_SIZE 1024 // todo externalize this to visualize internal ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "constants.h" #include "shape.h" #include "box2d/collision.h" #include "box2d/math_functions.h" #include <float.h> #include <stddef.h> _Static_assert( B2_MAX_POLYGON_VERTICES > 2, "must be 3 or more" ); bool b2IsValidRay( const b2R...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "constants.h" #include "core.h" #include "box2d/collision.h" #include "box2d/math_functions.h" #include <float.h> // quickhull recursion static b2Hull b2RecurseHull( b2Vec2 p1, b2Vec2 p2, b2Vec2* ps, int count ) { b2Hull hull; hul...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "id_pool.h" b2IdPool b2CreateIdPool( void ) { b2IdPool pool = { 0 }; pool.freeArray = b2IntArray_Create( 32 ); return pool; } void b2DestroyIdPool( b2IdPool* pool ) { b2IntArray_Destroy( &pool->freeArray ); *pool = ( b2IdPool ){...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" typedef struct b2IdPool { b2IntArray freeArray; int nextIndex; } b2IdPool; b2IdPool b2CreateIdPool( void ); void b2DestroyIdPool( b2IdPool* pool ); int b2AllocId( b2IdPool* pool ); void b2FreeId( b2IdPool* ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "island.h" #include "body.h" #include "contact.h" #include "core.h" #include "joint.h" #include "solver_set.h" #include "world.h" #include <stddef.h> B2_ARRAY_SOURCE( b2Island, b2Island ) B2_ARRAY_SOURCE( b2IslandSim, b2IslandSim ) ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include <stdbool.h> #include <stdint.h> typedef struct b2Contact b2Contact; typedef struct b2Joint b2Joint; typedef struct b2World b2World; // Deterministic solver // // Collide all awake contacts // Use bit...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "joint.h" #include "body.h" #include "contact.h" #include "core.h" #include "island.h" #include "shape.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" #include <std...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "solver.h" #include "box2d/types.h" typedef struct b2DebugDraw b2DebugDraw; typedef struct b2StepContext b2StepContext; typedef struct b2World b2World; /// A joint edge is used to connect bodies and j...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "constants.h" #include "core.h" #include "box2d/collision.h" #include "box2d/math_functions.h" #include <float.h> #include <stddef.h> #include <stdlib.h> #define B2_MAKE_ID( A, B ) ( (uint8_t)( A ) << 8 | (uint8_t)( B ) ) static b2...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "box2d/math_functions.h" #include <float.h> _Static_assert( sizeof( int32_t ) == sizeof( int ), "Box2D expects int32_t and int to be the same" ); bool b2IsValidFloat( float a ) { if ( isnan( a ) ) { return false; } if ( isinf...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" void b2MotorJoint_SetLinearOffset( b2JointId jointId, b2Vec2 linearOffset ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" void b2MouseJoint_SetTarget( b2JointId jointId, b2Vec2 target ) { B2_ASSE...
// SPDX-FileCopyrightText: 2025 Erin Catto // SPDX-License-Identifier: MIT #include "constants.h" #include "box2d/collision.h" b2PlaneSolverResult b2SolvePlanes( b2Vec2 position, b2CollisionPlane* planes, int count ) { for ( int i = 0; i < count; ++i ) { planes[i].push = 0.0f; } b2Vec2 delta = b2Vec2_zero; f...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" #include <stdio.h> void b2PrismaticJoint_EnableSpring( b2JointId jointId,...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #if defined( _MSC_VER ) && !defined( _CRT_SECURE_NO_WARNINGS ) #define _CRT_SECURE_NO_WARNINGS #endif #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll expo...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "sensor.h" #include "array.h" #include "body.h" #include "contact.h" #include "ctz.h" #include "shape.h" #include "world.h" #include "box2d/collision.h" #include <stddef.h> #include <stdlib.h> B2_ARRAY_SOURCE( b2ShapeRef, b2ShapeRe...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "bitset.h" typedef struct b2Shape b2Shape; typedef struct b2World b2World; typedef struct b2ShapeRef { int shapeId; uint16_t generation; } b2ShapeRef; typedef struct b2Sensor { b2ShapeRefArray ove...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "shape.h" #include "body.h" #include "broad_phase.h" #include "contact.h" #include "sensor.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" #include <stddef.h> B2_ARRAY_SOURCE( b2ChainShape, b2ChainShape ) B2...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" #include "box2d/types.h" typedef struct b2BroadPhase b2BroadPhase; typedef struct b2World b2World; typedef struct b2Shape { int id; int bodyId; int prevShapeId; int nextShapeId; int sensorIndex; b2Shape...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "solver.h" #include "array.h" #include "atomic.h" #include "bitset.h" #include "body.h" #include "contact.h" #include "contact_solver.h" #include "core.h" #include "ctz.h" #include "island.h" #include "joint.h" #include "shape.h" #inc...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "box2d/math_functions.h" #include "core.h" #include <stdbool.h> #include <stdint.h> typedef struct b2BodySim b2BodySim; typedef struct b2BodyState b2BodyState; typedef struct b2ContactSim b2ContactSim; typedef struct b...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "solver_set.h" #include "body.h" #include "constraint_graph.h" #include "contact.h" #include "core.h" #include "island.h" #include "joint.h" #include "world.h" #include <string.h> B2_ARRAY_SOURCE( b2SolverSet, b2SolverSet ) void b2...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include "array.h" typedef struct b2Body b2Body; typedef struct b2Joint b2Joint; typedef struct b2World b2World; // This holds solver set data. The following sets are used: // - static set for all static bodies (no contacts or j...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "table.h" #include "atomic.h" #include "core.h" #include "ctz.h" #include <stdbool.h> #include <string.h> #if B2_SNOOP_TABLE_COUNTERS b2AtomicInt b2_findCount; b2AtomicInt b2_probeCount; #endif // todo compare with https://github.c...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #pragma once #include <stdbool.h> #include <stdint.h> #define B2_SHAPE_PAIR_KEY( K1, K2 ) K1 < K2 ? (uint64_t)K1 << 32 | (uint64_t)K2 : (uint64_t)K2 << 32 | (uint64_t)K1 typedef struct b2SetItem { uint64_t key; uint32_t hash; } b2SetItem; ...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "box2d/base.h" #include <stddef.h> #if defined( _MSC_VER ) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include <windows.h> static double s_invFrequency = 0.0; uint64_t b2GetTicks( void ) { LARGE_INTEGER cou...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "box2d/types.h" #include "constants.h" #include "core.h" b2WorldDef b2DefaultWorldDef( void ) { b2WorldDef def = { 0 }; def.gravity.x = 0.0f; def.gravity.y = -10.0f; def.hitEventThreshold = 1.0f * b2_lengthUnitsPerMeter; def.res...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" float b2WeldJoint_GetReferenceAngle( b2JointId jointId ) { b2JointSim* jo...
// SPDX-FileCopyrightText: 2023 Erin Catto // SPDX-License-Identifier: MIT #include "body.h" #include "core.h" #include "joint.h" #include "solver.h" #include "solver_set.h" #include "world.h" // needed for dll export #include "box2d/box2d.h" #include <stdio.h> void b2WheelJoint_EnableSpring( b2JointId jointId, boo...