Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxor4d committed Mar 6, 2022
2 parents 32e1956 + b1a6ab2 commit 6a97ea2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 38 deletions.
78 changes: 41 additions & 37 deletions src/components/modules/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,62 +342,66 @@ namespace components

void effects::fx_origin_frame()
{
const auto edit_ent = game::g_edit_entity();
// edit_entity is unsave and can point to junk memory when transitioning into and out of prefabs
// use selected_brushes->def->owner instead

if(edit_ent && edit_ent->eclass && edit_ent->eclass->classtype == game::ECLASS_RADIANT_NODE)
const auto b = game::g_selected_brushes();

if(b && b->def && b->def->owner)
{
if(utils::string_equals(ggui::entity::ValueForKey(edit_ent->epairs, "classname"), "fx_origin"))
const auto edit_ent = b->def->owner;

if(edit_ent->eclass && edit_ent->eclass->classtype == game::ECLASS_RADIANT_NODE)
{
is_fx_origin_selected_ = true;

if (utils::string_equals(ggui::entity::ValueForKey(edit_ent->epairs, "classname"), "fx_origin"))
{
is_fx_origin_selected_ = true;

memcpy(editor_origin_from_fx_origin, edit_ent->origin, sizeof(game::vec3_t));
memcpy(editor_origin_from_fx_origin, edit_ent->origin, sizeof(game::vec3_t));

ggui::entity::Entity_GetVec3ForKey(reinterpret_cast<game::entity_s*>(edit_ent), editor_angles_from_fx_origin, "angles");
ggui::entity::Entity_GetVec3ForKey(reinterpret_cast<game::entity_s*>(edit_ent), editor_angles_from_fx_origin, "angles");

const auto fx_name = ggui::entity::ValueForKey(edit_ent->epairs, "fx");
const auto fx_name = ggui::entity::ValueForKey(edit_ent->epairs, "fx");


if (fx_name && !utils::string_equals(fx_system::ed_editor_effect.name, fx_name))
{
if (!effects_editor::has_unsaved_changes())
if (fx_name && !utils::string_equals(fx_system::ed_editor_effect.name, fx_name))
{
effects::load_effect(fx_name);
if (!effects_editor::has_unsaved_changes())
{
effects::load_effect(fx_name);
}
}
}
else if (fx_system::ed_active_effect && (effects::effect_is_playing() || effects::effect_is_paused()))
{
// use "fx_origin" origin to update effect position
memcpy(fx_system::ed_active_effect->frameAtSpawn.origin, edit_ent->origin, sizeof(game::vec3_t));
memcpy(fx_system::ed_active_effect->frameNow.origin, edit_ent->origin, sizeof(game::vec3_t));
else if (fx_system::ed_active_effect && (effects::effect_is_playing() || effects::effect_is_paused()))
{
// use "fx_origin" origin to update effect position
memcpy(fx_system::ed_active_effect->frameAtSpawn.origin, edit_ent->origin, sizeof(game::vec3_t));
memcpy(fx_system::ed_active_effect->frameNow.origin, edit_ent->origin, sizeof(game::vec3_t));


// use "fx_origin" angles to update effect angles - update spawn axis
utils::vector::angle_vectors(editor_angles_from_fx_origin, spawn_axis_rotated[2], spawn_axis_rotated[1], spawn_axis_rotated[0]);
// use "fx_origin" angles to update effect angles - update spawn axis
utils::vector::angle_vectors(editor_angles_from_fx_origin, spawn_axis_rotated[2], spawn_axis_rotated[1], spawn_axis_rotated[0]);

float quat[4] = {};
fx_system::AxisToQuat(spawn_axis_rotated, quat);
float quat[4] = {};
fx_system::AxisToQuat(spawn_axis_rotated, quat);

memcpy(fx_system::ed_active_effect->frameAtSpawn.quat, quat, sizeof(game::vec4_t));
memcpy(fx_system::ed_active_effect->frameNow.quat, quat, sizeof(game::vec4_t));
}
memcpy(fx_system::ed_active_effect->frameAtSpawn.quat, quat, sizeof(game::vec4_t));
memcpy(fx_system::ed_active_effect->frameNow.quat, quat, sizeof(game::vec4_t));
}

return;
return;
}
}
}
else if(edit_ent && edit_ent->eclass && utils::string_equals(edit_ent->eclass->name, "worldspawn"))
{
if(!game::g_selected_brushes()->def)
else if (edit_ent->eclass && utils::string_equals(edit_ent->eclass->name, "worldspawn"))
{
return;
}
}
if (effects::effect_is_playing())
{
effects::on_effect_stop();
}

if(effects::effect_is_playing())
{
effects::on_effect_stop();
is_fx_origin_selected_ = false;
}
}

is_fx_origin_selected_ = false;
}

void effects::tick_playback()
Expand Down
11 changes: 11 additions & 0 deletions src/ggui/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ namespace ggui::preferences
static float height = 0.0f;
height = pref_child_lambda(CAT_DEVELOPER, height, _pref_child_bg_col, dvars::gui_border_color->current.vector, []
{
if(ImGui::Button("Enter Prefab"))
{
cdeclcall(void, 0x42BF70);
}

ImGui::SameLine();
if (ImGui::Button("Leave Prefab"))
{
cdeclcall(void, 0x42BF80);
}

ImGui::DragInt("Int 01", &dev_num_01, 0.1f);
ImGui::DragFloat3("Vec4 01", dev_vec_01, 25.0f);
ImGui::ColorEdit4("Color 01", dev_color_01, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR);
Expand Down
2 changes: 1 addition & 1 deletion src/version.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* Automatically generated by premake5. */

#define REVISION 330.0
#define REVISION 331.0

0 comments on commit 6a97ea2

Please sign in to comment.