Skip to content

Commit

Permalink
disabled the particle interpolator entirely and other minor miscellan…
Browse files Browse the repository at this point in the history
…eous updates

the particle interpolator isn't needed, disable it for better performance
  • Loading branch information
nukeulater committed Jan 1, 2024
1 parent dc70262 commit b32c999
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 64 deletions.
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/Networking/PlayerPrediction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

struct s_player_prediction
{
DWORD predicted_entity_index;
int predicted_entity_index;
real_vector3d point_quantized;
real_vector3d prediction_axis;
real_vector3d prediction_axis2;
Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/camera/dead_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ __declspec(naked) void object_try_get_node_position_interpolated_intermediate()
mov esi, [esp + 4 + current_stack_offset + 0Ch]
retn
}
#undef current_stack_offset (0Ch)
#undef current_stack_offset
}

void apply_dead_camera_patches()
Expand Down
7 changes: 4 additions & 3 deletions xlive/Blam/Engine/effects/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ s_data_array* get_particle_table()
{
return *Memory::GetAddress<s_data_array**>(0x4DD08C, 0x5053B4);
}
real32 g_particle_delta_temp;
real32 g_particle_interpolator_delta = 0.f;
real32 g_particle_interpolator_delta_remainder = 0.f;
bool particle_interpolator_enabled = false;
Expand Down Expand Up @@ -110,7 +109,6 @@ real_vector3d* halo_interpolator_particle_get_interpolated_velocity(datum partic
void particle_update(real32 delta)
{
s_data_iterator<c_particle_system> particle_system_it(get_particle_system_table());
g_particle_delta_temp = delta;
while (particle_system_it.get_next_datum())
{
c_particle_system* particle_system = particle_system_it.get_current_datum();
Expand All @@ -123,7 +121,8 @@ void particle_update(real32 delta)
c_particle_system::destroy(particle_system_it.get_current_datum_index());
}
}
halo_particle_interpolator_update();
// we run at dt, baby!!
// halo_particle_interpolator_update();


/*g_particle_interpolator_delta += delta;
Expand All @@ -139,6 +138,8 @@ void particle_update(real32 delta)
nearest_whole_tick_delta += game_tick_length;
} while (accumulated_delta >= game_tick_length);
accumulated_delta -= ((int32)(accumulated_delta / game_tick_length) * game_tick_length);
g_particle_interpolator_delta = accumulated_delta;
if(nearest_whole_tick_delta > 0.f)
Expand Down
1 change: 0 additions & 1 deletion xlive/Blam/Engine/effects/particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct s_particle_frame_data_storage
s_particle_interpolation_data_storage target_data;
};

extern real32 g_particle_delta_temp;
extern real32 g_particle_interpolator_delta;
extern real32 g_particle_interpolator_delta_remainder;
extern s_particle_frame_data_storage* g_particle_frame_storage;
Expand Down
4 changes: 2 additions & 2 deletions xlive/Blam/Engine/effects/particle_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ real_vector3d* __cdecl particle_update_points_interpolate_hook(const real_vector
void apply_particle_update_patches()
{
//p_particle_system_update_particle_position_and_velocity = Memory::GetAddress<particle_system_update_particle_position_and_velocity_t>(0xC4125);
PatchCall(Memory::GetAddress(0x10459E), particle_system_update_particle_position_and_velocity);
PatchCall(Memory::GetAddress(0x508AA), particle_system_update_particle_position_and_velocity);
//PatchCall(Memory::GetAddress(0x10459E), particle_system_update_particle_position_and_velocity);
//PatchCall(Memory::GetAddress(0x508AA), particle_system_update_particle_position_and_velocity);
PatchCall(Memory::GetAddress(0x105380), particle_update_points_interpolate_hook);
}
30 changes: 13 additions & 17 deletions xlive/Blam/Engine/effects/player_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ s_player_effect_user_globals* player_effects_get_user_globals(int32 user_index)
return &player_effect_globals_get()->user_effects[user_index];
}

/*
void __cdecl player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3* matrix)
{
INVOKE(0xA432D, 0x963AA, player_effect_apply_camera_effect_matrix, user_index, matrix);
return;
}*/

void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3* matrix)
{
// INVOKE(0xA432D, 0x963AA, player_effect_apply_camera_effect_matrix, user_index, matrix);
// return;

real_matrix4x3 calculated_matrix;
if (user_index != NONE)
{
Expand Down Expand Up @@ -83,14 +79,14 @@ void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3*
}
else
{
real32 impulse_passed_time = user_effect->camera_impulse.duration - (real32)user_effect->camera_impulse_countdown;
real32 impulse_elapsed_time = user_effect->camera_impulse.duration - (real32)user_effect->camera_impulse_countdown;
// do not stale the transition function
impulse_passed_time += halo_interpolator_get_interpolation_time();
impulse_elapsed_time += halo_interpolator_get_interpolation_time();

transition_result = player_effect_transition_function_evaluate(
(e_transition_function_type)user_effect->camera_impulse.fade_function,
user_effect->transition_function_scale_9C,
impulse_passed_time,
user_effect->camera_impulse_transition_scale,
impulse_elapsed_time,
user_effect->camera_impulse.duration);
}

Expand All @@ -107,7 +103,7 @@ void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3*
}

