mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add solid entities (wip)
This commit is contained in:
parent
3cd6ce1df2
commit
0a34f9b767
7 changed files with 158 additions and 116 deletions
|
|
@ -278,13 +278,17 @@ void Entities::updateSensors(
|
|||
}
|
||||
|
||||
void Entities::preparePhysics(float delta) {
|
||||
auto& physics = *level.physics;
|
||||
auto& solidHitboxes = physics.getSolidHitboxesWriteable();
|
||||
|
||||
|
||||
if (sensorsTickClock.update(delta)) {
|
||||
auto part = sensorsTickClock.getPart();
|
||||
auto parts = sensorsTickClock.getParts();
|
||||
|
||||
auto& sensors = physics.getSensorsWriteable();
|
||||
|
||||
auto view = registry->view<EntityId, Transform, Rigidbody>();
|
||||
auto physics = level.physics.get();
|
||||
std::vector<Sensor*> sensors;
|
||||
for (auto [entity, eid, transform, rigidbody] : view.each()) {
|
||||
if (!rigidbody.enabled) {
|
||||
continue;
|
||||
|
|
@ -294,7 +298,16 @@ void Entities::preparePhysics(float delta) {
|
|||
}
|
||||
updateSensors(rigidbody, transform, sensors);
|
||||
}
|
||||
physics->setSensors(std::move(sensors));
|
||||
}
|
||||
|
||||
solidHitboxes.clear();
|
||||
|
||||
auto view = registry->view<EntityId, Rigidbody>();
|
||||
for (auto [entity, eid, rigidbody] : view.each()) {
|
||||
if (!eid.def.solid || eid.destroyFlag || !rigidbody.enabled) {
|
||||
continue;
|
||||
}
|
||||
solidHitboxes.emplace_back(&rigidbody.hitbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue