Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
PhysicsReadback.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
24#include "./PhysicsContext.hpp"
25#include "./PhysicsBindings.hpp"
26
27namespace {
28size_t floatBytes(const std::vector<float>& buffer) {
29 return buffer.size() * sizeof(float);
30}
31} // namespace
32
33extern "C" {
34
36 return floatBytes(g_ctx.dynamicTransformBuffer);
37}
38
40 return floatBytes(g_ctx.poseInterpolated);
41}
42
44 return floatBytes(g_ctx.collisionEnterBuffer);
45}
46
48 return floatBytes(g_ctx.collisionExitBuffer);
49}
50
52 return floatBytes(g_ctx.sensorEnterBuffer);
53}
54
56 return floatBytes(g_ctx.sensorExitBuffer);
57}
58
60 return floatBytes(g_ctx.hitEventBuffer);
61}
62
64 return floatBytes(g_raycastBuffer);
65}
66
68 return floatBytes(g_overlapBuffer);
69}
70
74
75// The character mover writes a fixed record (position delta, ground normal, flags, what it stands on and hit),
76// so its whole extent is always live — see physics_moveCharacter.
78 return (11 + 4 * 3) * sizeof(float);
79}
80
81} // extern "C"
#define EMSCRIPTEN_KEEPALIVE
The Box2D module's entry points, declared once for both platforms.
PhysicsContext g_ctx
std::vector< float > g_shapeCastBuffer
std::vector< float > g_raycastBuffer
std::vector< float > g_overlapBuffer
size_t physics_interpolatedTransformsBytes()
size_t physics_collisionExitBytes()
size_t physics_overlapBytes()
size_t physics_collisionEnterBytes()
size_t physics_sensorExitBytes()
size_t physics_shapeCastBytes()
size_t physics_dynamicBodyTransformsBytes()
size_t physics_hitEventBytes()
size_t physics_raycastBytes()
size_t physics_sensorEnterBytes()
size_t physics_moveCharacterBytes()