mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
Merge branch 'main' into animation
This commit is contained in:
commit
ab3c1e1b0c
14 changed files with 56 additions and 15 deletions
|
|
@ -181,9 +181,10 @@ std::optional<Entities::RaycastResult> Entities::rayCast(
|
|||
glm::ivec3 foundNormal;
|
||||
|
||||
for (auto [entity, eid, transform, body] : view.each()) {
|
||||
const auto& hitbox = body.hitbox;
|
||||
if (eid.uid == settings.ignoredUid || !body.enabled ||
|
||||
(settings.solidEntitiesOnly && !eid.def.solid) ||
|
||||
(!eid.def.selectable && !settings.includeNonSelectable)) {
|
||||
(!hitbox.selectable && !settings.includeNonSelectable)) {
|
||||
continue;
|
||||
}
|
||||
if (settings.entitiesFilter) {
|
||||
|
|
@ -193,7 +194,6 @@ std::optional<Entities::RaycastResult> Entities::rayCast(
|
|||
continue;
|
||||
}
|
||||
}
|
||||
const auto& hitbox = body.hitbox;
|
||||
glm::ivec3 normal;
|
||||
double distance;
|
||||
if (ray.intersectAABB(
|
||||
|
|
@ -336,6 +336,7 @@ void Entities::preparePhysics(float delta) {
|
|||
? rigidbody.mass
|
||||
: std::numeric_limits<float>::infinity();
|
||||
rigidbody.hitbox.elasticity = rigidbody.elasticity;
|
||||
rigidbody.hitbox.selectable = rigidbody.selectable;
|
||||
hitboxes.emplace_back(&rigidbody.hitbox);
|
||||
if (!eid.def.solid) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ dv::value Rigidbody::serialize(bool saveVelocity, bool saveBodySettings) const {
|
|||
}
|
||||
bodymap["mass"] = mass;
|
||||
bodymap["elasticity"] = elasticity;
|
||||
bodymap["selectable"] = selectable;
|
||||
}
|
||||
return bodymap;
|
||||
}
|
||||
|
|
@ -37,6 +38,7 @@ void Rigidbody::deserialize(const dv::value& root) {
|
|||
root["damping"].asNumber(hitbox.linearDamping);
|
||||
root["mass"].asNumber(mass);
|
||||
root["elasticity"].asNumber(elasticity);
|
||||
root["selectable"].asBoolean(selectable);
|
||||
}
|
||||
|
||||
template <void (*callback)(const Entity&, size_t, entityid_t)>
|
||||
|
|
@ -55,6 +57,7 @@ void Rigidbody::initialize(
|
|||
) {
|
||||
mass = def.mass;
|
||||
elasticity = def.elasticity;
|
||||
selectable = def.selectable;
|
||||
sensors.resize(def.radialSensors.size() + def.boxSensors.size());
|
||||
for (auto& [i, box] : def.boxSensors) {
|
||||
SensorParams params {};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ struct Rigidbody {
|
|||
std::vector<Sensor> sensors;
|
||||
float mass;
|
||||
float elasticity;
|
||||
bool selectable;
|
||||
|
||||
dv::value serialize(bool saveVelocity, bool saveBodySettings) const;
|
||||
void deserialize(const dv::value& root);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue