mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
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:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user