Compare commits

..

No commits in common. "3cc97f579f252bfd97622278f27401ff47e69b0b" and "905e66b2410cccce8cb11b95933b7d0adba369d3" have entirely different histories.

16 changed files with 88 additions and 207 deletions

View File

@ -16,4 +16,3 @@ BraceWrapping:
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Attach
NamespaceIndentation: All
PointerAlignment: Left

View File

@ -67,8 +67,8 @@ Size=104,68
Collapsed=0
[Window][Test]
Pos=560,275
Size=396,176
Pos=60,60
Size=55,82
Collapsed=0
[Docking][Data]

View File

@ -1,127 +1,10 @@
#include "ServiceScriptGenericFunction.h"
#include "Deer/Log.h"
#include "DeerStudio/EditorEngine/ErrorHandle.h"
#include "angelscript.h"
namespace Deer {
bool copyParameter(asIScriptContext* ctx, int paramIndex, int typeId,
asDWORD flags, asIScriptGeneric* gen);
bool copyReturnValue(asIScriptGeneric* gen, asIScriptContext* ctx,
asIScriptFunction* func);
void EditorEngine::apiFunction(asIScriptGeneric *func) {
ServiceScriptFunction* serviceScriptFunction =
(ServiceScriptFunction*)func->GetAuxiliary();
asIScriptContext* context = serviceScriptFunction->scriptContext;
asIScriptFunction* apiFunction = serviceScriptFunction->apiFunction;
DEER_CORE_ASSERT(context, "Nullptr service script context calling {0}",
DEER_CORE_TRACE("Called function {0}",
func->GetFunction()->GetDeclaration());
AS_CHECK(context->Prepare(apiFunction));
AS_CHECK(context->SetObject(serviceScriptFunction->scriptObject));
// Extract atributes
asUINT paramCount = apiFunction->GetParamCount();
for (asUINT i = 0; i < paramCount; i++) {
int type;
asDWORD flags;
apiFunction->GetParam(i, &type, &flags, nullptr);
copyParameter(context, i, type, flags, func);
}
AS_CHECK(context->Execute());
copyReturnValue(func, context, apiFunction);
AS_CHECK(context->Unprepare());
}
bool copyParameter(asIScriptContext* ctx, int paramIndex, int typeId,
asDWORD flags, asIScriptGeneric* gen) {
if (flags & asTM_OUTREF) {
// Skip out refs for now
// Unsupported type
DEER_EDITOR_ENGINE_WARN(
"Skipping our ref type {0} when calling {1}",
ctx->GetEngine()->GetTypeDeclaration(typeId, true),
gen->GetFunction()->GetDeclaration());
return false;
}
if (typeId == asTYPEID_INT32) {
ctx->SetArgDWord(paramIndex, gen->GetArgDWord(paramIndex));
} else if (typeId == asTYPEID_FLOAT) {
ctx->SetArgFloat(paramIndex, gen->GetArgFloat(paramIndex));
} else if (typeId == asTYPEID_DOUBLE) {
ctx->SetArgDouble(paramIndex, gen->GetArgDouble(paramIndex));
} else if (typeId == asTYPEID_INT64) {
ctx->SetArgQWord(paramIndex, gen->GetArgQWord(paramIndex));
} else if (typeId & asTYPEID_OBJHANDLE) {
void* obj =
gen->GetArgAddress(paramIndex); // Use GetArgAddress instead of
// GetArgObject for handles
ctx->SetArgObject(paramIndex, obj);
} else if (typeId & asTYPEID_MASK_OBJECT) {
void* obj = gen->GetArgObject(paramIndex);
ctx->SetArgObject(paramIndex, obj);
} else {
// Unsupported type
DEER_EDITOR_ENGINE_WARN(
"Unsuported type {0} when calling {1}",
ctx->GetEngine()->GetTypeDeclaration(typeId, true),
gen->GetFunction()->GetDeclaration());
return false;
}
return true;
}
bool copyReturnValue(asIScriptGeneric* gen, asIScriptContext* ctx,
asIScriptFunction* func) {
int returnTypeId = func->GetReturnTypeId();
asITypeInfo* typeInfo = ctx->GetEngine()->GetTypeInfoById(returnTypeId);
if (returnTypeId == asTYPEID_VOID) {
// Nothing to return
return true;
}
if (returnTypeId == asTYPEID_INT32) {
gen->SetReturnDWord(ctx->GetReturnDWord());
} else if (returnTypeId == asTYPEID_FLOAT) {
gen->SetReturnFloat(ctx->GetReturnFloat());
} else if (returnTypeId == asTYPEID_DOUBLE) {
gen->SetReturnDouble(ctx->GetReturnDouble());
} else if (returnTypeId == asTYPEID_INT64) {
gen->SetReturnQWord(ctx->GetReturnQWord());
} else if (returnTypeId & asTYPEID_OBJHANDLE) {
void* obj = ctx->GetReturnAddress(); // For handles, this returns
// the pointer
gen->SetReturnAddress(obj);
} else if (returnTypeId & asTYPEID_MASK_OBJECT) {
bool isRef = (typeInfo->GetFlags() & asOBJ_REF) != 0;
if (isRef) {
void* obj = ctx->GetReturnObject();
gen->SetReturnObject(obj);
} else {
void* src = ctx->GetReturnObject();
void* dst = gen->GetAddressOfReturnLocation();
memcpy(dst, src, typeInfo->GetSize());
}
} else {
DEER_EDITOR_ENGINE_WARN(
"Unsupported return type {0} in call to {1}",
ctx->GetEngine()->GetTypeDeclaration(returnTypeId, true),
func->GetDeclaration());
return false;
}
return true;
}
} // namespace Deer

View File

@ -1,20 +1,16 @@
#pragma once
#include "angelscript.h"
class asIScriptGeneric;
class asIScriptFunction;
class asIScriptContext;
class asIScriptObject;
namespace Deer {
namespace EditorEngine {
struct ServiceScriptObject;
struct ServiceScriptFunction {
asIScriptFunction* apiFunction = nullptr;
asIScriptContext* scriptContext = nullptr;
asIScriptObject* scriptObject = nullptr;
};
void apiFunction(asIScriptGeneric *gen);
struct ApiFunctionData {
uint16_t serviceContextId;
uint16_t serviceObjectId;
};
} // namespace EditorEngine
} // namespace Deer

View File

@ -171,16 +171,9 @@ namespace Deer {
DEER_CORE_INFO(ext_dec.str().c_str());
ServiceScriptFunction* serviceScriptFunction =
new ServiceScriptFunction();
serviceScriptFunction->apiFunction = func;
serviceScriptFunction->scriptContext = scriptContext;
serviceScriptFunction->scriptObject = object;
AS_CHECK(scriptEngine->RegisterGlobalFunction(
ext_dec.str().c_str(), asFUNCTION(apiFunction),
asCALL_GENERIC, serviceScriptFunction));
asCALL_GENERIC));
}
}
} // namespace EditorEngine

