Skip to content

Commit 7d22bcd

Browse files
committed
[WIP] Implement Physics2D with box2d-v3
1 parent ceab134 commit 7d22bcd

File tree

127 files changed

+21124
-6788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+21124
-6788
lines changed

3rdparty/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## Box2D
1313
- [![Upstream](https://img.shields.io/github/v/release/erincatto/box2d?label=Upstream)](https://github.com/erincatto/box2d)
14-
- Version: 3.0.0-df7373c
14+
- Version: 3.1.0
1515
- License: MIT
1616

1717
## Bullet

3rdparty/box2d/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ endif()
2222

2323
set_target_properties(${target_name} PROPERTIES C_STANDARD 17 C_STANDARD_REQUIRED TRUE)
2424

25+
if(_simdc_defines)
26+
target_compile_definitions(${target_name} PRIVATE ${_simdc_defines})
27+
if(_simdc_options)
28+
target_compile_options(${target_name} PRIVATE ${_simdc_options})
29+
endif()
30+
endif()
31+
2532
target_include_directories(${target_name}
2633
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
2734
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")

3rdparty/box2d/include/box2d/base.h

+40-22
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// using the Windows DLL
1616
#define BOX2D_EXPORT __declspec( dllimport )
1717
#elif defined( box2d_EXPORTS )
18-
// building or using the Box2D shared library
18+
// building or using the shared library
1919
#define BOX2D_EXPORT __attribute__( ( visibility( "default" ) ) )
2020
#else
2121
// static library
@@ -44,26 +44,26 @@
4444
*/
4545

4646
/// Prototype for user allocation function
47-
/// @param size the allocation size in bytes
48-
/// @param alignment the required alignment, guaranteed to be a power of 2
47+
/// @param size the allocation size in bytes
48+
/// @param alignment the required alignment, guaranteed to be a power of 2
4949
typedef void* b2AllocFcn( unsigned int size, int alignment );
5050

5151
/// Prototype for user free function
52-
/// @param mem the memory previously allocated through `b2AllocFcn`
52+
/// @param mem the memory previously allocated through `b2AllocFcn`
5353
typedef void b2FreeFcn( void* mem );
5454

5555
/// Prototype for the user assert callback. Return 0 to skip the debugger break.
5656
typedef int b2AssertFcn( const char* condition, const char* fileName, int lineNumber );
5757

5858
/// This allows the user to override the allocation functions. These should be
59-
/// set during application startup.
59+
/// set during application startup.
6060
B2_API void b2SetAllocator( b2AllocFcn* allocFcn, b2FreeFcn* freeFcn );
6161

6262
/// @return the total bytes allocated by Box2D
6363
B2_API int b2GetByteCount( void );
6464

6565
/// Override the default assert callback
66-
/// @param assertFcn a non-null assert callback
66+
/// @param assertFcn a non-null assert callback
6767
B2_API void b2SetAssertFcn( b2AssertFcn* assertFcn );
6868

6969
/// Version numbering scheme.
@@ -86,27 +86,45 @@ B2_API b2Version b2GetVersion( void );
8686
/**@}*/
8787

8888
//! @cond
89-
// Timer for profiling. This has platform specific code and may not work on every platform.
90-
typedef struct b2Timer
91-
{
92-
#if defined( _WIN32 )
93-
int64_t start;
94-
#elif defined( __linux__ ) || defined( __APPLE__ )
95-
unsigned long long start_sec;
96-
unsigned long long start_usec;
89+
90+
// see https://github.com/scottt/debugbreak
91+
#if defined( _MSC_VER )
92+
#define B2_BREAKPOINT __debugbreak()
93+
#elif defined( __GNUC__ ) || defined( __clang__ )
94+
#define B2_BREAKPOINT __builtin_trap()
95+
#else
96+
// Unknown compiler
97+
#include <assert.h>
98+
#define B2_BREAKPOINT assert( 0 )
99+
#endif
100+
101+
#if !defined( NDEBUG ) || defined( B2_ENABLE_ASSERT )
102+
B2_API int b2InternalAssertFcn( const char* condition, const char* fileName, int lineNumber );
103+
#define B2_ASSERT( condition ) \
104+
do \
105+
{ \
106+
if ( !( condition ) && b2InternalAssertFcn( #condition, __FILE__, (int)__LINE__ ) ) \
107+
B2_BREAKPOINT; \
108+
} \
109+
while ( 0 )
97110
#else
98-
int32_t dummy;
111+
#define B2_ASSERT( ... ) ( (void)0 )
99112
#endif
100-
} b2Timer;
101113

102-
B2_API b2Timer b2CreateTimer( void );
103-
B2_API int64_t b2GetTicks( b2Timer* timer );
104-
B2_API float b2GetMilliseconds( const b2Timer* timer );
105-
B2_API float b2GetMillisecondsAndReset( b2Timer* timer );
106-
B2_API void b2SleepMilliseconds( int milliseconds );
114+
/// Get the absolute number of system ticks. The value is platform specific.
115+
B2_API uint64_t b2GetTicks( void );
116+
117+
/// Get the milliseconds passed from an initial tick value.
118+
B2_API float b2GetMilliseconds( uint64_t ticks );
119+
120+
/// Get the milliseconds passed from an initial tick value. Resets the passed in
121+
/// value to the current tick value.
122+
B2_API float b2GetMillisecondsAndReset( uint64_t* ticks );
123+
124+
/// Yield to be used in a busy loop.
107125
B2_API void b2Yield( void );
108126

109-
// Simple djb2 hash function for determinism testing
127+
/// Simple djb2 hash function for determinism testing
110128
#define B2_HASH_INIT 5381
111129
B2_API uint32_t b2Hash( uint32_t hash, const uint8_t* data, int count );
112130

0 commit comments

Comments
 (0)