bool bit_2_result = user_effect->flags.test(_player_effect_apply_camera_shake);
if (user_effect->camera_shake_passed_time > 0 || bit_2_result)
if (user_effect->camera_shake_countdown > 0 || bit_2_result)
{
calculated_matrix = global_identity4x3;

Expand All @@ -118,18 +114,18 @@ void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3*
}
else
{
real32 passed_time = user_effect->camera_shaking.duration
- game_ticks_to_seconds((real32)user_effect->camera_shake_passed_time - halo_interpolator_get_interpolation_time());
real32 shake_elapsed_time = user_effect->camera_shaking.duration
- game_ticks_to_seconds((real32)user_effect->camera_shake_countdown - halo_interpolator_get_interpolation_time());

transition_function_result = player_effect_transition_function_evaluate(
(e_transition_function_type)user_effect->camera_shaking.falloff_function,
user_effect->transition_function_scale_98,
passed_time,
user_effect->camera_shake_transition_scale,
shake_elapsed_time,
user_effect->camera_shaking.duration
);
}

real32 camera_shake_remaining_time = user_effect->camera_shaking.duration - game_ticks_to_seconds(user_effect->camera_shake_passed_time);
real32 camera_shake_remaining_time = user_effect->camera_shaking.duration - game_ticks_to_seconds(user_effect->camera_shake_countdown);
real32 periodic_function_result = periodic_function_evaluate(user_effect->camera_shaking.wobble_function, camera_shake_remaining_time / user_effect->camera_shaking.wobble_function_period);
real32 periodic_function_result_scaled =
periodic_function_result * (transition_function_result * user_effect->camera_shaking.wobble_weight + transition_function_result * (1.0f - user_effect->camera_shaking.wobble_weight));
Expand Down
6 changes: 3 additions & 3 deletions xlive/Blam/Engine/effects/player_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ struct s_player_effect_user_globals
int16 field_7C;
int16 game_time;
int16 camera_impulse_countdown;
int16 camera_shake_passed_time;
int16 camera_shake_countdown;
int8 field_84[4];
c_flags<e_player_effect_user_global_flags, uint8, k_player_effect_user_global_flag_count> flags;
int8 field_89;
int16 pad_8A;
real_point3d origin;
real32 transition_function_scale_98;
real32 transition_function_scale_9C;
real32 camera_shake_transition_scale;
real32 camera_impulse_transition_scale;
};
CHECK_STRUCT_SIZE(s_player_effect_user_globals, 160);

Expand Down
8 changes: 4 additions & 4 deletions xlive/Blam/Engine/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ void __cdecl shell_initialize(void)
g_target_interpolation_frame_data = &g_frame_data_storage->target_data;
halo_interpolator_set_interpolation_enabled(true);

g_particle_frame_storage = (s_particle_frame_data_storage*)VirtualAlloc(0, sizeof(s_particle_frame_data_storage), MEM_COMMIT, PAGE_READWRITE);
g_previous_particle_interpolation_frame_data = &g_particle_frame_storage->previous_data;
g_target_particle_interpolation_frame_data = &g_particle_frame_storage->target_data;
halo_particle_interpolator_set_state(true);
//g_particle_frame_storage = (s_particle_frame_data_storage*)VirtualAlloc(0, sizeof(s_particle_frame_data_storage), MEM_COMMIT, PAGE_READWRITE);
//g_previous_particle_interpolation_frame_data = &g_particle_frame_storage->previous_data;
//g_target_particle_interpolation_frame_data = &g_particle_frame_storage->target_data;
halo_particle_interpolator_set_state(false);
}
return;
}
Expand Down
4 changes: 1 addition & 3 deletions xlive/Blam/Engine/objects/damage.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ struct s_damage_owner
};
CHECK_STRUCT_SIZE(s_damage_owner, 12);

