mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
More lua binding work
This commit is contained in:
parent
d15446da29
commit
964a8f3fd1
|
@ -21,6 +21,9 @@ function is_raw(value)
|
|||
return getmetatable(value) == RawType
|
||||
end
|
||||
|
||||
|
||||
null_value = raw("NULL")
|
||||
|
||||
local MacroType = {}
|
||||
|
||||
function macro(name, ...)
|
||||
|
@ -141,6 +144,10 @@ local function replace_references(object, name_mapping, name_path)
|
|||
end
|
||||
|
||||
if (is_reference_type(object)) then
|
||||
if (object.value == nil) then
|
||||
return null_value
|
||||
end
|
||||
|
||||
local referenceName = name_mapping[object.value]
|
||||
|
||||
if (referenceName == nil) then
|
||||
|
@ -151,6 +158,7 @@ local function replace_references(object, name_mapping, name_path)
|
|||
end
|
||||
|
||||
local changes = {}
|
||||
local hasChange = {}
|
||||
local hasChanges = false
|
||||
|
||||
for k, v in pairs(object) do
|
||||
|
@ -165,7 +173,8 @@ local function replace_references(object, name_mapping, name_path)
|
|||
local replacement = replace_references(v, name_mapping, name)
|
||||
|
||||
if (replacement ~= v) then
|
||||
changes[k] = replacement;
|
||||
changes[k] = replacement
|
||||
hasChange[k] = true
|
||||
hasChanges = true
|
||||
end
|
||||
end
|
||||
|
@ -177,7 +186,11 @@ local function replace_references(object, name_mapping, name_path)
|
|||
local result = {}
|
||||
|
||||
for k, v in pairs(object) do
|
||||
result[k] = changes[k] or object[k]
|
||||
if (hasChange[k]) then
|
||||
result[k] = changes[k]
|
||||
else
|
||||
result[k] = object[k]
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
|
|
|
@ -322,8 +322,6 @@ void markConstantKeyframes(std::map<unsigned short, SKBoneKeyframeChain*>& first
|
|||
curr = curr->next;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "maxJump " << thresholdCheck << std::endl;
|
||||
}
|
||||
|
||||
void combineChunk(std::vector<SKBoneKeyframeChain>& chunkKeyframes, struct SKAnimationChunk& output) {
|
||||
|
|
|
@ -30,6 +30,8 @@ std::unique_ptr<DataChunk> buildStructureChunk(lua_State* L) {
|
|||
int topStart = lua_gettop(L);
|
||||
|
||||
std::unique_ptr<StructureDataChunk> result(new StructureDataChunk());
|
||||
|
||||
std::vector<std::pair<std::string, std::unique_ptr<DataChunk>>> namedEntries;
|
||||
|
||||
lua_pushnil(L); /* first key */
|
||||
while (lua_next(L, topStart) != 0) {
|
||||
|
@ -37,11 +39,20 @@ std::unique_ptr<DataChunk> buildStructureChunk(lua_State* L) {
|
|||
if (keyType == LUA_TNUMBER) {
|
||||
result->Add(std::move(buildDataChunk(L)));
|
||||
} else if (keyType == LUA_TSTRING) {
|
||||
result->Add(lua_tostring(L, -2), std::move(buildDataChunk(L)));
|
||||
namedEntries.push_back(std::pair<std::string, std::unique_ptr<DataChunk>>(
|
||||
lua_tostring(L, -2),
|
||||
std::move(buildDataChunk(L))
|
||||
));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
std::sort(namedEntries.begin(), namedEntries.end());
|
||||
|
||||
for (auto& entry : namedEntries) {
|
||||
result->Add(entry.first, std::move(entry.second));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <string.h>
|
||||
#include "./LuaMesh.h"
|
||||
#include "LuaTransform.h"
|
||||
#include "LuaBasicTypes.h"
|
||||
|
||||
Material* luaGetMaterial(lua_State* L, const DisplayListSettings& defaults) {
|
||||
int materialType = lua_type(L, -1);
|
||||
|
@ -63,5 +64,11 @@ void populateDisplayListSettings(lua_State* L, const DisplayListSettings& defaul
|
|||
toLua(L, defaults.CreateGlobalTransform());
|
||||
lua_setfield(L, -2, "fixed_point_transform");
|
||||
|
||||
toLua(L, defaults.mModelScale);
|
||||
lua_setfield(L, -2, "model_scale");
|
||||
|
||||
toLua(L, defaults.mFixedPointScale);
|
||||
lua_setfield(L, -2, "fixed_point_scale");
|
||||
|
||||
lua_setglobal(L, "settings");
|
||||
}
|
Loading…
Reference in a new issue