diff --git a/Deer/Include/Deer/ComponentScript.h b/Deer/Include/Deer/ComponentScript.h index 6051204..0c7642f 100755 --- a/Deer/Include/Deer/ComponentScript.h +++ b/Deer/Include/Deer/ComponentScript.h @@ -35,7 +35,7 @@ namespace Deer { ComponentScriptInstance() = default; ~ComponentScriptInstance(); - void tick(); + void tickExecution(); void start(); asIScriptObject* m_object; diff --git a/Deer/Include/Deer/DataStore.h b/Deer/Include/Deer/DataStore.h index 7420946..5e3d1a8 100755 --- a/Deer/Include/Deer/DataStore.h +++ b/Deer/Include/Deer/DataStore.h @@ -18,6 +18,7 @@ #define DEER_MESH_EXTENSION ".dmesh" #define DEER_SHADER_EXTENSION ".glsl" +#define DEER_SCRIPT_EXTENSION ".as" #define DEER_BIN_PATH "bin" #define DEER_TEMP_PATH "tmp" diff --git a/Deer/Include/Deer/Enviroment.h b/Deer/Include/Deer/Enviroment.h index 30d7196..b221bcf 100755 --- a/Deer/Include/Deer/Enviroment.h +++ b/Deer/Include/Deer/Enviroment.h @@ -148,7 +148,7 @@ namespace Deer { glm::mat4 getWorldMatrix(); glm::mat4 getRelativeMatrix(); - void tick(); + void tickExecution(); inline bool isValid() const { return m_exists; } diff --git a/Deer/Include/Deer/Scene.h b/Deer/Include/Deer/Scene.h index b384a77..7572c95 100755 --- a/Deer/Include/Deer/Scene.h +++ b/Deer/Include/Deer/Scene.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace Deer { class Environment; @@ -18,16 +19,17 @@ namespace Deer { // A scene is a 3d simulation with its environment and voxel world in case // of initialized, here things can be simulated namespace Scene { - // Resets all scene to 0 but conserving the memory making it much faster - // than creating another instance + // Clears all the assets and memory the Scene had conained void clear(); - // This is the cycle to execution - void beginExecution(); - void tick(); + // This is the cycle to execution of scripts and physics + void initExecution(); + void tickExecution(); void endExecution(); bool getExecutingState(); + uint32_t getCurrentExTick(); + #ifdef DEER_RENDER // This function renders with the default camera in the environment void render(); diff --git a/Deer/Include/Deer/ScriptEngine.h b/Deer/Include/Deer/ScriptEngine.h old mode 100755 new mode 100644 index 65946ad..796f7a4 --- a/Deer/Include/Deer/ScriptEngine.h +++ b/Deer/Include/Deer/ScriptEngine.h @@ -1,47 +1,36 @@ #pragma once -#include +#include #include -#include -#include -#include "Deer/ComponentScript.h" -#include "Deer/Memory.h" - -class asIScriptEngine; -class asIScriptModule; -class asIScriptContext; -class asIScriptFunction; class asITypeInfo; +class asIScriptObject; +class asIScriptFunction; namespace Deer { - class Entity; - class ComponentScript; + namespace ScriptEngine { + struct ComponentScript { + public: + ComponentScript(asITypeInfo* type); - using ComponentScriptMap = std::unordered_map; + void initialize(); + void tick(); + private: + asITypeInfo* scriptType; + asIScriptFunction* startFunction; + asIScriptFunction* updateFunction; + }; - namespace ScriptEngine { - extern asIScriptContext* m_context; - extern bool m_isCompilationValid; - extern ComponentScriptMap m_componentScripts; + void loadScripts(); + void unloadScripts(); - void compileScriptEngine(const std::filesystem::path& scriptPath); - void shutdownScriptEngine(); + void initializeExecution(); + void tickExecution(); + void endExecution(); - void beginExecutionContext(); - void endExecutionContext(); + void clearComponentScripts(); - inline asIScriptContext* getExecutionContext() { return m_context; } - inline bool isCompilationValid() { return m_isCompilationValid; } - - inline ComponentScriptMap& getComponentScripts() { - return m_componentScripts; - } - inline ComponentScript& getComponentScript( - const std::string& scriptID) { - return m_componentScripts[scriptID]; - } - - Ref createComponentScriptInstance( - const std::string& scriptID, Entity& scriptEntity); - } // namespace ScriptEngine -} // namespace Deer + ComponentScript& getComponentScript(uint16_t); + ComponentScript& createComponentScript(const std::string& scriptName); + void destroyComponentScript(uint16_t); + } +} \ No newline at end of file diff --git a/Deer/src/Deer/Core/Application.cpp b/Deer/src/Deer/Core/Application.cpp index 9f035f8..4ea30fc 100755 --- a/Deer/src/Deer/Core/Application.cpp +++ b/Deer/src/Deer/Core/Application.cpp @@ -94,7 +94,7 @@ namespace Deer { RenderCommand::setClearColor({ 0.2f, 0.2f, 0.3f, 1.0f }); RenderCommand::clear(); - Render::beginExecution(); + Render::initExecution(); onRender(Timestep((float)targetRenderTime)); Render::endExecution(); diff --git a/Deer/src/Deer/Scene/Scene.cpp b/Deer/src/Deer/Scene/Scene.cpp index e88f228..16527e4 100755 --- a/Deer/src/Deer/Scene/Scene.cpp +++ b/Deer/src/Deer/Scene/Scene.cpp @@ -12,7 +12,6 @@ #include "Deer/Voxels/VoxelWorldData.h" #include "Deer/Enviroment.h" - #include "Deer/Scene/SceneData.h" #ifdef DEER_RENDER @@ -26,6 +25,7 @@ namespace Deer { void Scene::clear() { environment.clear(); VoxelWorld::clear(); + #ifdef DEER_RENDER MeshManager::unloadAllModels(); ShaderManager::unloadAllShaders(); @@ -37,33 +37,17 @@ namespace Deer { return isExecuting; } - void Scene::beginExecution() { + void Scene::initExecution() { DEER_CORE_ASSERT(!isExecuting, "Deer scene is already executing"); isExecuting = true; - - DEER_CORE_INFO("Executing Scene..."); - ScriptEngine::beginExecutionContext(); - - // Instantiate all the scripts - auto view = environment.m_registry.view(); - for (auto& entID : view) { - auto& tagComponent = view.get(entID); - auto& componentScript = view.get(entID); - - Entity& entity = environment.getEntity(tagComponent.entityUID); - componentScript.roeInstance = - ScriptEngine::createComponentScriptInstance(componentScript.scriptID, entity); - - componentScript.roeInstance->start(); - } } - void Scene::tick() { + void Scene::tickExecution() { // Update all scripts auto view = environment.m_registry.view(); for (auto& entID : view) { auto& componentScript = view.get(entID); - componentScript.roeInstance->tick(); + componentScript.roeInstance->tickExecution(); } } diff --git a/Deer/src/Deer/Scripting/ComponentScript.cpp b/Deer/src/Deer/Scripting/ComponentScript.cpp deleted file mode 100755 index e2822af..0000000 --- a/Deer/src/Deer/Scripting/ComponentScript.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "Deer/ComponentScript.h" -#include "angelscript.h" - -#include "Deer/Log.h" -#include "Deer/ScriptEngine.h" -#include "angelscript.h" - -namespace Deer { - ComponentScript::ComponentScript(asITypeInfo* typeInfo) - : m_typeInfo(typeInfo) { - - m_scriptID = m_typeInfo->GetName(); - m_attributes = extractAttributes(typeInfo); - } - - ComponentScriptInstance::~ComponentScriptInstance() { - m_object->Release(); - } - - void ComponentScriptInstance::tick() { - if (!m_updateFunction) - return; - - asIScriptContext* context = ScriptEngine::getExecutionContext(); - - context->Prepare(m_updateFunction); - context->SetObject(m_object); - context->Execute(); - } - - void ComponentScriptInstance::start() { - if (!m_startFuction) - return; - - asIScriptContext* context = ScriptEngine::getExecutionContext(); - - context->Prepare(m_startFuction); - context->SetObject(m_object); - context->Execute(); - } -} \ No newline at end of file diff --git a/Deer/src/Deer/Scripting/ScriptAttributes.cpp b/Deer/src/Deer/Scripting/ScriptAttributes.cpp deleted file mode 100755 index 61f70eb..0000000 --- a/Deer/src/Deer/Scripting/ScriptAttributes.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "Deer/ComponentScript.h" -#include "Deer/Log.h" -#include "angelscript.h" - -namespace Deer { - ScriptAttributeMap extractAttributes(asITypeInfo* typeInfo) { - ScriptAttributeMap m_attributes; - - int atributes = typeInfo->GetPropertyCount(); - for (int x = 0; x < atributes; x++) { - const char* name; - bool isPrivate; - int typeID; - int offset; - - typeInfo->GetProperty(x, &name, &typeID, &isPrivate, nullptr, &offset); - ScriptAttribute attribute(name, typeID, isPrivate, offset, x); - - m_attributes.insert({ std::string(name), attribute}); - } - - return m_attributes; - } -} \ No newline at end of file diff --git a/Deer/src/Deer/Scripting/ScriptEngine.cpp b/Deer/src/Deer/Scripting/ScriptEngine.cpp deleted file mode 100755 index 2524c62..0000000 --- a/Deer/src/Deer/Scripting/ScriptEngine.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include "Deer/ScriptEngine.h" - -#include - -#include "Deer/ComponentScript.h" -#include "Deer/Enviroment.h" -#include "Deer/Log.h" -#include "Deer/Scene.h" -#include "ScriptEngineFunctions.h" -#include "angelscript.h" -#include "scriptbuilder.h" -#include "scriptmath.h" -#include "scriptstdstring.h" - -namespace fs = std::filesystem; - -namespace Deer { - namespace ScriptEngine { - asIScriptEngine* m_scriptEngine; - asIScriptModule* m_scriptModule; - - bool m_isCompilationValid = false; - - asIScriptContext* m_context; - ComponentScriptMap m_componentScripts; - - void loadModuleFolder(const std::filesystem::path& modulePath, - const char* moduleName); - void registerBaseComponents(); - } // namespace ScriptEngine - - void ScriptEngine::shutdownScriptEngine() { m_componentScripts.clear(); } - - void ScriptEngine::beginExecutionContext() { - m_context = m_scriptEngine->CreateContext(); - } - - void ScriptEngine::endExecutionContext() { m_context->Release(); } - - void ScriptEngine::compileScriptEngine( - const std::filesystem::path& modulePath) { - m_scriptEngine = asCreateScriptEngine(); - m_isCompilationValid = true; - - registerBaseComponents(); - loadModuleFolder(modulePath, "Deer"); - - m_scriptModule = m_scriptEngine->GetModule("Deer"); - asITypeInfo* m_deerScript = - m_scriptModule->GetTypeInfoByName("ComponentScript"); - - int classCount = m_scriptModule->GetObjectTypeCount(); - for (int i = 0; i < classCount; i++) { - asITypeInfo* type = m_scriptModule->GetObjectTypeByIndex(i); - asITypeInfo* parent = type->GetBaseType(); - - std::string scriptID = type->GetName(); - - if (parent == m_deerScript) { - ComponentScript componentScript(type); - m_componentScripts.insert({scriptID, componentScript}); - } - } - } - - Ref ScriptEngine::createComponentScriptInstance( - const std::string& scriptID, Entity& scriptEntity) { - ComponentScript& script = getComponentScript(scriptID); - asITypeInfo* type = script.getTypeInfo(); - - ComponentScriptInstance* instance = new ComponentScriptInstance(); - - std::string factoryString(script.getName()); - factoryString = factoryString + " @" + script.getName() + "()"; - - asIScriptFunction* function = - type->GetFactoryByDecl(factoryString.c_str()); - if (!function) { - DEER_SCRIPT_ERROR("Function constructor not found for class {0}", - script.getName()); - return nullptr; - } - - int r = m_context->Prepare(function); - if (r < 0) { - DEER_SCRIPT_ERROR( - "Failed to prepare constructor context for class {0}", - script.getName()); - return nullptr; - } - - r = m_context->Execute(); - if (r < 0) { - DEER_SCRIPT_ERROR("Failed to execute constructor for class {0}", - script.getName()); - return nullptr; - } - - asIScriptObject* obj = - *(asIScriptObject**)m_context->GetAddressOfReturnValue(); - obj->AddRef(); - - int entityPosition = script.getAttribute("entity").internalID; - unsigned int* entityValue = - (unsigned int*)obj->GetAddressOfProperty(entityPosition); - - *entityValue = scriptEntity.getId(); - - asIScriptFunction* updateFunction = - type->GetMethodByDecl("void update()"); - asIScriptFunction* startFunction = - type->GetMethodByDecl("void start()"); - instance->m_updateFunction = updateFunction; - instance->m_startFuction = startFunction; - instance->m_object = obj; - - return Ref(instance); - } - - void ScriptEngine::loadModuleFolder(const std::filesystem::path& modulePath, - const char* moduleName) { - CScriptBuilder builder; - - int r = builder.StartNewModule(m_scriptEngine, moduleName); - DEER_SCRIPT_ASSERT( - r >= 0, "Unrecoverable error while starting a new module. {0}", - moduleName); - - try { - DEER_CORE_TRACE("Loading Scripts "); - for (const auto& entry : - fs::recursive_directory_iterator(modulePath)) { - if (fs::is_regular_file(entry) && - entry.path().extension() == ".as") { - r = builder.AddSectionFromFile( - entry.path().generic_string().c_str()); - DEER_SCRIPT_ASSERT(r >= 0, - "Please correct the errors in the " - "script and try again. {0}", - entry.path().generic_string().c_str()); - - //DEER_CORE_TRACE(" {0}", - // entry.path().filename().string().c_str()); - } - } - } catch (const fs::filesystem_error& e) { - DEER_CORE_ERROR("Error while loading scripts, error: {0}", - e.what()); - } - - r = builder.BuildModule(); - if (r < 0) { - DEER_SCRIPT_INFO( - "Please correct the errors in the script and try again."); - m_isCompilationValid = false; - } - } - - void ScriptEngine::registerBaseComponents() { - RegisterStdString(m_scriptEngine); - RegisterScriptMath(m_scriptEngine); - - // Regist data types - registerEntity(m_scriptEngine); - registerVec3(m_scriptEngine); - - // Regist functions - registerDeerFunctions(m_scriptEngine); - registerInputFunctions(m_scriptEngine); - registerEntityTransformFunctions(m_scriptEngine); - } -} // namespace Deer \ No newline at end of file diff --git a/Deer/src/Deer/Scripting/ScriptEngineFunctions.cpp b/Deer/src/Deer/Scripting/ScriptEngineFunctions.cpp deleted file mode 100755 index 1100c00..0000000 --- a/Deer/src/Deer/Scripting/ScriptEngineFunctions.cpp +++ /dev/null @@ -1,249 +0,0 @@ -#include "ScriptEngineFunctions.h" - -#include "Deer/Enviroment.h" -#include "Deer/Log.h" -#include "Deer/Scene.h" -#include "Deer/ScriptEngine.h" -#include "DeerRender/Input.h" -#include "angelscript.h" -#include "glm/glm.hpp" - -namespace Deer { - void messageCallback(const asSMessageInfo* msg, void* param) { - if (msg->type == asMSGTYPE_WARNING) { - DEER_SCRIPT_WARN("({0} {1}) : {2} {3}", msg->row, msg->col, - msg->message, msg->section); - } else if (msg->type == asMSGTYPE_ERROR) { - DEER_SCRIPT_ERROR("({0} {1}) : {2} {3}", msg->row, msg->col, - msg->message, msg->section); - } else if (msg->type == asMSGTYPE_INFORMATION) { - DEER_SCRIPT_INFO("({0} {1}) : {2} {3}", msg->row, msg->col, - msg->message, msg->section); - } else { - DEER_SCRIPT_WARN("({0} {1}) : {2} {3}", msg->row, msg->col, - msg->message, msg->section); - } - } - - void print(std::string& msg) { DEER_SCRIPT_INFO(msg.c_str()); } - - glm::vec3 getEntityPosition(uint32_t& entityUID) { - if (entityUID == 0 || entityUID == 1) { - DEER_SCRIPT_ERROR("Entity is not invalid"); - return glm::vec3(); - } - - Environment& m_environment = Scene::environment; - Entity& entt = m_environment.getEntity(entityUID); - - return entt.getComponent().position; - } - - void setEntityPosition(glm::vec3 position, uint32_t& entityUID) { - if (entityUID == 0 || entityUID == 1) { - DEER_SCRIPT_ERROR("Entity is not invalid"); - return; - } - - Environment& m_environment = Scene::environment; - Entity& entt = m_environment.getEntity(entityUID); - - entt.getComponent().position = position; - } - - glm::vec3 getEntityScale(uint32_t& entityUID) { - if (entityUID == 0 || entityUID == 1) { - DEER_SCRIPT_ERROR("Entity is not invalid"); - return glm::vec3(); - } - - Environment& m_environment = Scene::environment; - Entity& entt = m_environment.getEntity(entityUID); - - return entt.getComponent().scale; - } - - void setEntityScale(glm::vec3 scale, uint32_t& entityUID) { - if (entityUID == 0 || entityUID == 1) { - DEER_SCRIPT_ERROR("Entity is not invalid"); - return; - } - - Environment& m_environment = Scene::environment; - Entity& entt = m_environment.getEntity(entityUID); - - entt.getComponent().scale = scale; - } - - uint32_t getEntityParent(uint32_t& entityUID) { - if (entityUID == 0 || entityUID == 1) { - DEER_SCRIPT_ERROR("Entity is not invalid"); - return 0; - } - - Environment& m_environment = Scene::environment; - Entity& entt = m_environment.getEntity(entityUID); - - return entt.getParentId(); - } - - bool isEntityValid(uint32_t& entityUID) { - if (entityUID == 0 || entityUID == 1) return false; - - Environment& m_environment = Scene::environment; - Entity& entt = m_environment.getEntity(entityUID); - - return entt.isValid(); - } - - void registerVec3(asIScriptEngine* engine) { - engine->RegisterObjectType("Vec3", sizeof(glm::vec3), - asOBJ_VALUE | asOBJ_POD | - asGetTypeTraits() | - asOBJ_APP_CLASS_ALLFLOATS); - - engine->RegisterObjectBehaviour( - "Vec3", asBEHAVE_CONSTRUCT, "void f()", - asFUNCTIONPR([](void* memory) { new (memory) glm::vec3(); }, - (void*), void), - asCALL_CDECL_OBJLAST); - engine->RegisterObjectBehaviour( - "Vec3", asBEHAVE_CONSTRUCT, "void f(float, float = 0, float = 0)", - asFUNCTIONPR([](float x, float y, float z, - void* memory) { new (memory) glm::vec3(x, y, z); }, - (float, float, float, void*), void), - asCALL_CDECL_OBJLAST); - engine->RegisterObjectProperty("Vec3", "float x", - asOFFSET(glm::vec3, x)); - engine->RegisterObjectProperty("Vec3", "float y", - asOFFSET(glm::vec3, y)); - engine->RegisterObjectProperty("Vec3", "float z", - asOFFSET(glm::vec3, z)); - - engine->RegisterObjectMethod( - "Vec3", "Vec3 opAdd(const Vec3 &in) const", - asFUNCTIONPR([](const glm::vec3& a, - const glm::vec3& b) -> glm::vec3 { return a + b; }, - (const glm::vec3&, const glm::vec3&), glm::vec3), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "Vec3 opSub(const Vec3 &in) const", - asFUNCTIONPR( - [](const glm::vec3& a, const glm::vec3& b) { return a - b; }, - (const glm::vec3&, const glm::vec3&), glm::vec3), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "Vec3 opMul(float) const", - asFUNCTIONPR( - [](const glm::vec3& a, float scalar) { return a * scalar; }, - (const glm::vec3&, float), glm::vec3), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "Vec3 opDiv(float) const", - asFUNCTIONPR( - [](const glm::vec3& a, float scalar) { return a / scalar; }, - (const glm::vec3&, float), glm::vec3), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "Vec3 normalize() const", - asFUNCTIONPR(glm::normalize, (const glm::vec3&), glm::vec3), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "float getMagnitude() const", - asFUNCTIONPR(glm::length, (const glm::vec3&), float), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "Vec3 opNeg() const", - asFUNCTIONPR([](const glm::vec3& a) { return -a; }, - (const glm::vec3&), glm::vec3), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod( - "Vec3", "bool opEquals(const Vec3 &in) const", - asFUNCTIONPR( - [](const glm::vec3& a, const glm::vec3& b) { return a == b; }, - (const glm::vec3&, const glm::vec3&), bool), - asCALL_CDECL_OBJFIRST); - - engine->RegisterObjectMethod("Vec3", "string opImplConv() const", - asFUNCTIONPR( - [](const glm::vec3& a) { - // Example string conversion using - // glm (you may need to format it) - char buffer[64]; - snprintf(buffer, sizeof(buffer), - "(%.2f, %.2f, %.2f)", a.x, - a.y, a.z); - return std::string(buffer); - }, - (const glm::vec3&), std::string), - asCALL_CDECL_OBJFIRST); - } - - void registerEntity(asIScriptEngine* engine) { - engine->RegisterObjectType( - "Entity", sizeof(unsigned int), - asOBJ_VALUE | asOBJ_POD | asOBJ_APP_PRIMITIVE); - engine->RegisterObjectProperty("Entity", "uint uint32_t", 0); - - engine->RegisterObjectMethod("Entity", "Entity getParent()", - asFUNCTION(Deer::getEntityParent), - asCALL_CDECL_OBJLAST); - engine->RegisterObjectMethod("Entity", "bool isValid()", - asFUNCTION(Deer::isEntityValid), - asCALL_CDECL_OBJLAST); - - engine->RegisterGlobalFunction( - "Entity getEntity(uint)", - asFUNCTIONPR([](uint32_t id) { return id; }, (uint32_t), uint32_t), - asCALL_CDECL); - } - - void registerDeerFunctions(asIScriptEngine* scriptEngine) { - int r = scriptEngine->SetMessageCallback( - asFUNCTION(Deer::messageCallback), 0, asCALL_CDECL); - DEER_SCRIPT_ASSERT(r >= 0, "Error in seting up angel script"); - - r = scriptEngine->RegisterGlobalFunction("void print(const string &in)", - asFUNCTION(Deer::print), - asCALL_CDECL); - DEER_SCRIPT_ASSERT(r >= 0, - "Error in seting up void print(const string &in)"); - } - - void registerInputFunctions(asIScriptEngine* scriptEngine) { - int r = scriptEngine->RegisterGlobalFunction( - "bool isKeyPressed(int)", asFUNCTION(Deer::Input::isKeyPressed), - asCALL_CDECL); - DEER_SCRIPT_ASSERT(r >= 0, "Error in seting up bool isKeyPressed(int)"); - } - - void registerEntityTransformFunctions(asIScriptEngine* scriptEngine) { - int r = scriptEngine->RegisterObjectMethod( - "Entity", "Vec3 getPosition()", asFUNCTION(Deer::getEntityPosition), - asCALL_CDECL_OBJLAST); - DEER_SCRIPT_ASSERT(r >= 0, "Error in seting up Vec3 getPosition()"); - - scriptEngine->RegisterObjectMethod("Entity", "void setPosition(Vec3)", - asFUNCTION(Deer::setEntityPosition), - asCALL_CDECL_OBJLAST); - DEER_SCRIPT_ASSERT(r >= 0, "Error in seting up void setPosition(Vec3)"); - - r = scriptEngine->RegisterObjectMethod("Entity", "Vec3 getScale()", - asFUNCTION(Deer::getEntityScale), - asCALL_CDECL_OBJLAST); - DEER_SCRIPT_ASSERT(r >= 0, "Error in seting up Vec3 getScale()"); - - scriptEngine->RegisterObjectMethod("Entity", "void setScale(Vec3)", - asFUNCTION(Deer::setEntityScale), - asCALL_CDECL_OBJLAST); - DEER_SCRIPT_ASSERT(r >= 0, "Error in seting up void setScale(Vec3)"); - } - -} // namespace Deer \ No newline at end of file diff --git a/Deer/src/Deer/Scripting/ScriptEngineFunctions.h b/Deer/src/Deer/Scripting/ScriptEngineFunctions.h deleted file mode 100755 index 91375f5..0000000 --- a/Deer/src/Deer/Scripting/ScriptEngineFunctions.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - - -#include -#include "glm/glm.hpp" - -struct asSMessageInfo; -class asIScriptEngine; - -namespace Deer { - void messageCallback(const asSMessageInfo* msg, void* param); - void print(std::string& msg); - - // Entity Transformations ------------- - glm::vec3 getEntityPosition(uint32_t& entityUID); - void setEntityPosition(glm::vec3 position, uint32_t& entityUID); - glm::vec3 getEntityScale(uint32_t& entityUID); - void setEntityScale(glm::vec3 scale, uint32_t& entityUID); - // Entity Transformations ------------- - - // Entity Relationship ------------ - uint32_t getEntityParent(uint32_t& entityUID); - bool isEntityValid(uint32_t& entityUID); - // Entity Relationship ------------ - - void registerVec3(asIScriptEngine* engine); - void registerEntity(asIScriptEngine* engine); - - void registerDeerFunctions(asIScriptEngine* scriptEngine); - void registerInputFunctions(asIScriptEngine* scriptEngine); - void registerEntityTransformFunctions(asIScriptEngine* scriptEngine); -} \ No newline at end of file diff --git a/Deer/src/DeerRender/Render/Render.cpp b/Deer/src/DeerRender/Render/Render.cpp index eea9b03..cad854e 100755 --- a/Deer/src/DeerRender/Render/Render.cpp +++ b/Deer/src/DeerRender/Render/Render.cpp @@ -4,7 +4,7 @@ #include "DeerRender/Render/RenderAPI.h" namespace Deer { - void Render::beginExecution() { + void Render::initExecution() { } diff --git a/Deer/src/DeerRender/Render/Render.h b/Deer/src/DeerRender/Render/Render.h index 0d8440b..87bc697 100755 --- a/Deer/src/DeerRender/Render/Render.h +++ b/Deer/src/DeerRender/Render/Render.h @@ -6,7 +6,7 @@ namespace Deer { class Render { public: - static void beginExecution(); + static void initExecution(); static void endExecution(); static void submit(VertexArray& vertexArray); diff --git a/DeerStudio/src/DeerStudio/DeerStudio.cpp b/DeerStudio/src/DeerStudio/DeerStudio.cpp index 1358857..cfa1b3e 100755 --- a/DeerStudio/src/DeerStudio/DeerStudio.cpp +++ b/DeerStudio/src/DeerStudio/DeerStudio.cpp @@ -76,7 +76,7 @@ namespace Deer { void DeerStudioApplication::onUpdate(Timestep delta) { if (Scene::getExecutingState()) - Scene::tick(); + Scene::tickExecution(); if (VoxelWorld::isInitialized()) VoxelWorld::bakeNextChunk(); diff --git a/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp b/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp index a0f8ec2..ed2d972 100755 --- a/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp +++ b/DeerStudio/src/DeerStudio/Editor/GamePanel.cpp @@ -30,7 +30,7 @@ namespace Deer { if (ScriptEngine::isCompilationValid() && ImGui::Button("Execute")) { DataStore::exportRuntimeScene(); - Scene::beginExecution(); + Scene::initExecution(); } } else { if (ImGui::Button("Stop")) { @@ -78,7 +78,7 @@ namespace Deer { if (ScriptEngine::isCompilationValid() && ImGui::Button("Execute")) { DataStore::exportRuntimeScene(); - Scene::beginExecution(); + Scene::initExecution(); } } else { if (ImGui::Button("Stop")) { diff --git a/roe/imgui.ini b/roe/imgui.ini index 17d8675..7682b7d 100644 --- a/roe/imgui.ini +++ b/roe/imgui.ini @@ -36,7 +36,7 @@ DockId=0x00000004,0 Pos=377,24 Size=532,462 Collapsed=0 -DockId=0x00000006,2 +DockId=0x00000006,1 [Window][Scene Explorer] Pos=0,389 @@ -97,10 +97,10 @@ Collapsed=0 DockId=0x00000008,1 [Window][Test] -Pos=377,24 -Size=532,462 +Pos=911,24 +Size=369,462 Collapsed=0 -DockId=0x00000006,1 +DockId=0x00000004,2 [Docking][Data] DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y @@ -109,7 +109,7 @@ DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y DockNode ID=0x00000003 Parent=0x00000001 SizeRef=909,338 Split=X Selected=0x13926F0B DockNode ID=0x00000005 Parent=0x00000003 SizeRef=375,446 Selected=0xE45B9F93 DockNode ID=0x00000006 Parent=0x00000003 SizeRef=532,446 CentralNode=1 Selected=0x13926F0B - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=369,338 Selected=0xA35A27E3 + DockNode ID=0x00000004 Parent=0x00000001 SizeRef=369,338 Selected=0x44A6A033 DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702 DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,232 Selected=0xD962995A diff --git a/roe/tmp/voxel_texture_atlas.png b/roe/tmp/voxel_texture_atlas.png index e4fe44e..ae08728 100644 Binary files a/roe/tmp/voxel_texture_atlas.png and b/roe/tmp/voxel_texture_atlas.png differ