chore: added warnings and dependencies. also fixed warnings
This commit is contained in:
parent
253c617d19
commit
2b650c0fed
29 changed files with 63 additions and 51 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
||||||
/bin/
|
/bin/
|
||||||
/lib/
|
/lib/
|
||||||
/build/
|
/build/
|
||||||
|
/build-rel
|
||||||
/autogen/build
|
/autogen/build
|
||||||
|
|
||||||
# Qt
|
# Qt
|
||||||
|
|
|
@ -3,6 +3,12 @@ set(CMAKE_CXX_STANDARD 20)
|
||||||
project(openblocks VERSION 0.1.0)
|
project(openblocks VERSION 0.1.0)
|
||||||
set(OpenGL_GL_PREFERENCE "GLVND")
|
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
add_compile_options(/W4 /WX)
|
||||||
|
else()
|
||||||
|
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter)
|
||||||
|
endif()
|
||||||
|
|
||||||
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
|
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
|
||||||
|
|
||||||
add_subdirectory(autogen)
|
add_subdirectory(autogen)
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
using namespace data;
|
using namespace data;
|
||||||
|
|
||||||
static std::string toStaticName(std::string orig) {
|
static std::string toStaticName(std::string orig) {
|
||||||
bool isSnakeCase = orig.find('_') == -1;
|
|
||||||
|
|
||||||
std::string newName = "";
|
std::string newName = "";
|
||||||
int wordStart = 0;
|
int wordStart = 0;
|
||||||
for (char c : orig) {
|
for (char c : orig) {
|
||||||
|
@ -46,7 +44,6 @@ static void processConstructor(CXCursor cur, ClassAnalysis* state) {
|
||||||
|
|
||||||
auto result = parseAnnotationString(propertyDef.value());
|
auto result = parseAnnotationString(propertyDef.value());
|
||||||
std::string symbolName = x_clang_toString(clang_getCursorSpelling(cur));
|
std::string symbolName = x_clang_toString(clang_getCursorSpelling(cur));
|
||||||
CXType retType = clang_getCursorResultType(cur);
|
|
||||||
|
|
||||||
anly.name = result["name"];
|
anly.name = result["name"];
|
||||||
anly.functionName = "__ctor";
|
anly.functionName = "__ctor";
|
||||||
|
|
|
@ -118,14 +118,14 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) {
|
||||||
// Check number of arguments
|
// Check number of arguments
|
||||||
out << "n == " << std::to_string(methodImpl.parameters.size() + 1); // Account for first argument as 'this'
|
out << "n == " << std::to_string(methodImpl.parameters.size() + 1); // Account for first argument as 'this'
|
||||||
|
|
||||||
for (int i = 0; i < methodImpl.parameters.size(); i++) {
|
for (size_t i = 0; i < methodImpl.parameters.size(); i++) {
|
||||||
out << " && ";
|
out << " && ";
|
||||||
writeLuaTestArgument(out, methodImpl.parameters[i].type, i, true);
|
writeLuaTestArgument(out, methodImpl.parameters[i].type, i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
out << ") {\n"; // End if condition, start if body
|
out << ") {\n"; // End if condition, start if body
|
||||||
|
|
||||||
for (int i = 0; i < methodImpl.parameters.size(); i++) {
|
for (size_t i = 0; i < methodImpl.parameters.size(); i++) {
|
||||||
writeLuaGetArgument(out, methodImpl.parameters[i].type, i, true);
|
writeLuaGetArgument(out, methodImpl.parameters[i].type, i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) {
|
||||||
// Call function
|
// Call function
|
||||||
out << "this_->" << methodImpl.functionName << "(";
|
out << "this_->" << methodImpl.functionName << "(";
|
||||||
|
|
||||||
for (int i = 0; i < methodImpl.parameters.size(); i++) {
|
for (size_t i = 0; i < methodImpl.parameters.size(); i++) {
|
||||||
std::string varname = "arg" + std::to_string(i);
|
std::string varname = "arg" + std::to_string(i);
|
||||||
if (i != 0) out << ", ";
|
if (i != 0) out << ", ";
|
||||||
out << varname;
|
out << varname;
|
||||||
|
@ -183,7 +183,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) {
|
||||||
// Check number of arguments
|
// Check number of arguments
|
||||||
out << "n == " << std::to_string(methodImpl.parameters.size());
|
out << "n == " << std::to_string(methodImpl.parameters.size());
|
||||||
|
|
||||||
for (int i = 0; i < methodImpl.parameters.size(); i++) {
|
for (size_t i = 0; i < methodImpl.parameters.size(); i++) {
|
||||||
out << " && ";
|
out << " && ";
|
||||||
writeLuaTestArgument(out, methodImpl.parameters[i].type, i, false);
|
writeLuaTestArgument(out, methodImpl.parameters[i].type, i, false);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) {
|
||||||
out << ") {\n"; // End if condition, start if body
|
out << ") {\n"; // End if condition, start if body
|
||||||
|
|
||||||
// Get the arguments
|
// Get the arguments
|
||||||
for (int i = 0; i < methodImpl.parameters.size(); i++) {
|
for (size_t i = 0; i < methodImpl.parameters.size(); i++) {
|
||||||
writeLuaGetArgument(out, methodImpl.parameters[i].type, i, false);
|
writeLuaGetArgument(out, methodImpl.parameters[i].type, i, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ static void writeLuaMethodImpls(std::ofstream& out, ClassAnalysis& state) {
|
||||||
else
|
else
|
||||||
out << fqn << "::" << methodImpl.functionName << "(";
|
out << fqn << "::" << methodImpl.functionName << "(";
|
||||||
|
|
||||||
for (int i = 0; i < methodImpl.parameters.size(); i++) {
|
for (size_t i = 0; i < methodImpl.parameters.size(); i++) {
|
||||||
std::string varname = "arg" + std::to_string(i);
|
std::string varname = "arg" + std::to_string(i);
|
||||||
if (i != 0) out << ", ";
|
if (i != 0) out << ", ";
|
||||||
out << varname;
|
out << varname;
|
||||||
|
|
|
@ -25,11 +25,11 @@ std::map<std::string, std::string> parseAnnotationString(std::string src) {
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
bool quoted = false;
|
bool quoted = false;
|
||||||
|
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
for (; i < src.length(); i++) {
|
for (; i < src.length(); i++) {
|
||||||
if (src[i] == ' ' && (stage != 2 || !quoted)) continue; // Ignore spaces if not in stage 2 and quoted
|
if (src[i] == ' ' && (stage != 2 || !quoted)) continue; // Ignore spaces if not in stage 2 and quoted
|
||||||
if (src[i] == ',' && stage == 0) continue; // Let empty commas slip by
|
if (src[i] == ',' && stage == 0) continue; // Let empty commas slip by
|
||||||
if (stage < 2 && (src[i] >= 'a' && src[i] <= 'z' || src[i] >= 'A' && src[i] <= 'Z' || src[i] >= '0' && src[i] <= '9' || src[i] == '_')) {
|
if (stage < 2 && ((src[i] >= 'a' && src[i] <= 'z') || (src[i] >= 'A' && src[i] <= 'Z') || (src[i] >= '0' && src[i] <= '9') || src[i] == '_')) {
|
||||||
currentIdent += src[i];
|
currentIdent += src[i];
|
||||||
stage = 1;
|
stage = 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -63,7 +63,7 @@ std::map<std::string, std::string> parseAnnotationString(std::string src) {
|
||||||
currentValue += src[i];
|
currentValue += src[i];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Unexpected symbol: %c at index %d\n", src[i], i);
|
fprintf(stderr, "Unexpected symbol: %c at index %zu\n", src[i], i);
|
||||||
fprintf(stderr, "\t%s\n", src.c_str());
|
fprintf(stderr, "\t%s\n", src.c_str());
|
||||||
fprintf(stderr, "\t%s^\n", i > 0 ? std::string(i, '~').c_str() : "");
|
fprintf(stderr, "\t%s^\n", i > 0 ? std::string(i, '~').c_str() : "");
|
||||||
abort();
|
abort();
|
||||||
|
|
|
@ -5,3 +5,4 @@ find_package(glfw3 REQUIRED)
|
||||||
|
|
||||||
add_executable(client "src/main.cpp")
|
add_executable(client "src/main.cpp")
|
||||||
target_link_libraries(client PRIVATE ${SDL2_LIBRARIES} openblocks glfw)
|
target_link_libraries(client PRIVATE ${SDL2_LIBRARIES} openblocks glfw)
|
||||||
|
add_dependencies(client openblocks)
|
|
@ -26,6 +26,7 @@ foreach (SRC ${AUTOGEN_SOURCES})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${OUT_PATH}"
|
OUTPUT "${OUT_PATH}"
|
||||||
|
DEPENDS autogen
|
||||||
DEPENDS "${SRC_PATH}"
|
DEPENDS "${SRC_PATH}"
|
||||||
COMMAND "${CMAKE_BINARY_DIR}/autogen/autogen" "${CMAKE_CURRENT_SOURCE_DIR}/src" "${SRC_PATH}" "${OUT_PATH}"
|
COMMAND "${CMAKE_BINARY_DIR}/autogen/autogen" "${CMAKE_CURRENT_SOURCE_DIR}/src" "${SRC_PATH}" "${OUT_PATH}"
|
||||||
)
|
)
|
||||||
|
@ -43,6 +44,7 @@ add_library(openblocks STATIC ${SOURCES})
|
||||||
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
|
||||||
target_link_libraries(openblocks ${GLEW_LIBRARIES} ${LUAJIT_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml)
|
target_link_libraries(openblocks ${GLEW_LIBRARIES} ${LUAJIT_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml)
|
||||||
target_include_directories(openblocks PUBLIC "src" "../include" ${LUAJIT_INCLUDE_DIR})
|
target_include_directories(openblocks PUBLIC "src" "../include" ${LUAJIT_INCLUDE_DIR})
|
||||||
|
add_dependencies(openblocks autogen_build autogen)
|
||||||
|
|
||||||
# Windows-specific dependencies
|
# Windows-specific dependencies
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
DEF_DATA_CTOR CFrame(Vector3 , Vector3 lookAt, Vector3 up = Vector3(0, 1, 0));
|
DEF_DATA_CTOR CFrame(Vector3 , Vector3 lookAt, Vector3 up = Vector3(0, 1, 0));
|
||||||
CFrame(const reactphysics3d::Transform&);
|
CFrame(const reactphysics3d::Transform&);
|
||||||
CFrame(Vector3 position, glm::quat quat);
|
CFrame(Vector3 position, glm::quat quat);
|
||||||
~CFrame();
|
virtual ~CFrame();
|
||||||
|
|
||||||
// Same as CFrame(position, position + toward), but makes sure that up and toward are not linearly dependant
|
// Same as CFrame(position, position + toward), but makes sure that up and toward are not linearly dependant
|
||||||
static CFrame pointToward(Vector3 position, Vector3 toward);
|
static CFrame pointToward(Vector3 position, Vector3 toward);
|
||||||
|
|
|
@ -15,7 +15,7 @@ class DEF_DATA Color3 {
|
||||||
public:
|
public:
|
||||||
DEF_DATA_CTOR Color3(float r, float g, float b);
|
DEF_DATA_CTOR Color3(float r, float g, float b);
|
||||||
Color3(const glm::vec3&);
|
Color3(const glm::vec3&);
|
||||||
~Color3();
|
virtual ~Color3();
|
||||||
|
|
||||||
DEF_DATA_METHOD static Color3 FromHex(std::string hex);
|
DEF_DATA_METHOD static Color3 FromHex(std::string hex);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "error/data.h"
|
#include "error/data.h"
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
|
||||||
TypeMeta::TypeMeta(const Enum* enum_) : enum_(enum_), descriptor(&EnumItem::TYPE) {}
|
TypeMeta::TypeMeta(const Enum* enum_) : descriptor(&EnumItem::TYPE), enum_(enum_) {}
|
||||||
|
|
||||||
Enum::Enum(_EnumData* data) : data(data) {}
|
Enum::Enum(_EnumData* data) : data(data) {}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ class DEF_DATA Enum {
|
||||||
_EnumData* data;
|
_EnumData* data;
|
||||||
public:
|
public:
|
||||||
Enum(_EnumData*);
|
Enum(_EnumData*);
|
||||||
|
virtual ~Enum() = default;
|
||||||
|
|
||||||
static const TypeDesc TYPE;
|
static const TypeDesc TYPE;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ class DEF_DATA EnumItem {
|
||||||
int value;
|
int value;
|
||||||
public:
|
public:
|
||||||
EnumItem(_EnumData*, std::string, int);
|
EnumItem(_EnumData*, std::string, int);
|
||||||
|
virtual ~EnumItem() = default;
|
||||||
|
|
||||||
static const TypeDesc TYPE;
|
static const TypeDesc TYPE;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "objects/base/member.h"
|
#include "objects/base/member.h"
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
|
||||||
TypeMeta::TypeMeta(const InstanceType* instType) : instType(instType), descriptor(&InstanceRef::TYPE) {}
|
TypeMeta::TypeMeta(const InstanceType* instType) : descriptor(&InstanceRef::TYPE), instType(instType) {}
|
||||||
|
|
||||||
InstanceRef::InstanceRef() {};
|
InstanceRef::InstanceRef() {};
|
||||||
InstanceRef::InstanceRef(std::weak_ptr<Instance> instance) : ref(instance) {};
|
InstanceRef::InstanceRef(std::weak_ptr<Instance> instance) : ref(instance) {};
|
||||||
|
|
|
@ -11,7 +11,7 @@ class InstanceRef {
|
||||||
public:
|
public:
|
||||||
InstanceRef();
|
InstanceRef();
|
||||||
InstanceRef(std::weak_ptr<Instance>);
|
InstanceRef(std::weak_ptr<Instance>);
|
||||||
~InstanceRef();
|
virtual ~InstanceRef();
|
||||||
|
|
||||||
static const TypeDesc TYPE;
|
static const TypeDesc TYPE;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ LuaSignalConnection::~LuaSignalConnection() {
|
||||||
luaL_unref(state, LUA_REGISTRYINDEX, thread);
|
luaL_unref(state, LUA_REGISTRYINDEX, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static void stackdump(lua_State* L) {
|
static void stackdump(lua_State* L) {
|
||||||
printf("%d\n", lua_gettop(L));
|
printf("%d\n", lua_gettop(L));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -52,6 +53,7 @@ static void stackdump(lua_State* L) {
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void LuaSignalConnection::Call(std::vector<Variant> args) {
|
void LuaSignalConnection::Call(std::vector<Variant> args) {
|
||||||
lua_State* thread = lua_newthread(state);
|
lua_State* thread = lua_newthread(state);
|
||||||
|
@ -227,7 +229,10 @@ SignalRef::~SignalRef() = default;
|
||||||
|
|
||||||
const TypeDesc SignalRef::TYPE = {
|
const TypeDesc SignalRef::TYPE = {
|
||||||
.name = "Signal",
|
.name = "Signal",
|
||||||
|
.serialize = nullptr,
|
||||||
|
.deserialize = nullptr,
|
||||||
.toString = toVariantFunction(&SignalRef::ToString),
|
.toString = toVariantFunction(&SignalRef::ToString),
|
||||||
|
.fromString = nullptr,
|
||||||
.pushLuaValue = toVariantFunction(&SignalRef::PushLuaValue),
|
.pushLuaValue = toVariantFunction(&SignalRef::PushLuaValue),
|
||||||
.fromLuaValue = &SignalRef::FromLuaValue,
|
.fromLuaValue = &SignalRef::FromLuaValue,
|
||||||
};
|
};
|
||||||
|
@ -348,7 +353,10 @@ SignalConnectionRef::~SignalConnectionRef() = default;
|
||||||
|
|
||||||
const TypeDesc SignalConnectionRef::TYPE = {
|
const TypeDesc SignalConnectionRef::TYPE = {
|
||||||
.name = "Signal",
|
.name = "Signal",
|
||||||
|
.serialize = nullptr,
|
||||||
|
.deserialize = nullptr,
|
||||||
.toString = toVariantFunction(&SignalConnectionRef::ToString),
|
.toString = toVariantFunction(&SignalConnectionRef::ToString),
|
||||||
|
.fromString = nullptr,
|
||||||
.pushLuaValue = toVariantFunction(&SignalConnectionRef::PushLuaValue),
|
.pushLuaValue = toVariantFunction(&SignalConnectionRef::PushLuaValue),
|
||||||
.fromLuaValue = &SignalConnectionRef::FromLuaValue,
|
.fromLuaValue = &SignalConnectionRef::FromLuaValue,
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,7 @@ protected:
|
||||||
void Call(std::vector<Variant>) override;
|
void Call(std::vector<Variant>) override;
|
||||||
public:
|
public:
|
||||||
CSignalConnection(std::function<void(std::vector<Variant>)>, std::weak_ptr<Signal> parent);
|
CSignalConnection(std::function<void(std::vector<Variant>)>, std::weak_ptr<Signal> parent);
|
||||||
|
virtual ~CSignalConnection() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LuaSignalConnection : public SignalConnection {
|
class LuaSignalConnection : public SignalConnection {
|
||||||
|
@ -53,7 +54,7 @@ public:
|
||||||
LuaSignalConnection(lua_State*, std::weak_ptr<Signal> parent);
|
LuaSignalConnection(lua_State*, std::weak_ptr<Signal> parent);
|
||||||
LuaSignalConnection (const LuaSignalConnection&) = delete;
|
LuaSignalConnection (const LuaSignalConnection&) = delete;
|
||||||
LuaSignalConnection& operator= (const LuaSignalConnection&) = delete;
|
LuaSignalConnection& operator= (const LuaSignalConnection&) = delete;
|
||||||
~LuaSignalConnection();
|
virtual ~LuaSignalConnection();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Holds a signal connection such that when the holder is deleted (either via its parent object being deleted, or being overwritten),
|
// Holds a signal connection such that when the holder is deleted (either via its parent object being deleted, or being overwritten),
|
||||||
|
@ -110,7 +111,7 @@ class SignalRef {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SignalRef(std::weak_ptr<Signal>);
|
SignalRef(std::weak_ptr<Signal>);
|
||||||
~SignalRef();
|
virtual ~SignalRef();
|
||||||
|
|
||||||
static const TypeDesc TYPE;
|
static const TypeDesc TYPE;
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ class SignalConnectionRef {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SignalConnectionRef(std::weak_ptr<SignalConnection>);
|
SignalConnectionRef(std::weak_ptr<SignalConnection>);
|
||||||
~SignalConnectionRef();
|
virtual ~SignalConnectionRef();
|
||||||
|
|
||||||
static const TypeDesc TYPE;
|
static const TypeDesc TYPE;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ result<Vector3, DataParseError> Vector3::FromString(std::string string) {
|
||||||
if (string.length() == 0) return DataParseError(string, "Vector3");
|
if (string.length() == 0) return DataParseError(string, "Vector3");
|
||||||
while (string[0] == ' ' && string.length() > 0) string.erase(0, 1);
|
while (string[0] == ' ' && string.length() > 0) string.erase(0, 1);
|
||||||
size_t nextPos = string.find(",");
|
size_t nextPos = string.find(",");
|
||||||
if (nextPos == -1) nextPos = string.length();
|
if (nextPos == std::string::npos) nextPos = string.length();
|
||||||
std::string term = string.substr(0, nextPos);
|
std::string term = string.substr(0, nextPos);
|
||||||
string.erase(0, nextPos+1);
|
string.erase(0, nextPos+1);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
DEF_DATA_CTOR Vector3(float x, float y, float z);
|
DEF_DATA_CTOR Vector3(float x, float y, float z);
|
||||||
Vector3(const glm::vec3&);
|
Vector3(const glm::vec3&);
|
||||||
Vector3(const reactphysics3d::Vector3&);
|
Vector3(const reactphysics3d::Vector3&);
|
||||||
~Vector3();
|
virtual ~Vector3();
|
||||||
|
|
||||||
DEF_DATA_PROP static Vector3 ZERO;
|
DEF_DATA_PROP static Vector3 ZERO;
|
||||||
DEF_DATA_PROP static Vector3 ONE;
|
DEF_DATA_PROP static Vector3 ONE;
|
||||||
|
|
|
@ -28,6 +28,7 @@ const InstanceType Instance::TYPE = {
|
||||||
.className = "Instance",
|
.className = "Instance",
|
||||||
.constructor = NULL, // Instance is abstract and therefore not creatable
|
.constructor = NULL, // Instance is abstract and therefore not creatable
|
||||||
.explorerIcon = "instance",
|
.explorerIcon = "instance",
|
||||||
|
.flags = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Instance is abstract, so it should not implement GetClass directly
|
// Instance is abstract, so it should not implement GetClass directly
|
||||||
|
@ -211,7 +212,7 @@ result<Variant, MemberNotFound> Instance::InternalGetPropertyValue(std::string n
|
||||||
|
|
||||||
result<PropertyMeta, MemberNotFound> Instance::InternalGetPropertyMeta(std::string name) {
|
result<PropertyMeta, MemberNotFound> Instance::InternalGetPropertyMeta(std::string name) {
|
||||||
if (name == "Name") {
|
if (name == "Name") {
|
||||||
return PropertyMeta { &STRING_TYPE };
|
return PropertyMeta { &STRING_TYPE, 0 };
|
||||||
} else if (name == "Parent") {
|
} else if (name == "Parent") {
|
||||||
return PropertyMeta { &InstanceRef::TYPE, PROP_NOSAVE };
|
return PropertyMeta { &InstanceRef::TYPE, PROP_NOSAVE };
|
||||||
} else if (name == "ClassName") {
|
} else if (name == "ClassName") {
|
||||||
|
@ -391,7 +392,7 @@ result<std::shared_ptr<Instance>, NoSuchInstance> Instance::Deserialize(pugi::xm
|
||||||
|
|
||||||
// DescendantsIterator
|
// DescendantsIterator
|
||||||
|
|
||||||
DescendantsIterator::DescendantsIterator(std::shared_ptr<Instance> current) : current(current), root(current == DUMMY_INSTANCE ? DUMMY_INSTANCE : current->GetParent()), siblingIndex { 0 } { }
|
DescendantsIterator::DescendantsIterator(std::shared_ptr<Instance> current) : root(current == DUMMY_INSTANCE ? DUMMY_INSTANCE : current->GetParent()), current(current), siblingIndex { 0 } { }
|
||||||
|
|
||||||
DescendantsIterator::self_type DescendantsIterator::operator++(int _) {
|
DescendantsIterator::self_type DescendantsIterator::operator++(int _) {
|
||||||
// If the current item is dummy, an error has occurred, this is not supposed to happen.
|
// If the current item is dummy, an error has occurred, this is not supposed to happen.
|
||||||
|
@ -416,7 +417,7 @@ DescendantsIterator::self_type DescendantsIterator::operator++(int _) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've hit the end of this item's children, move one up
|
// If we've hit the end of this item's children, move one up
|
||||||
while (current->GetParent() && current->GetParent().value()->GetChildren().size() <= (siblingIndex.back() + 1)) {
|
while (current->GetParent() && current->GetParent().value()->GetChildren().size() <= size_t(siblingIndex.back() + 1)) {
|
||||||
siblingIndex.pop_back();
|
siblingIndex.pop_back();
|
||||||
current = current->GetParent().value();
|
current = current->GetParent().value();
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ public:
|
||||||
typedef int difference_type;
|
typedef int difference_type;
|
||||||
|
|
||||||
DescendantsIterator(std::shared_ptr<Instance> current);
|
DescendantsIterator(std::shared_ptr<Instance> current);
|
||||||
inline self_type operator++() { self_type i = *this; ++*this; return i; }
|
inline self_type operator++() { (*this)++; return (*this); }
|
||||||
inline std::shared_ptr<Instance> operator*() { return current; }
|
inline std::shared_ptr<Instance> operator*() { return current; }
|
||||||
inline std::shared_ptr<Instance> operator->() { return current; }
|
inline std::shared_ptr<Instance> operator->() { return current; }
|
||||||
inline bool operator==(const self_type& rhs) { return current == rhs.current; }
|
inline bool operator==(const self_type& rhs) { return current == rhs.current; }
|
||||||
|
|
|
@ -94,7 +94,7 @@ void ScriptContext::PushThreadSleep(lua_State* thread, float delay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptContext::RunSleepingThreads() {
|
void ScriptContext::RunSleepingThreads() {
|
||||||
for (int i = 0; i < sleepingThreads.size();) {
|
for (size_t i = 0; i < sleepingThreads.size();) {
|
||||||
bool deleted = false;
|
bool deleted = false;
|
||||||
|
|
||||||
SleepingThread sleep = sleepingThreads[i];
|
SleepingThread sleep = sleepingThreads[i];
|
||||||
|
|
|
@ -24,7 +24,7 @@ Workspace::~Workspace() {
|
||||||
PhysicsEventListener::PhysicsEventListener(Workspace* parent) : workspace(parent) {}
|
PhysicsEventListener::PhysicsEventListener(Workspace* parent) : workspace(parent) {}
|
||||||
|
|
||||||
void PhysicsEventListener::onContact(const rp::CollisionCallback::CallbackData& data) {
|
void PhysicsEventListener::onContact(const rp::CollisionCallback::CallbackData& data) {
|
||||||
for (int i = 0; i < data.getNbContactPairs(); i++) {
|
for (size_t i = 0; i < data.getNbContactPairs(); i++) {
|
||||||
auto pair = data.getContactPair(i);
|
auto pair = data.getContactPair(i);
|
||||||
auto type = pair.getEventType();
|
auto type = pair.getEventType();
|
||||||
if (type == rp::CollisionCallback::ContactPair::EventType::ContactStay) continue;
|
if (type == rp::CollisionCallback::ContactPair::EventType::ContactStay) continue;
|
||||||
|
@ -84,8 +84,6 @@ void Workspace::InitService() {
|
||||||
void Workspace::SyncPartPhysics(std::shared_ptr<Part> part) {
|
void Workspace::SyncPartPhysics(std::shared_ptr<Part> part) {
|
||||||
if (!physicsWorld) return;
|
if (!physicsWorld) return;
|
||||||
|
|
||||||
glm::mat4 rotMat = glm::mat4(1.0f);
|
|
||||||
|
|
||||||
rp::Transform transform = part->cframe;
|
rp::Transform transform = part->cframe;
|
||||||
if (!part->rigidBody) {
|
if (!part->rigidBody) {
|
||||||
part->rigidBody = physicsWorld->createRigidBody(transform);
|
part->rigidBody = physicsWorld->createRigidBody(transform);
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool operator ==(std::optional<std::weak_ptr<T>> a, std::optional<std::weak_ptr<T>> b) {
|
bool operator ==(std::optional<std::weak_ptr<T>> a, std::optional<std::weak_ptr<T>> b) {
|
||||||
return (!a.has_value() || a.value().expired()) && (!b.has_value() || b.value().expired())
|
return ((!a.has_value() || a.value().expired()) && (!b.has_value() || b.value().expired()))
|
||||||
|| (a.has_value() && !a.value().expired()) && (b.has_value() && !b.value().expired()) && a.value().lock() == b.value().lock();
|
|| ((a.has_value() && !a.value().expired()) && (b.has_value() && !b.value().expired()) && a.value().lock() == b.value().lock());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool operator ==(std::weak_ptr<T> a, std::weak_ptr<T> b) {
|
bool operator ==(std::weak_ptr<T> a, std::weak_ptr<T> b) {
|
||||||
return a.expired() && b.expired() || (!a.expired() && !b.expired() && a.lock() == b.lock());
|
return (a.expired() && b.expired()) || (!a.expired() && !b.expired() && a.lock() == b.lock());
|
||||||
}
|
}
|
|
@ -52,8 +52,6 @@ void renderInit(GLFWwindow* window, int width, int height) {
|
||||||
viewportWidth = width, viewportHeight = height;
|
viewportWidth = width, viewportHeight = height;
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
int argc = 1;
|
|
||||||
char* argv = const_cast<char*>("");
|
|
||||||
initMeshes();
|
initMeshes();
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
@ -240,7 +238,6 @@ void renderSurfaceExtras() {
|
||||||
glm::mat4 model = CFrame::pointToward(surfaceCenter, part->cframe.Rotation() * normalFromFace(face));
|
glm::mat4 model = CFrame::pointToward(surfaceCenter, part->cframe.Rotation() * normalFromFace(face));
|
||||||
model = glm::scale(model, glm::vec3(0.4,0.4,0.4));
|
model = glm::scale(model, glm::vec3(0.4,0.4,0.4));
|
||||||
ghostShader->set("model", model);
|
ghostShader->set("model", model);
|
||||||
glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model)));
|
|
||||||
|
|
||||||
CYLINDER_MESH->bind();
|
CYLINDER_MESH->bind();
|
||||||
glDrawArrays(GL_TRIANGLES, 0, CYLINDER_MESH->vertexCount);
|
glDrawArrays(GL_TRIANGLES, 0, CYLINDER_MESH->vertexCount);
|
||||||
|
|
|
@ -69,6 +69,7 @@ endif()
|
||||||
|
|
||||||
target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR})
|
target_include_directories(editor PUBLIC "../core/src" "../include" ${QSCINTILLA_INCLUDE_DIR})
|
||||||
target_link_libraries(editor PRIVATE openblocks Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia ${QSCINTILLA_LIBRARY})
|
target_link_libraries(editor PRIVATE openblocks Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Multimedia ${QSCINTILLA_LIBRARY})
|
||||||
|
add_dependencies(editor openblocks)
|
||||||
|
|
||||||
# Qt6 does not include QOpenGLWidgets as part of Widgets base anymore, so
|
# Qt6 does not include QOpenGLWidgets as part of Widgets base anymore, so
|
||||||
# we have to include it manually
|
# we have to include it manually
|
||||||
|
|
|
@ -421,7 +421,7 @@ void MainGLWidget::mousePressEvent(QMouseEvent* evt) {
|
||||||
draggingObject = part;
|
draggingObject = part;
|
||||||
if (evt->modifiers() & Qt::ControlModifier) {
|
if (evt->modifiers() & Qt::ControlModifier) {
|
||||||
std::vector<std::shared_ptr<Instance>> currentSelection = getSelection();
|
std::vector<std::shared_ptr<Instance>> currentSelection = getSelection();
|
||||||
for (int i = 0; i < currentSelection.size(); i++) {
|
for (size_t i = 0; i < currentSelection.size(); i++) {
|
||||||
std::shared_ptr<Instance> inst = currentSelection[i];
|
std::shared_ptr<Instance> inst = currentSelection[i];
|
||||||
if (inst == part) {
|
if (inst == part) {
|
||||||
currentSelection.erase(currentSelection.begin() + i);
|
currentSelection.erase(currentSelection.begin() + i);
|
||||||
|
|
|
@ -45,7 +45,7 @@ QModelIndex ExplorerModel::index(int row, int column, const QModelIndex &parent)
|
||||||
? static_cast<Instance*>(parent.internalPointer())
|
? static_cast<Instance*>(parent.internalPointer())
|
||||||
: rootItem.get();
|
: rootItem.get();
|
||||||
|
|
||||||
if (parentItem->GetChildren().size() >= row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN))
|
if (parentItem->GetChildren().size() >= (size_t)row && !(parentItem->GetChildren()[row]->GetClass()->flags & INSTANCE_HIDDEN))
|
||||||
return createIndex(row, column, parentItem->GetChildren()[row].get());
|
return createIndex(row, column, parentItem->GetChildren()[row].get());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ QModelIndex ExplorerModel::toIndex(std::shared_ptr<Instance> item) {
|
||||||
|
|
||||||
std::shared_ptr<Instance> parentItem = item->GetParent().value();
|
std::shared_ptr<Instance> parentItem = item->GetParent().value();
|
||||||
// Check above ensures this item is not root, so value() must be valid
|
// Check above ensures this item is not root, so value() must be valid
|
||||||
for (int i = 0; i < parentItem->GetChildren().size(); i++)
|
for (size_t i = 0; i < parentItem->GetChildren().size(); i++)
|
||||||
if (parentItem->GetChildren()[i] == item)
|
if (parentItem->GetChildren()[i] == item)
|
||||||
return createIndex(i, 0, item.get());
|
return createIndex(i, 0, item.get());
|
||||||
return QModelIndex{};
|
return QModelIndex{};
|
||||||
|
@ -79,7 +79,7 @@ QModelIndex ExplorerModel::parent(const QModelIndex &index) const {
|
||||||
|
|
||||||
// Check above ensures this item is not root, so value() must be valid
|
// Check above ensures this item is not root, so value() must be valid
|
||||||
std::shared_ptr<Instance> parentParent = parentItem->GetParent().value();
|
std::shared_ptr<Instance> parentParent = parentItem->GetParent().value();
|
||||||
for (int i = 0; i < parentParent->GetChildren().size(); i++)
|
for (size_t i = 0; i < parentParent->GetChildren().size(); i++)
|
||||||
if (parentParent->GetChildren()[i] == parentItem)
|
if (parentParent->GetChildren()[i] == parentItem)
|
||||||
return createIndex(i, 0, parentItem.get());
|
return createIndex(i, 0, parentItem.get());
|
||||||
return QModelIndex{};
|
return QModelIndex{};
|
||||||
|
@ -156,7 +156,7 @@ bool ExplorerModel::moveRows(const QModelIndex &sourceParentIdx, int sourceRow,
|
||||||
|
|
||||||
Logger::infof("Moved %d from %s", count, sourceParent->name.c_str());
|
Logger::infof("Moved %d from %s", count, sourceParent->name.c_str());
|
||||||
|
|
||||||
if ((sourceRow + count) >= sourceParent->GetChildren().size()) {
|
if (size_t(sourceRow + count) >= sourceParent->GetChildren().size()) {
|
||||||
Logger::fatalErrorf("Attempt to move rows %d-%d from %s (%s) while it only has %zu children.", sourceRow, sourceRow + count, sourceParent->name.c_str(), sourceParent->GetClass()->className.c_str(), sourceParent->GetChildren().size());
|
Logger::fatalErrorf("Attempt to move rows %d-%d from %s (%s) while it only has %zu children.", sourceRow, sourceRow + count, sourceParent->name.c_str(), sourceParent->GetClass()->className.c_str(), sourceParent->GetChildren().size());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ bool ExplorerModel::moveRows(const QModelIndex &sourceParentIdx, int sourceRow,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExplorerModel::removeRows(int row, int count, const QModelIndex& parentIdx) {
|
bool ExplorerModel::removeRows(int row, int count, const QModelIndex& parentIdx) {
|
||||||
Instance* parent = parentIdx.isValid() ? static_cast<Instance*>(parentIdx.internalPointer()) : rootItem.get();
|
// Instance* parent = parentIdx.isValid() ? static_cast<Instance*>(parentIdx.internalPointer()) : rootItem.get();
|
||||||
|
|
||||||
for (int i = row; i < (row + count); i++) {
|
for (int i = row; i < (row + count); i++) {
|
||||||
//parent->GetChildren()[i]->SetParent(nullptr);
|
//parent->GetChildren()[i]->SetParent(nullptr);
|
||||||
|
|
|
@ -33,7 +33,6 @@ ExplorerView::ExplorerView(QWidget* parent):
|
||||||
this->expand(model.ObjectToIndex(gWorkspace()));
|
this->expand(model.ObjectToIndex(gWorkspace()));
|
||||||
|
|
||||||
connect(this, &QTreeView::customContextMenuRequested, this, [&](const QPoint& point) {
|
connect(this, &QTreeView::customContextMenuRequested, this, [&](const QPoint& point) {
|
||||||
QModelIndex index = this->indexAt(point);
|
|
||||||
contextMenu.exec(this->viewport()->mapToGlobal(point));
|
contextMenu.exec(this->viewport()->mapToGlobal(point));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,12 @@
|
||||||
class PropertiesItemDelegate : public QStyledItemDelegate {
|
class PropertiesItemDelegate : public QStyledItemDelegate {
|
||||||
PropertiesView* view;
|
PropertiesView* view;
|
||||||
public:
|
public:
|
||||||
PropertiesItemDelegate(PropertiesView* parent) : view(parent), QStyledItemDelegate(parent) {}
|
PropertiesItemDelegate(PropertiesView* parent) : QStyledItemDelegate(parent), view(parent) {}
|
||||||
|
|
||||||
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override {
|
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override {
|
||||||
// https://stackoverflow.com/a/76645757/16255372
|
// https://stackoverflow.com/a/76645757/16255372
|
||||||
// https://stackoverflow.com/a/70078448/16255372
|
// https://stackoverflow.com/a/70078448/16255372
|
||||||
|
|
||||||
int indent = dynamic_cast<PropertiesView*>(parent())->indentation();
|
|
||||||
|
|
||||||
QStyledItemDelegate::initStyleOption(option, index);
|
QStyledItemDelegate::initStyleOption(option, index);
|
||||||
|
|
||||||
if (!index.parent().isValid()) {
|
if (!index.parent().isValid()) {
|
||||||
|
@ -110,7 +108,7 @@ public:
|
||||||
|
|
||||||
EnumItem enumItem = currentValue.get<EnumItem>();
|
EnumItem enumItem = currentValue.get<EnumItem>();
|
||||||
std::vector<EnumItem> siblingItems = meta.type.enum_->GetEnumItems();
|
std::vector<EnumItem> siblingItems = meta.type.enum_->GetEnumItems();
|
||||||
for (int i = 0; i < siblingItems.size(); i++) {
|
for (size_t i = 0; i < siblingItems.size(); i++) {
|
||||||
comboBox->addItem(QString::fromStdString(siblingItems[i].Name()));
|
comboBox->addItem(QString::fromStdString(siblingItems[i].Name()));
|
||||||
if (siblingItems[i].Value() == enumItem.Value())
|
if (siblingItems[i].Value() == enumItem.Value())
|
||||||
comboBox->setCurrentIndex(i);
|
comboBox->setCurrentIndex(i);
|
||||||
|
@ -184,7 +182,7 @@ public:
|
||||||
|
|
||||||
EnumItem enumItem = currentValue.get<EnumItem>();
|
EnumItem enumItem = currentValue.get<EnumItem>();
|
||||||
std::vector<EnumItem> siblingItems = meta.type.enum_->GetEnumItems();
|
std::vector<EnumItem> siblingItems = meta.type.enum_->GetEnumItems();
|
||||||
for (int i = 0; i < siblingItems.size(); i++) {
|
for (size_t i = 0; i < siblingItems.size(); i++) {
|
||||||
if (siblingItems[i].Value() == enumItem.Value())
|
if (siblingItems[i].Value() == enumItem.Value())
|
||||||
comboBox->setCurrentIndex(i);
|
comboBox->setCurrentIndex(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class ObLuaLexer : public QsciLexerLua {
|
||||||
};
|
};
|
||||||
|
|
||||||
ScriptDocument::ScriptDocument(std::shared_ptr<Script> script, QWidget* parent):
|
ScriptDocument::ScriptDocument(std::shared_ptr<Script> script, QWidget* parent):
|
||||||
script(script), QMdiSubWindow(parent) {
|
QMdiSubWindow(parent), script(script) {
|
||||||
|
|
||||||
setWindowTitle(QString::fromStdString(script->name));
|
setWindowTitle(QString::fromStdString(script->name));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue