Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groups now have a "children_no_navmesh" checkbox that updates the "no_navmesh" value of it's children. #148

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Source/GUI/dimgui/dimgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,20 @@ static void DrawLaunchCustomGuiButton(Object* obj, bool& are_script_params_read_
}
}

static void UpdateChildrenNoNavmesh(Group* group, bool enabled) {
for (auto& i : group->children) {
if (i.direct_ptr->GetType() == _env_object) {
EnvObject* eo = (EnvObject*)i.direct_ptr;
eo->no_navmesh = enabled;
}
if (i.direct_ptr->GetType() == _group) {
Group* sub_group = (Group*)i.direct_ptr;
sub_group->children_no_navmesh = enabled;
UpdateChildrenNoNavmesh(sub_group, enabled);
}
}
}

static void DrawObjectInfoFlat(Object* obj) {
ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
obj->DrawImGuiEditor();
Expand Down Expand Up @@ -1255,6 +1269,15 @@ static void DrawObjectInfoFlat(Object* obj) {
ImGui::Checkbox("no_navmesh", &eo->no_navmesh);
}

if (obj->GetType() == _group) {
Group* group = (Group*)obj;
ImGui::Separator();
if (ImGui::Checkbox("children_no_navmesh", &group->children_no_navmesh)) {
bool enabled = group->children_no_navmesh;
UpdateChildrenNoNavmesh(group, enabled);
}
}

ImGui::Separator();
if (obj->GetType() == _movement_object) {
MovementObject* mov_obj = (MovementObject*)obj;
Expand Down Expand Up @@ -1424,6 +1447,15 @@ static void DrawObjectInfo(Object* obj, bool force_expand_script_params) {
}
}

if (obj->GetType() == _group) {
Group* group = (Group*)obj;
ImGui::Separator();
if (ImGui::Checkbox("children_no_navmesh", &group->children_no_navmesh)) {
bool enabled = group->children_no_navmesh;
UpdateChildrenNoNavmesh(group, enabled);
}
}

if (obj->GetType() == _movement_object) {
MovementObject* mo = (MovementObject*)obj;
if (ImGui::TreeNode("Color Palette")) {
Expand Down
15 changes: 15 additions & 0 deletions Source/Game/EntityDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,14 @@ void EntityDescription::SaveToXML(TiXmlElement* parent) const {
}
break;
}
case EDF_CHILDREN_NO_NAVMESH: {
bool val;
field.ReadBool(&val);
if (val) {
object->SetAttribute("children_no_navmesh", "true");
}
break;
}
case EDF_PREFAB_LOCKED: {
bool val;
field.ReadBool(&val);
Expand Down Expand Up @@ -868,6 +876,13 @@ void LoadGroupDescriptionFromXML(EntityDescription& desc, const TiXmlElement* el
}
desc.AddVec3(EDF_COLOR, color);

const char* children_no_navmesh = el->Attribute("children_no_navmesh");
if (children_no_navmesh) {
desc.AddBool(EDF_CHILDREN_NO_NAVMESH, saysTrue(children_no_navmesh) == 1);
} else {
desc.AddBool(EDF_CHILDREN_NO_NAVMESH, false);
}

LoadEntityDescriptionListFromXML(desc.children, el);
}

Expand Down
1 change: 1 addition & 0 deletions Source/Game/EntityDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ enum EntityDescriptionFieldType {
EDF_GI_COEFFICIENTS,
EDF_NAV_MESH_CONNECTIONS,
EDF_NO_NAVMESH,
EDF_CHILDREN_NO_NAVMESH, //Used for groups.
EDF_PREFAB_LOCKED,
EDF_PREFAB_PATH,
EDF_ORIGINAL_SCALE,
Expand Down
12 changes: 11 additions & 1 deletion Source/Objects/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ extern bool g_debug_runtime_disable_group_pre_draw_camera;
extern bool g_debug_runtime_disable_group_pre_draw_frame;

Group::Group() : child_transforms_need_update(false),
child_moved(false) {
child_moved(false),
children_no_navmesh(false) {
box_.dims = vec3(1.0f);
}

Expand Down Expand Up @@ -118,6 +119,14 @@ bool Group::SetFromDesc(const EntityDescription& desc) {
if (!version_edf) {
InitShape();
}
for (const auto& field : desc.fields) {
switch (field.type) {
case EDF_CHILDREN_NO_NAVMESH: {
field.ReadBool(&children_no_navmesh);
break;
}
}
}

InitRelMats();
}
Expand All @@ -137,6 +146,7 @@ void Group::GetDesc(EntityDescription& desc) const {
obj->GetDesc(desc.children.back());
}
}
desc.AddBool(EDF_CHILDREN_NO_NAVMESH, children_no_navmesh);
}

void Group::InitRelMats() {
Expand Down
1 change: 1 addition & 0 deletions Source/Objects/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Group : public Object {
std::vector<Child> children;
bool child_transforms_need_update;
bool child_moved;
bool children_no_navmesh;

Group();
bool Initialize() override;
Expand Down