mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
Merge branch 'MihailRis:main' into main
This commit is contained in:
commit
1f7f2ba097
7 changed files with 81 additions and 7 deletions
|
|
@ -55,6 +55,16 @@ public:
|
|||
return fields;
|
||||
}
|
||||
|
||||
void setFields(dv::value&& table, bool clear) {
|
||||
if (clear) {
|
||||
fields = std::move(table);
|
||||
return;
|
||||
}
|
||||
for (auto&& [key, value] : table.asObject()) {
|
||||
fields[std::move(key)] = std::move(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasFields() const {
|
||||
return fields != nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,6 +237,14 @@ static int l_get_all_data(lua::State* L, ItemStack& stack) {
|
|||
return lua::pushvalue(L, stack.getFields());
|
||||
}
|
||||
|
||||
static int l_set_all_data(lua::State* L, ItemStack& stack) {
|
||||
if (!lua::istable(L, 3)) {
|
||||
throw std::runtime_error("table expected as argument 1");
|
||||
}
|
||||
stack.setFields(lua::tovalue(L, 3), lua::toboolean(L, 4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_has_data(lua::State* L, ItemStack& stack) {
|
||||
auto key = lua::tostring(L, 3);
|
||||
if (key == nullptr) {
|
||||
|
|
@ -267,6 +275,7 @@ const luaL_Reg inventorylib[] = {
|
|||
{"get_data", lua::wrap<wrap_slot<l_get_data>>},
|
||||
{"set_data", lua::wrap<wrap_slot<l_set_data>>},
|
||||
{"get_all_data", lua::wrap<wrap_slot<l_get_all_data>>},
|
||||
{"set_all_data", lua::wrap<wrap_slot<l_set_all_data>>},
|
||||
{"has_data", lua::wrap<wrap_slot<l_has_data>>},
|
||||
{"create", lua::wrap<l_create>},
|
||||
{"remove", lua::wrap<l_remove>},
|
||||
|
|
|
|||
|
|
@ -88,12 +88,22 @@ void Skeleton::deserialize(const dv::value& root) {
|
|||
|
||||
void Skeleton::setConfig(std::shared_ptr<const SkeletonConfig> rigConfig) {
|
||||
config = std::move(rigConfig);
|
||||
|
||||
const auto& bones = config->getBones();
|
||||
|
||||
pose.matrices.resize(
|
||||
config->getBones().size(), glm::mat4(1.0f)
|
||||
bones.size(), glm::mat4(1.0f)
|
||||
);
|
||||
calculated.matrices.resize(
|
||||
config->getBones().size(), glm::mat4(1.0f)
|
||||
bones.size(), glm::mat4(1.0f)
|
||||
);
|
||||
|
||||
modelOverrides.resize(bones.size());
|
||||
flags.resize(bones.size());
|
||||
|
||||
for (size_t i = 0; i < bones.size(); i++) {
|
||||
flags[i].visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_all_nodes(std::vector<Bone*>& nodes, Bone* node) {
|
||||
|
|
|
|||
|
|
@ -309,7 +309,9 @@ static inline voxel* raycast_blocks(
|
|||
} else {
|
||||
iend = {ix, iy, iz};
|
||||
norm = {0, 0, 0};
|
||||
norm[steppedIndex] = -step[steppedIndex];
|
||||
if (steppedIndex != -1) {
|
||||
norm[steppedIndex] = -step[steppedIndex];
|
||||
}
|
||||
return voxel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue