Skip to content

Commit

Permalink
Merge pull request #753 from Berthalamew/development
Browse files Browse the repository at this point in the history
add global real math constants + misc changes
  • Loading branch information
Berthalamew authored Dec 1, 2024
2 parents 740dad1 + a388a8e commit 9ce8189
Show file tree
Hide file tree
Showing 42 changed files with 348 additions and 246 deletions.
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/camera/editor_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void __cdecl editor_camera_orbiting_update(s_editor_camera* camera, s_director_u
observer_command->flags = 1;
}

observer_command->position.orientation = global_zero_vector3d;
observer_command->position.orientation = *global_zero_vector3d;
observer_command->focus_distance = camera->focus_distance;

s_saved_game_cartographer_player_profile* player_profile = cartographer_player_profile_get_by_user_index(director_update->user_index);
Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/camera/first_person_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void __cdecl first_person_camera_build_observer_command(datum player_unit_index,

observer_command->timer = 0;
observer_command->flags = 0;
observer_command->position.orientation = global_zero_vector3d;
observer_command->position.orientation = *global_zero_vector3d;
observer_command->focus_distance = 0.f;
observer_command->forward = *unit_facing;
observer_command->field_of_view = DEGREES_TO_RADIANS(70.f);
Expand Down
10 changes: 5 additions & 5 deletions xlive/Blam/Engine/camera/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void __cdecl observer_update(real32 dt)

void observer_update_internal(int32 user_index)
{
real_matrix4x3 camera_effect_matrix = global_identity4x3;
real_matrix4x3 camera_effect_matrix = *global_identity4x3;
s_observer* observer = observer_get_from_user(user_index);
if (user_index != NONE)
{
Expand Down Expand Up @@ -162,12 +162,12 @@ void observer_update_internal(int32 user_index)

if (!valid_real_vector3d_axes2(&forward, &up))
{
normalize3d_with_default(&forward, &global_forward3d);
normalize3d_with_default(&up, &global_forward3d);
normalize3d_with_default(&forward, global_forward3d);
normalize3d_with_default(&up, global_forward3d);
if (!valid_real_vector3d_axes2(&forward, &up))
{
forward = global_forward3d;
up = global_up3d;
forward = *global_forward3d;
up = *global_up3d;
}
}

Expand Down
8 changes: 4 additions & 4 deletions xlive/Blam/Engine/cartographer/tag_fixes/tag_fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ static void tag_fixes_brute(void)
if (brute_shader_index != NONE && brute_head_shader_index != NONE)
{
s_shader_definition* shader = (s_shader_definition*)tag_get_fast(brute_shader_index);
shader->postprocess_definition[0]->pixel_constants[0]->color = D3DCOLOR_RGBA(87, 79, 69, 0);
shader->postprocess_definition[0]->pixel_constants[1]->color = D3DCOLOR_RGBA(180, 179, 189, 0);
*shader->postprocess_definition[0]->pixel_constants[0] = D3DCOLOR_RGBA(87, 79, 69, 0);
*shader->postprocess_definition[0]->pixel_constants[1] = D3DCOLOR_RGBA(180, 179, 189, 0);

shader = (s_shader_definition*)tag_get_fast(brute_head_shader_index);
shader->postprocess_definition[0]->pixel_constants[0]->color = D3DCOLOR_RGBA(255, 255, 255, 0);
shader->postprocess_definition[0]->pixel_constants[1]->color = D3DCOLOR_RGBA(180, 179, 189, 0);
*shader->postprocess_definition[0]->pixel_constants[0] = D3DCOLOR_RGBA(255, 255, 255, 0);
*shader->postprocess_definition[0]->pixel_constants[1] = D3DCOLOR_RGBA(180, 179, 189, 0);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/effects/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void c_particle::adjust_initial_position(

if (particle_system->parent_effect_index == NONE)
{
parent_velocity = &global_zero_vector3d;
parent_velocity = global_zero_vector3d;
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions xlive/Blam/Engine/effects/particle_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ bool __stdcall c_particle_system::frame_advance(c_particle_system* thisx, real32
switch (marker_name.get_id())
{
case _string_id_up:
marker_matrix.vectors.forward = global_up3d;
marker_matrix.vectors.up = global_forward3d;
marker_matrix.vectors.left = global_left3d;
marker_matrix.vectors.forward = *global_up3d;
marker_matrix.vectors.up = *global_forward3d;
marker_matrix.vectors.left = *global_left3d;
break;
case _string_id_gravity:
marker_matrix.vectors.forward = global_down3d;
marker_matrix.vectors.up = global_back3d;
marker_matrix.vectors.left = global_left3d;
marker_matrix.vectors.forward = *global_down3d;
marker_matrix.vectors.up = *global_backward3d;
marker_matrix.vectors.left = *global_left3d;
break;
default:
scale_vector3d(&particle->m_velocity, -1.0f, &marker_matrix.vectors.forward);
Expand Down
6 changes: 3 additions & 3 deletions xlive/Blam/Engine/effects/player_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3*
if (player_effects_globals->flags.test(_player_effect_global_bit_0))
{
real32 vibration_intensity = player_effects_globals->max_intensity;
effect_matrix = global_identity4x3;
effect_matrix = *global_identity4x3;

if (player_effects_globals->attack_time_passed_ticks > 0)
{
Expand Down Expand Up @@ -91,7 +91,7 @@ void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3*
}

real_vector3d v1;
cross_product3d(&global_up3d, &user_effect->jitter, &v1);
cross_product3d(global_up3d, &user_effect->jitter, &v1);

real32 rotation = user_effect->camera_impulse.temporary_rotation * transition_result;
matrix4x3_rotation_from_axis_and_angle(&effect_matrix, &v1, sin(rotation), cos(rotation));
Expand All @@ -108,7 +108,7 @@ void player_effect_apply_camera_effect_matrix(int32 user_index, real_matrix4x3*
bool apply_camera_shake = user_effect->flags.test(_player_effect_apply_camera_shake);
if (user_effect->camera_shake_countdown > 0 || apply_camera_shake)
{
effect_matrix = global_identity4x3;
effect_matrix = *global_identity4x3;

real32 transition_function_result;
if (apply_camera_shake)
Expand Down
3 changes: 1 addition & 2 deletions xlive/Blam/Engine/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ void render_splitscreen_line(void)
const int32 line_size = resolution_y / 480;

rectangle2d line;
pixel32 color;
color.color = k_splitscreen_line_colour;
pixel32 color = k_splitscreen_line_colour;
if (player_window_count > 1)
{
if (get_display_split_type() == _display_split_type_horizontal)
Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/interface/new_hud.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "game/game_engine_territories.h"
#include "game/players.h"
#include "math/color_math.h"
#include "saved_games/player_profile.h"

/* enums */

Expand Down
12 changes: 4 additions & 8 deletions xlive/Blam/Engine/interface/screens/screen_4way_signin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,10 @@ void add_button_key_split_input(c_text_widget* button_key_text)

c_static_wchar_string<512> temp, old;
old.set(button_key_text->get_interface()->get_raw_string());
if(!input_windows_has_split_device_active())
{
usnzprintf(temp.get_buffer(), temp.max_length(), L"%c ADD SPLIT ", _private_use_character_x_button);
}
else
{
usnzprintf(temp.get_buffer(), temp.max_length(), L"%c REMOVE SPLIT ", _private_use_character_x_button);
}

const wchar_t* split_text = !input_windows_has_split_device_active() ? L"%c ADD SPLIT " : L"%c REMOVE SPLIT ";
usnzprintf(temp.get_buffer(), temp.max_length(), split_text, _private_use_character_x_button);

button_key_text->set_text(temp.get_string());
button_key_text->append_text(old.get_string());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "screen_cartographer_account_manager.h"

#include "main/game_preferences.h"
#include "memory/data.h"
#include "interface/screens/screen_xbox_live_task_progress_dialog.h"

Expand Down Expand Up @@ -804,7 +805,7 @@ void xbox_live_task_progress_callback(c_screen_xbox_live_task_progress_dialog* d
ui_load_cartographer_update_notice_menu();
return;
}
ImGuiHandler::ToggleWindow(ImGuiHandler::ImMOTD::windowName);
ImGuiHandler::ToggleWindow(k_motd_window_name);
// extern int notify_xlive_ui;
// notify_xlive_ui = 0;
// sub_248beb_nak_deconstructor_Login_Warn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once
#include "interface/user_interface_headers.h"
#include "main/game_preferences.h"

#include "H2MOD/Modules/Accounts/Accounts.h"

/* macro defines */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "screen_cartographer_account_manager.h"

#include "interface/user_interface_utilities.h"
#include "main/game_preferences.h"

#include "H2MOD/Modules/CustomMenu/CustomMenuGlobals.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#pragma once

#include "interface/signal_slot.h"
#include "interface/user_interface_widget_list.h"
#include "interface/user_interface_widget_window.h"

/* enums */
Expand Down
2 changes: 1 addition & 1 deletion xlive/Blam/Engine/interface/user_interface_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void c_user_interface_text::set_color(const real_rgb_color* color)

bool c_user_interface_text::is_private_use_character(wchar_t character)
{
if (IN_RANGE(character, K_PRIVATE_USE_CHARACTER_SPACE_START, K_PRIVATE_USE_CHARACTER_SPACE_END))
if (IN_RANGE(character, k_private_use_character_space_start, k_private_use_character_space_end))
return true;
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions xlive/Blam/Engine/interface/user_interface_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

/* macro defines */

#define K_PRIVATE_USE_CHARACTER_SPACE_START 0xE000u
#define K_PRIVATE_USE_CHARACTER_SPACE_END 0xF8FFu
#define TO_PRIVATE_CHAR(id) ((K_PRIVATE_USE_CHARACTER_SPACE_START + (id)))
#define k_private_use_character_space_start 0xE000u
#define k_private_use_character_space_end 0xF8FFu
#define TO_PRIVATE_CHAR(id) ((k_private_use_character_space_start + (id)))

/* enums */

Expand Down Expand Up @@ -194,7 +194,7 @@ enum e_private_use_characters
_private_use_character_vote_variant = TO_PRIVATE_CHAR(0x48F),
_private_use_character_vote_mapname = TO_PRIVATE_CHAR(0x490),
_private_use_character_pending_votes = TO_PRIVATE_CHAR(0x491),
_private_use_character_resolution_change_seconds_remaining = TO_PRIVATE_CHAR(0x492),
_private_use_character_resolution_change_seconds_remaining = TO_PRIVATE_CHAR(0x492)
};


Expand Down
57 changes: 49 additions & 8 deletions xlive/Blam/Engine/math/color_math.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "stdafx.h"
#include "color_math.h"

/* constants */

const real_argb_color global_real_argb_color_table[] =
{
{ 1.f, 1.f, 1.f, 1.f },
Expand All @@ -22,15 +24,54 @@ const real_argb_color global_real_argb_color_table[] =
{ 1.f, .81f, .13f, .56f }
};

const real_argb_color* const global_real_argb_white = &global_real_argb_color_table[0];
const real_argb_color* const global_real_argb_grey = &global_real_argb_color_table[1];
const real_argb_color* const global_real_argb_black = &global_real_argb_color_table[2];
const real_argb_color* const global_real_argb_red = &global_real_argb_color_table[3];
const real_argb_color* const global_real_argb_green = &global_real_argb_color_table[4];
const real_argb_color* const global_real_argb_blue = &global_real_argb_color_table[5];
const real_argb_color* const global_real_argb_cyan = &global_real_argb_color_table[6];
const real_argb_color* const global_real_argb_yellow = &global_real_argb_color_table[7];
const real_argb_color* const global_real_argb_magenta = &global_real_argb_color_table[8];
const real_argb_color* const global_real_argb_pink = &global_real_argb_color_table[9];
const real_argb_color* const global_real_argb_lightblue = &global_real_argb_color_table[10];
const real_argb_color* const global_real_argb_orange = &global_real_argb_color_table[11];
const real_argb_color* const global_real_argb_purple = &global_real_argb_color_table[12];
const real_argb_color* const global_real_argb_aqua = &global_real_argb_color_table[13];
const real_argb_color* const global_real_argb_darkgreen = &global_real_argb_color_table[14];
const real_argb_color* const global_real_argb_salmon = &global_real_argb_color_table[15];
const real_argb_color* const global_real_argb_violet = &global_real_argb_color_table[16];

const real_rgb_color* const global_real_rgb_white = &global_real_argb_color_table[0].rgb;
const real_rgb_color* const global_real_rgb_grey = &global_real_argb_color_table[1].rgb;
const real_rgb_color* const global_real_rgb_black = &global_real_argb_color_table[2].rgb;
const real_rgb_color* const global_real_rgb_red = &global_real_argb_color_table[3].rgb;
const real_rgb_color* const global_real_rgb_green = &global_real_argb_color_table[4].rgb;
const real_rgb_color* const global_real_rgb_blue = &global_real_argb_color_table[5].rgb;
const real_rgb_color* const global_real_rgb_cyan = &global_real_argb_color_table[6].rgb;
const real_rgb_color* const global_real_rgb_yellow = &global_real_argb_color_table[7].rgb;
const real_rgb_color* const global_real_rgb_magenta = &global_real_argb_color_table[8].rgb;
const real_rgb_color* const global_real_rgb_pink = &global_real_argb_color_table[9].rgb;
const real_rgb_color* const global_real_rgb_lightblue = &global_real_argb_color_table[10].rgb;
const real_rgb_color* const global_real_rgb_orange = &global_real_argb_color_table[11].rgb;
const real_rgb_color* const global_real_rgb_purple = &global_real_argb_color_table[12].rgb;
const real_rgb_color* const global_real_rgb_aqua = &global_real_argb_color_table[13].rgb;
const real_rgb_color* const global_real_rgb_darkgreen = &global_real_argb_color_table[14].rgb;
const real_rgb_color* const global_real_rgb_salmon = &global_real_argb_color_table[15].rgb;
const real_rgb_color* const global_real_rgb_violet = &global_real_argb_color_table[16].rgb;

const pixel32 global_white_pixel32 = D3DCOLOR_ARGB(255, 255, 255, 255);
const pixel32 global_yellow_pixel32 = D3DCOLOR_ARGB(255, 255, 255, 0);

/* public code */

pixel32 real_argb_color_to_pixel32(const real_argb_color* color)
{
pixel32 result = { D3DCOLOR_ARGB(
(int32)(color->alpha * 255),
(int32)(color->red * 255),
(int32)(color->green * 255),
(int32)(color->blue * 255)
) };
return result;
return D3DCOLOR_ARGB(
(int32)(color->alpha * 255),
(int32)(color->red * 255),
(int32)(color->green * 255),
(int32)(color->blue * 255));
}

void pixel32_to_real_rgb_color(pixel32 pixel_color, real_rgb_color* out_color)
Expand All @@ -42,6 +83,6 @@ void pixel32_to_real_rgb_color(pixel32 pixel_color, real_rgb_color* out_color)
pixel32 real_alpha_to_pixel32(real32 alpha)
{
ASSERT(alpha >= 0.f && alpha <= 1.f);
pixel32 color = { (int32)(alpha * 255.f) << 24 };
pixel32 color = (int32)(alpha * 255.f) << 24;
return color;
}
Loading

0 comments on commit 9ce8189

Please sign in to comment.