Files
ReSkate/Extension/World/physics_world_size.h
WackyHckyandClaude Opus 5.5 8fa971ceae Raise physics world body pool for large custom maps
Stock worlds allocate 8,200 bodies (+1 internal) from FBPhysicsWorldSize.
Studio maps give every collision part its own static body, so large maps
(e.g. a 41k-part GTA IV export) hit the FatalAssert
"bodyIndex < m_freeBodyList.capacity()" in FBPhysicsWorld::asyncAllocateBody
and crash on load.

Hook fb::FBPhysicsWorld creation (RVA 0x02606ff0) and raise the size
descriptor before it is copied into the job arguments, so every free list
and per-body array is sized consistently. BodyCount becomes 65,000 (kept
below 16 bits); the pools a static mesh body also draws from (geometry,
owner, hull/mesh, shape, aggregate/fixed shape, fixed partition,
persistent spatial index) scale by the same factor, capped at 2^20.
Contacts, joints, queries and culling tables keep their native sizes.

Both native callers build the descriptor on their own stack, so raising
it in place only affects that world. Contract bytes for the entry, the
descriptor copy, the internal-body increment and both call sites are
validated before the hook is enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 06:26:20 +11:00

19 lines
858 B
C++

#pragma once
#include <cstdint>
#include <string>
namespace dingosdk {
// Static collision slots per physics world. Stock worlds hold 8,200 bodies
// (+1 internal); a large custom map gives every collision part its own body.
// Kept below 65,536 so no 16-bit index elsewhere in the engine can wrap.
inline constexpr std::uint32_t physics_world_body_target = 65000;
// Pools that each static mesh body also draws from scale with BodyCount, up to this.
inline constexpr std::uint32_t physics_world_pool_ceiling = 1u << 20;
// Install after Detours hook service init, before any level loads. Raises the
// body pool and its companion static-collision pools at world creation only;
// queries, contacts, joints and per-query result limits keep their native size.
bool start_physics_world_size(std::uintptr_t base, std::string& error);
} // namespace dingosdk