mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge branch 'main' into volume-renderer
This commit is contained in:
commit
b2df0a7e91
28 changed files with 642 additions and 184 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "objects/rigging.hpp"
|
||||
#include "libentity.hpp"
|
||||
|
||||
#include "engine/Engine.hpp"
|
||||
#include "graphics/render/WorldRenderer.hpp"
|
||||
#include "graphics/render/NamedSkeletons.hpp"
|
||||
|
||||
|
|
@ -21,11 +22,14 @@ static int index_range_check(
|
|||
}
|
||||
|
||||
static rigging::Skeleton* get_skeleton(lua::State* L) {
|
||||
if (scripting::engine->isHeadless()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (lua::isstring(L, 1)) {
|
||||
return scripting::renderer->skeletons->getSkeleton(lua::tostring(L, 1));
|
||||
}
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
return &entity->getSkeleton();
|
||||
return entity->getSkeleton();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,14 @@ static int l_parse_model(lua::State* L) {
|
|||
auto name = lua::require_string(L, 3);
|
||||
|
||||
if (format == "xml" || format == "vcm") {
|
||||
auto vcmModel = vcm::parse(name, string, format == "xml");
|
||||
engine->getAssets()->store(
|
||||
vcm::parse(name, string, format == "xml"), name
|
||||
std::make_unique<model::Model>(std::move(vcmModel.squash())), name
|
||||
);
|
||||
} else {
|
||||
throw std::runtime_error("unknown format " + util::quote(std::string(format)));
|
||||
throw std::runtime_error(
|
||||
"unknown format " + util::quote(std::string(format))
|
||||
);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "libentity.hpp"
|
||||
|
||||
#include "assets/Assets.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "content/ContentPack.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
|
@ -82,7 +83,11 @@ static int l_despawn(lua::State* L) {
|
|||
|
||||
static int l_get_skeleton(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
return lua::pushstring(L, entity->getSkeleton().config->getName());
|
||||
auto skeleton = entity->getSkeleton();
|
||||
if (skeleton == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return lua::pushstring(L, skeleton->config->getName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -97,9 +102,13 @@ static int l_get_player(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_set_skeleton(lua::State* L) {
|
||||
auto assets = engine->getAssets();
|
||||
if (assets == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
std::string skeletonName = lua::require_string(L, 2);
|
||||
auto rigConfig = content->getSkeleton(skeletonName);
|
||||
auto rigConfig = assets->get<rigging::SkeletonConfig>(skeletonName);
|
||||
if (rigConfig == nullptr) {
|
||||
throw std::runtime_error(
|
||||
"skeleton not found '" + skeletonName + "'"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue