feat: sync entity direction and rotate models accordingly

Move direction into the transform component and include it in server-to-client entity updates. Client now sets transform direction from the network message and uses it to compute yaw for model rotation, so entities visually face their movement direction. Refactor net_utils to support arbitrary Vec3 fields.
This commit is contained in:
2026-08-04 10:46:31 +08:00
parent 6b1f9d7354
commit e2bbc2d57f
12 changed files with 37 additions and 18 deletions

View File

@@ -300,8 +300,11 @@ void WorldRenderer::shadow_entity(ClientWorld& world,
auto view = registry.view<BaseClientCreature>();
for (auto entity : view) {
auto& creature = view.get<BaseClientCreature>(entity);
float yaw = std::atan2(creature.transform.direction.value.x,
creature.transform.direction.value.z);
m_renderer.model_renderer().shadow_pass(
creature.model, creature.transform.position.value,
creature.model, creature.transform.position.value, yaw,
world.world_scene().camera());
}
m_player_renderer.render(shader, world, true);
@@ -721,8 +724,10 @@ void WorldRenderer::render_entity(ClientWorld& world) {
auto view = registry.view<BaseClientCreature>();
for (auto entity : view) {
auto& creature = view.get<BaseClientCreature>(entity);
float yaw = std::atan2(creature.transform.direction.value.x,
creature.transform.direction.value.z);
m_renderer.model_renderer().render_model(
creature.model, creature.transform.position.value,
creature.model, creature.transform.position.value, yaw,
world.world_scene().camera());
}