mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add modeltree component
This commit is contained in:
parent
824231bfd6
commit
8e08f79b54
5 changed files with 53 additions and 13 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include "../graphics/core/Model.hpp"
|
||||
#include "../maths/FrustumCulling.hpp"
|
||||
#include "../objects/EntityDef.hpp"
|
||||
#include "../objects/rigging.hpp"
|
||||
#include "../logic/scripting/scripting.hpp"
|
||||
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
|
|
@ -30,7 +31,16 @@ void Entity::destroy() {
|
|||
Entities::Entities(Level* level) : level(level) {
|
||||
}
|
||||
|
||||
entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos, dynamic::Value args) {
|
||||
entityid_t Entities::spawn(
|
||||
Assets* assets,
|
||||
EntityDef& def,
|
||||
glm::vec3 pos,
|
||||
dynamic::Value args)
|
||||
{
|
||||
auto rig = assets->get<rigging::RigConfig>(def.rigName);
|
||||
if (rig == nullptr) {
|
||||
throw std::runtime_error("rig "+def.rigName+" not found");
|
||||
}
|
||||
auto entity = registry.create();
|
||||
glm::vec3 size(1);
|
||||
auto id = nextID++;
|
||||
|
|
@ -54,9 +64,12 @@ entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos, dynamic::Value args) {
|
|||
}
|
||||
}});
|
||||
}
|
||||
auto& scripting = registry.emplace<Scripting>(entity, entity_funcs_set {}, nullptr);
|
||||
auto& scripting = registry.emplace<Scripting>(
|
||||
entity, entity_funcs_set {}, nullptr);
|
||||
entities[id] = entity;
|
||||
scripting.env = scripting::on_entity_spawn(def, id, scripting.funcsset, std::move(args));
|
||||
scripting.env = scripting::on_entity_spawn(
|
||||
def, id, scripting.funcsset, std::move(args));
|
||||
registry.emplace<rigging::Rig>(entity, rig->instance());
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +186,10 @@ void Entities::renderDebug(LineBatch& batch, const Frustum& frustum) {
|
|||
batch.box(hitbox.position, hitbox.halfsize * 2.0f, glm::vec4(1.0f));
|
||||
|
||||
for (auto& trigger : rigidbody.triggers) {
|
||||
batch.box(trigger.calculated.center(), trigger.calculated.size(), glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
batch.box(
|
||||
trigger.calculated.center(),
|
||||
trigger.calculated.size(),
|
||||
glm::vec4(1.0f, 1.0f, 0.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue