Skip to content

Commit

Permalink
Fix building export templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Beliar83 committed Feb 23, 2023
1 parent 76b6755 commit dc730aa
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 55 deletions.
3 changes: 3 additions & 0 deletions modules/bullet_physics/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,6 @@ if env["builtin_bullet"]:

# Bullet Physics ECS
env_bullet.add_source_files(env.modules_sources, "*.cpp")

if env_bullet.editor_build:
env_bullet.add_source_files(env.modules_sources, "editor/*.cpp")
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "components_gizmos.h"

#include "debug_utilities.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "../debug_utilities.h"

void BtBoxGizmo::init() {
const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1));
Expand Down Expand Up @@ -752,6 +752,7 @@ void BtConvexGizmo::init() {
}

void BtConvexGizmo::redraw(EditorNode3DGizmo *p_gizmo) {
#ifdef TOOLS_ENABLED
Entity3D *entity = static_cast<Entity3D *>(p_gizmo->get_node_3d());
ERR_FAIL_COND(entity == nullptr);

Expand All @@ -767,7 +768,6 @@ void BtConvexGizmo::redraw(EditorNode3DGizmo *p_gizmo) {
mesh = td->mesh;
}
}

if (mesh.is_null()) {
const Vector<Vector3> points = entity->get_component_value(convex_component_name, points_name);
mesh = generate_mesh_from_points(points);
Expand All @@ -778,6 +778,7 @@ void BtConvexGizmo::redraw(EditorNode3DGizmo *p_gizmo) {

p_gizmo->add_mesh(mesh, material);
}
#endif
}

int BtConvexGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const {
Expand All @@ -804,6 +805,7 @@ void BtTrimeshGizmo::init() {
}

void BtTrimeshGizmo::redraw(EditorNode3DGizmo *p_gizmo) {
#ifdef TOOLS_ENABLED
Entity3D *entity = static_cast<Entity3D *>(p_gizmo->get_node_3d());
ERR_FAIL_COND(entity == nullptr);

Expand All @@ -819,7 +821,6 @@ void BtTrimeshGizmo::redraw(EditorNode3DGizmo *p_gizmo) {
mesh = td->mesh;
}
}

if (mesh.is_null()) {
const Vector<Vector3> faces = entity->get_component_value(trimesh_component_name, faces_name);
mesh = generate_mesh_from_faces(faces);
Expand All @@ -830,6 +831,7 @@ void BtTrimeshGizmo::redraw(EditorNode3DGizmo *p_gizmo) {

p_gizmo->add_mesh(mesh, material);
}
#endif
}

int BtTrimeshGizmo::get_handle_count(const EditorNode3DGizmo *p_gizmo) const {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "../godot/editor_plugins/components_gizmo_3d.h"
#include "../../godot/editor_plugins/components_gizmo_3d.h"

class BtBoxGizmo : public ComponentGizmo {
StringName box_component_name = "BtBox";
Expand Down
6 changes: 5 additions & 1 deletion modules/bullet_physics/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "../godot/editor_plugins/components_gizmo_3d.h"
#include "components_area.h"
#include "components_generic.h"
#include "components_gizmos.h"
#ifdef TOOLS_ENABLED
#include "editor/components_gizmos.h"
#endif
#include "components_pawn.h"
#include "components_rigid_body.h"
#include "databag_space.h"
Expand Down Expand Up @@ -153,6 +155,7 @@ void initialize_bullet_physics_module(ModuleInitializationLevel p_level) {
.add("BtOverlapCheck");

} else if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
#ifdef TOOLS_ENABLED
// Register gizmos
Components3DGizmoPlugin::get_singleton()->add_component_gizmo(memnew(BtBoxGizmo));
Components3DGizmoPlugin::get_singleton()->add_component_gizmo(memnew(BtSphereGizmo));
Expand All @@ -162,6 +165,7 @@ void initialize_bullet_physics_module(ModuleInitializationLevel p_level) {
Components3DGizmoPlugin::get_singleton()->add_component_gizmo(memnew(BtConvexGizmo));
Components3DGizmoPlugin::get_singleton()->add_component_gizmo(memnew(BtTrimeshGizmo));
Components3DGizmoPlugin::get_singleton()->add_component_gizmo(memnew(BtPawnGizmo));
#endif
}
}

Expand Down
4 changes: 3 additions & 1 deletion modules/godot/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ env_godot_module = env_modules.Clone()
env_godot_module.add_source_files(env.modules_sources, "*.cpp")
env_godot_module.add_source_files(env.modules_sources, "components/*.cpp")
env_godot_module.add_source_files(env.modules_sources, "components/physics/*.cpp")
env_godot_module.add_source_files(env.modules_sources, "editor_plugins/*.cpp")
env_godot_module.add_source_files(env.modules_sources, "nodes/*.cpp")
env_godot_module.add_source_files(env.modules_sources, "databags/*.cpp")
env_godot_module.add_source_files(env.modules_sources, "systems/*.cpp")

if env_godot_module.editor_build:
env_godot_module.add_source_files(env.modules_sources, "editor_plugins/*.cpp")
43 changes: 25 additions & 18 deletions modules/godot/nodes/ecs_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "core/object/script_language.h"
#include "editor/editor_node.h"
#include "entity.h"
#include "shared_component_resource.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
#endif

void System::_bind_methods() {
ClassDB::bind_method(D_METHOD("execute_in", "phase", "dispatcher"), &System::execute_in, DEFVAL(godex::SYSTEM_NONE));
Expand Down Expand Up @@ -113,13 +115,13 @@ void System::prepare(godex::DynamicSystemExecutionData *p_info) {

String System::validate_script(Ref<Script> p_script) {
if (p_script.is_null()) {
return TTR("Script is null.");
return RTR("Script is null.");
}
if (p_script->is_valid() == false) {
return TTR("Script has some errors.");
return RTR("Script has some errors.");
}
if ("System" != p_script->get_instance_base_type()) {
return TTR("This script is not extending `System`.");
return RTR("This script is not extending `System`.");
}
List<MethodInfo> methods;
p_script->get_script_method_list(&methods);
Expand All @@ -135,22 +137,25 @@ String System::validate_script(Ref<Script> p_script) {
}
}
if (has_prepare == false) {
return TTR("This script is not overriding the function `_prepare()`.");
return RTR("This script is not overriding the function `_prepare()`.");
}
if (has_execute == false) {
return TTR("This script is not overriding the function `_execute(...)`.");
return RTR("This script is not overriding the function `_execute(...)`.");
}

List<PropertyInfo> properties;

#ifdef TOOLS_ENABLED
p_script->get_script_property_list(&properties);
for (List<PropertyInfo>::Element *e = properties.front(); e; e = e->next()) {
if (e->get().name == p_script->get_class_category().name) {
properties.erase(e);
}
}
#endif

if (properties.size()) {
return TTR("The System script can't have any property in it. It possible to only access `Component`s and `Databag`s.");
return RTR("The System script can't have any property in it. It possible to only access `Component`s and `Databag`s.");
}

// This script is safe to use.
Expand Down Expand Up @@ -247,13 +252,13 @@ void SystemBundle::execute_after(uint32_t p_system_id) {

String SystemBundle::validate_script(Ref<Script> p_script) {
if (p_script.is_null()) {
return TTR("Script is null.");
return RTR("Script is null.");
}
if (p_script->is_valid() == false) {
return TTR("Script has some errors.");
return RTR("Script has some errors.");
}
if ("SystemBundle" != p_script->get_instance_base_type()) {
return TTR("This script is not extending `SystemBundle`.");
return RTR("This script is not extending `SystemBundle`.");
}
List<MethodInfo> methods;
p_script->get_script_method_list(&methods);
Expand All @@ -265,7 +270,7 @@ String SystemBundle::validate_script(Ref<Script> p_script) {
}
}
if (has_prepare == false) {
return TTR("This script is not overriding the function `_prepare()`.");
return RTR("This script is not overriding the function `_prepare()`.");
}
// This script is safe to use.
return "";
Expand Down Expand Up @@ -314,13 +319,13 @@ Vector<StringName> Component::get_spawners() {

String Component::validate_script(Ref<Script> p_script) {
if (p_script.is_null()) {
return TTR("Script is null.");
return RTR("Script is null.");
}
if (p_script->is_valid() == false) {
return TTR("Script has some errors.");
return RTR("Script has some errors.");
}
if ("Component" != p_script->get_instance_base_type()) {
return TTR("This script is not extending `Component`.");
return RTR("This script is not extending `Component`.");
}

// Make sure doesn't have any function in it.
Expand All @@ -331,29 +336,31 @@ String Component::validate_script(Ref<Script> p_script) {
for (int i = 0; i < methods.size(); i += 1) {
// Only this method is allowed.
if (methods[i].name != "@implicit_new" && methods[i].name != "get_spawners") {
return TTR("The only method the Component can have is the `get_spawners()`.");
return RTR("The only method the Component can have is the `get_spawners()`.");
}
}

List<PropertyInfo> properties;
p_script->get_script_property_list(&properties);
for (List<PropertyInfo>::Element *e = properties.front(); e; e = e->next()) {
#ifdef TOOLS_ENABLED
if (
// Filter GDScript file name
e->get().name == p_script->get_class_category().name
// Filter C# file name. It uses only the class name
|| p_script->get_path().ends_with(e->get().name + ".cs")) {
continue;
}
#endif
switch (e->get().type) {
case Variant::NIL:
return "(" + e->get().name + ") " + TTR("Please make sure all variables are typed.");
return "(" + e->get().name + ") " + RTR("Please make sure all variables are typed.");
case Variant::RID:
case Variant::OBJECT:
return "(" + e->get().name + ") " + TTR("The Component can't hold unsafe references. The same reference could be holded by multiple things into the engine, this invalidates the thread safety of the ECS model. Please use a Databag or report your use case so a safe native type will be provided instead.");
return "(" + e->get().name + ") " + RTR("The Component can't hold unsafe references. The same reference could be holded by multiple things into the engine, this invalidates the thread safety of the ECS model. Please use a Databag or report your use case so a safe native type will be provided instead.");
case Variant::SIGNAL:
case Variant::CALLABLE:
return "(" + e->get().name + ") " + TTR("The Component can't hold signals or callables. Please report your use case.");
return "(" + e->get().name + ") " + RTR("The Component can't hold signals or callables. Please report your use case.");
default:
// Nothing to worry about.
break;
Expand Down
3 changes: 2 additions & 1 deletion modules/godot/nodes/ecs_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ World *WorldECS::get_world() const {
return world;
}

#ifdef TOOLS_ENABLED
PackedStringArray WorldECS::get_configuration_warnings() const {
Vector<String> warnings = Node::get_configuration_warnings();

Expand Down Expand Up @@ -447,9 +448,9 @@ PackedStringArray WorldECS::get_configuration_warnings() const {
}
}
}

return warnings;
}
#endif

void WorldECS::set_pipelines(Vector<Ref<PipelineECS>> p_pipelines) {
pipelines = p_pipelines;
Expand Down
4 changes: 2 additions & 2 deletions modules/godot/nodes/ecs_world.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ class WorldECS : public Node {
/// possible to do it via the commands object that you can take using:
/// `ECS::get_singleton()->get_commands()`
World *get_world() const;

#ifdef TOOLS_ENABLED
virtual PackedStringArray get_configuration_warnings() const override;

#endif
void set_pipelines(Vector<Ref<PipelineECS>> p_pipelines);
const Vector<Ref<PipelineECS>> &get_pipelines() const;
Vector<Ref<PipelineECS>> &get_pipelines();
Expand Down
Loading

0 comments on commit dc730aa

Please sign in to comment.