View File

@ -1,7 +1,7 @@
#include "DeerStudio/DeerStudio.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
#include "DeerStudio/EditorEngine/DockPanel/DockPanelObject.h"
#include "DeerStudio/EditorEngine/DockPanel/DockPanelContext.h"
#include "imgui.h"
@ -10,8 +10,8 @@ namespace Deer {
void panelEnable(EditorEngine::DockPanelObject& dpo);
void onPannelMenuBar() {
for (EditorEngine::DockPanelContext& pc :
EditorEngine::dockPanelModules) {
if (ImGui::BeginMenu("Dock Panels Show/Hide")) {
for (EditorEngine::DockPanelContext& pc : EditorEngine::dockPanelModules) {
if (pc.dockPanels.size() == 0)
continue;
@ -28,6 +28,8 @@ namespace Deer {
ImGui::EndMenu();
}
}
ImGui::EndMenu();
}
}
void panelEnable(EditorEngine::DockPanelObject& dpo) {
@ -38,5 +40,5 @@ namespace Deer {
dpo.setFlag(DockPannelFlag_ShowPannel, !enabled);
}
}
} // namespace DeerStudio
} // namespace Deer
}
}

View File

@ -1,3 +1,4 @@
void addComponentPopup(any@ data) {
Entity entity;
data.retrieve(entity);

View File

@ -1,3 +1,4 @@
void renderMeshComponent(any@ data) {
Entity entity;
data.retrieve(entity);
@ -41,6 +42,7 @@ void renderMeshComponent(any@ data) {
}
}
void setMeshComponentMesh(any@ meshComponent_data, any@ mesh_data){
string mesh;
mesh_data.retrieve(mesh);

View File

@ -1,10 +1,11 @@
class PropertiesPannel : DockPanel {
float slider = 0;
vec3 slid;
vec3 slid2;
void onRender() {
Entity entity = Chewico::ActiveEntity::ActiveEntity::getActiveEntity();
Entity entity = activeEntity;
// We don't want to change root options
if (entity.isRoot)
@ -18,6 +19,7 @@ class PropertiesPannel : DockPanel {
UI::separator();
UI::textColor(0.5, 0.5, 0.5f, "Id : " + entity.id);
UI::sameline();
if (UI::buttonEnd("Add Component")) {
UI::openPopup("ADD_COMPONENT", any(entity));
@ -39,6 +41,7 @@ class PropertiesPannel : DockPanel {
UI::componentNode_contextMenu("Camera Component", any(entity), renderCameraComponent, removeCameraComponent);
}
UI::space();
UI::separator();

View File

@ -1,3 +1,4 @@
void setShaderComponent(any@ shaderComponent_data, any@ shader_data) {
string shader;
shader_data.retrieve(shader);

View File

@ -21,7 +21,7 @@ class TreePannel : DockPanel {
for (int i = 0; i < entity.childs.count; i++) {
Entity child = entity.childs[i];
bool isActive = child == Chewico::ActiveEntity::ActiveEntity::getActiveEntity();
bool isActive = child == activeEntity;
string displayName = child.name;
if (displayName == "") {
@ -52,7 +52,7 @@ class TreePannel : DockPanel {
// We can't select the entity
if (UI::isItemClicked(0)) {
Chewico::ActiveEntity::ActiveEntity::setActiveEntity(entity);
activeEntity = entity;
}
}

View File

@ -0,0 +1,2 @@
Entity activeEntity = Engine::getRoot();

View File

@ -1,3 +1,4 @@
void renameEntity(any@ data) {
Entity entity;
data.retrieve(entity);

View File

@ -1,8 +1,6 @@
class Test : DockPanel {
void onRender() {
Entity ent = Chewico::ActiveEntity::ActiveEntity::getActiveEntity();
UI::text("Hi");
UI::text(ent.name);
Chewico::ActiveEntity::ActiveEntity::getActiveEntity();
}
}