Improve presentation

This commit is contained in:
gingerBill
2024-08-14 10:18:36 +01:00
parent 660b6ff0f1
commit 0b26115805
4 changed files with 392 additions and 379 deletions
+15 -12
View File
@@ -423,12 +423,12 @@ foreign lib {
// Get proxy user data
// @return the proxy user data or 0 if the id is invalid
DynamicTree_GetUserData :: proc "contextless" (tree: DynamicTree, proxyId: i32) -> i32 {
DynamicTree_GetUserData :: #force_inline proc "contextless" (tree: DynamicTree, proxyId: i32) -> i32 {
return tree.nodes[proxyId].userData
}
// Get the AABB of a proxy
DynamicTree_GetAABB :: proc "contextless" (tree: DynamicTree, proxyId: i32) -> AABB {
DynamicTree_GetAABB :: #force_inline proc "contextless" (tree: DynamicTree, proxyId: i32) -> AABB {
return tree.nodes[proxyId].aabb
}
@@ -436,7 +436,6 @@ DynamicTree_GetAABB :: proc "contextless" (tree: DynamicTree, proxyId: i32) -> A
@(link_prefix="b2", default_calling_convention="c")
foreign lib {
/**
* @defgroup world World
* These functions allow you to create a simulation world.
@@ -575,7 +574,11 @@ foreign lib {
// Dump memory stats to box2d_memory.txt
World_DumpMemoryStats :: proc(worldId: WorldId) ---
}
@(link_prefix="b2", default_calling_convention="c")
foreign lib {
/**
* @defgroup body Body
* This is the body API.
@@ -583,9 +586,9 @@ foreign lib {
// Create a rigid body given a definition. No reference to the definition is retained. So you can create the definition
// on the stack and pass it as a pointer.
// @code{.c}
// BodyDef bodyDef = b2DefaultBodyDef();
// BodyId myBodyId = b2CreateBody(myWorldId, &bodyDef);
// @code{.odin}
// body_def := b2.DefaultBodyDef()
// my_body_id =: b2.CreateBody(my_world_id, body_def)
// @endcode
// @warning This function is locked during callbacks.
CreateBody :: proc(worldId: WorldId, #by_ptr def: BodyDef) -> BodyId ---
@@ -998,7 +1001,11 @@ foreign lib {
// Get the maximum capacity required for retrieving all the touching contacts on a shape
Shape_GetContactCapacity :: proc(shapeId: ShapeId) -> c.int ---
// Get the current world AABB
Shape_GetAABB :: proc(shapeId: ShapeId) -> AABB ---
// Get the closest point on a shape to a target point. Target and result are in world space.
Shape_GetClosestPoint :: proc(shapeId: ShapeId, target: Vec2) -> Vec2 ---
}
// Get the touching contact data for a shape. The provided shapeId will be either shapeIdA or shapeIdB on the contact data.
@@ -1012,12 +1019,6 @@ Shape_GetContactData :: proc "c" (shapeId: ShapeId, contactData: []ContactData)
@(link_prefix="b2", default_calling_convention="c")
foreign lib {
// Get the current world AABB
Shape_GetAABB :: proc(shapeId: ShapeId) -> AABB ---
// Get the closest point on a shape to a target point. Target and result are in world space.
Shape_GetClosestPoint :: proc(shapeId: ShapeId, target: Vec2) -> Vec2 ---
// Chain Shape
// Create a chain shape
@@ -1497,4 +1498,6 @@ IsValid :: proc{
Shape_IsValid,
Chain_IsValid,
Joint_IsValid,
IsValidRay,
}
+1 -1
View File
@@ -413,7 +413,7 @@ TreeNode :: struct {
enlarged: bool, // 1
// Padding for clarity
pad: [9]byte,
_: [9]byte,
}
// The dynamic tree structure. This should be considered private data.
+23 -13
View File
@@ -1,5 +1,7 @@
package vendor_box2d
import "base:intrinsics"
/**
* @defgroup id Ids
* These ids serve as handles to internal Box2D objects.
@@ -7,19 +9,13 @@ package vendor_box2d
* Include this header if you need the id types and not the whole Box2D API.
* All ids are considered null if initialized to zero.
*
* For example in C++:
* For example in Odin:
*
* @code{.cxx}
* b2WorldId worldId = {};
* @code{.odin}
* worldId := b2.WorldId{}
* @endcode
*
* Or in C:
*
* @code{.c}
* b2WorldId worldId = {0};
* @endcode
*
* These are both considered null.
* This is considered null.
*
* @warning Do not use the internals of these ids. They are subject to change. Ids should be treated as opaque objects.
* @warning You should use ids to access objects in Box2D. Do not access files within the src folder. Such usage is unsupported.
@@ -68,10 +64,24 @@ nullJointId :: JointId{}
nullChainId :: ChainId{}
/// Macro to determine if any id is null.
IS_NULL :: proc "c" (id: $T) -> bool { return id.index1 == 0 }
IS_NULL :: #force_inline proc "c" (id: $T) -> bool
where intrinsics.type_is_struct(T),
intrinsics.type_has_field(T, "index1") {
return id.index1 == 0
}
/// Macro to determine if any id is non-null.
IS_NON_NULL :: proc "c" (id: $T) -> bool { return id.index1 != 0 }
IS_NON_NULL :: #force_inline proc "c" (id: $T) -> bool
where intrinsics.type_is_struct(T),
intrinsics.type_has_field(T, "index1") {
return id.index1 != 0
}
/// Compare two ids for equality. Doesn't work for b2WorldId.
ID_EQUALS :: proc "c" (id1, id2: $T) -> bool { return id1.index1 == id2.index1 && id1.world0 == id2.world0 && id1.revision == id2.revision }
ID_EQUALS :: #force_inline proc "c" (id1, id2: $T) -> bool
where intrinsics.type_is_struct(T),
intrinsics.type_has_field(T, "index1"),
intrinsics.type_has_field(T, "world0"),
intrinsics.type_has_field(T, "revision") {
return id1.index1 == id2.index1 && id1.world0 == id2.world0 && id1.revision == id2.revision
}
+5 -5
View File
@@ -199,9 +199,8 @@ BodyDef :: struct {
Filter :: struct {
// The collision category bits. Normally you would just set one bit. The category bits should
// represent your application object types. For example:
// @code{.cpp}
// enum MyCategories
// {
// @code{.odin}
// My_Categories :: enum u32 {
// Static = 0x00000001,
// Dynamic = 0x00000002,
// Debris = 0x00000004,
@@ -209,14 +208,15 @@ Filter :: struct {
// // etc
// };
// @endcode
// Or use a bit_set.
categoryBits: u32,
// The collision mask bits. This states the categories that this
// shape would accept for collision.
// For example, you may want your player to only collide with static objects
// and other players.
// @code{.c}
// maskBits = Static | Player;
// @code{.odin}
// maskBits = u32(My_Categories.Static | My_Categories.Player);
// @endcode
maskBits: u32,