#pragma pack(push, 1)
struct s_damage_data
{
DWORD damage_tag_index; // 0x0
Expand Down Expand Up @@ -40,8 +39,7 @@ struct s_damage_data
BYTE gap_80[4]; // 0x80
char field_84; // 0x84
};
#pragma pack(pop)
CHECK_STRUCT_SIZE(s_damage_data, 0x85);
CHECK_STRUCT_SIZE(s_damage_data, 0x88);

// max_count: LONG_MAX
struct s_armor_modifier_definition
Expand Down
8 changes: 4 additions & 4 deletions xlive/Blam/Engine/physics/collisions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ struct collision_result
int32 type;
real32 t;
real_point3d point;
s_location location_0;
s_location location_1;
s_location locations[2];
int16 global_material_index;
int16 pad;
real_plane3d fog_plane;
int32 field_38;
int32 instanced_geometry_instance_index;
Expand All @@ -57,8 +55,10 @@ struct collision_result
int32 field_4C;
int32 field_50;
int32 flags;
int32 field_58;
int16 field_58;
int16 field_5A;
};
CHECK_STRUCT_SIZE(collision_result, 0x5C);

uint16 collision_compute_object_cull_flags(datum object_index);

Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/render/render_cartographer_ingame_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void render_cartographer_achievements()
}

draw_string_reset();
draw_string_set_font_and_options(k_cheevo_title_font, 0, 2, 0, &text_color, *Memory::GetAddress<real_argb_color**>(0x412780), false);
draw_string_set_font_and_options(k_cheevo_title_font, 0, 2, 0, &text_color, global_real_argb_black, false);

rasterizer_get_screen_bounds(&bounds);
bounds.top += rectangle2d_height(&bounds) / 3 - (widget_total_height / 2);
Expand Down
25 changes: 2 additions & 23 deletions xlive/H2MOD/Modules/Input/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,12 @@
#include "Util/Hooks/Hook.h"
#include "H2MOD/Modules/EventHandler/EventHandler.hpp"


typedef void __cdecl c_UpdatePlayerControl(float* yaw, float* pitch);
c_UpdatePlayerControl* p_UpdatePlayerControl;

void __cdecl UpdatePlayerControl(float* yawChange, float* pitchChange)
{
p_UpdatePlayerControl(yawChange, pitchChange);
//EventHandler::execute_callback<EventHandler::PlayerControlEvent>(execute_after, &yawChange, &pitchChange);
//EventHandler::executePlayerControlCallback(yawChange, pitchChange);
}

typedef void __cdecl p_network_player_actions_to_player_actions(s_player_motion* nActions, player_action* pActions);
p_network_player_actions_to_player_actions* network_player_actions_to_player_actions;


void PlayerControl::ApplyHooks()
{
return; // TODO FIXME usercall convention functions, bad hooks
p_UpdatePlayerControl = Memory::GetAddress<c_UpdatePlayerControl*>(0x90D62);
network_player_actions_to_player_actions = Memory::GetAddress<p_network_player_actions_to_player_actions*>(0x1DB569);
PatchCall(Memory::GetAddress(0x93596), UpdatePlayerControl);
PatchCall(Memory::GetAddress(0x9390D), UpdatePlayerControl);
return;
}

player_action PlayerControl::GetPlayerActions(int player_index)
Expand All @@ -36,13 +20,8 @@ player_action PlayerControl::GetPlayerActions(int player_index)
return newActions;
}

s_player_motion* PlayerControl::GetPlayerMotion(int player_index)
{
return Memory::GetAddress<s_player_motion*>(0x514EE8 + player_index * sizeof(s_player_motion));
}

void PlayerControl::DisableLocalCamera(bool state)
{
auto player_controls_globals = *Memory::GetAddress<s_player_control_globals**>(0x4ca37c);
auto player_controls_globals = *Memory::GetAddress<s_player_control_globals**>(0x4CA37C);
player_controls_globals->disable_camera = state;
}
1 change: 0 additions & 1 deletion xlive/H2MOD/Modules/Input/PlayerControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ namespace PlayerControl
void Init();
void ApplyHooks();
player_action GetPlayerActions(int player_index);
s_player_motion* GetPlayerMotion(int player_index);
void DisableLocalCamera(bool);
}

0 comments on commit b32c999

Please sign in to comment.