mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
change rigs role from assets to content units
This commit is contained in:
parent
7dfda981a8
commit
49aa64a033
16 changed files with 67 additions and 70 deletions
|
|
@ -38,7 +38,7 @@ rigging::Rig& Entity::getModeltree() const {
|
|||
return registry.get<rigging::Rig>(entity);
|
||||
}
|
||||
|
||||
void Entity::setRig(rigging::RigConfig* rigConfig) {
|
||||
void Entity::setRig(const rigging::RigConfig* rigConfig) {
|
||||
auto& rig = registry.get<rigging::Rig>(entity);
|
||||
rig.config = rigConfig;
|
||||
rig.pose.matrices.resize(rigConfig->getNodes().size(), glm::mat4(1.0f));
|
||||
|
|
@ -60,14 +60,13 @@ static triggercallback create_trigger_callback(Entities* entities) {
|
|||
}
|
||||
|
||||
entityid_t Entities::spawn(
|
||||
Assets* assets,
|
||||
EntityDef& def,
|
||||
Transform transform,
|
||||
dynamic::Value args,
|
||||
dynamic::Map_sptr saved,
|
||||
entityid_t uid)
|
||||
{
|
||||
auto rig = assets->get<rigging::RigConfig>(def.rigName);
|
||||
auto rig = level->content->getRig(def.rigName);
|
||||
if (rig == nullptr) {
|
||||
throw std::runtime_error("rig "+def.rigName+" not found");
|
||||
}
|
||||
|
|
@ -140,8 +139,7 @@ void Entities::loadEntity(const dynamic::Map_sptr& map) {
|
|||
dynamic::get_vec(tsfmap, "pos", transform.pos);
|
||||
}
|
||||
dynamic::Map_sptr savedMap = map->map("comps");
|
||||
auto assets = scripting::engine->getAssets();
|
||||
spawn(assets, def, transform, dynamic::NONE, savedMap, uid);
|
||||
spawn(def, transform, dynamic::NONE, savedMap, uid);
|
||||
}
|
||||
|
||||
void Entities::loadEntities(dynamic::Map_sptr root) {
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ public:
|
|||
|
||||
rigging::Rig& getModeltree() const;
|
||||
|
||||
void setRig(rigging::RigConfig* rigConfig);
|
||||
void setRig(const rigging::RigConfig* rigConfig);
|
||||
|
||||
entityid_t getUID() const {
|
||||
return registry.get<EntityId>(entity).uid;
|
||||
|
|
@ -170,7 +170,6 @@ public:
|
|||
void render(Assets* assets, ModelBatch& batch, const Frustum& frustum);
|
||||
|
||||
entityid_t spawn(
|
||||
Assets* assets,
|
||||
EntityDef& def,
|
||||
Transform transform,
|
||||
dynamic::Value args=dynamic::NONE,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct EntityDef {
|
|||
glm::vec3 hitbox {0.5f};
|
||||
std::vector<std::pair<size_t, AABB>> boxTriggers {};
|
||||
std::vector<std::pair<size_t, float>> radialTriggers {};
|
||||
std::string rigName = name.substr(name.find(":") + 1);
|
||||
std::string rigName = name;
|
||||
|
||||
struct {
|
||||
bool enabled = true;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace rigging {
|
|||
};
|
||||
|
||||
struct Rig {
|
||||
RigConfig* config;
|
||||
const RigConfig* config;
|
||||
Pose pose;
|
||||
Pose calculated;
|
||||
std::unordered_map<std::string, std::string> textures;
|
||||
|
|
@ -99,7 +99,7 @@ namespace rigging {
|
|||
Rig& rig,
|
||||
const glm::mat4& matrix) const;
|
||||
|
||||
Rig instance() {
|
||||
Rig instance() const {
|
||||
return Rig {
|
||||
this, Pose(nodes.size()), Pose(nodes.size()), {}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue