mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ void EntityDef::cloneTo(EntityDef& dst) {
|
|||
dst.radialSensors = radialSensors;
|
||||
dst.skeletonName = skeletonName;
|
||||
dst.blocking = blocking;
|
||||
dst.solid = solid;
|
||||
dst.stepHeight = stepHeight;
|
||||
dst.save = save;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ struct EntityDef {
|
|||
/// @brief Does entity prevent blocks setup
|
||||
bool blocking = true;
|
||||
|
||||
/// @brief Is the entity solid (blocks other entities)
|
||||
bool solid = false;
|
||||
|
||||
/// @brief Max obstacle height that does not require jumping
|
||||
float stepHeight = 0.5f;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue