Skip to content

Commit

Permalink
Revert "Avoid destructive recalculations during poly height changes; f…
Browse files Browse the repository at this point in the history
…ixes #492"

This reverts commit fe20606.
  • Loading branch information
Hopper262 committed Aug 30, 2024
1 parent 836bcfd commit f54650b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Source_Files/GameWorld/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,8 @@ void precalculate_map_indexes(void);

void touch_polygon(short polygon_index);
void recalculate_redundant_polygon_data(short polygon_index);
void recalculate_redundant_endpoint_data(short endpoint_index, bool only_for_heights = false);
void recalculate_redundant_line_data(short line_index, bool only_for_heights = false);
void recalculate_redundant_endpoint_data(short endpoint_index);
void recalculate_redundant_line_data(short line_index);
void recalculate_redundant_side_data(short side_index, short line_index);

void calculate_endpoint_polygon_owners(short endpoint_index, short *first_index, short *index_count);
Expand Down
23 changes: 7 additions & 16 deletions Source_Files/GameWorld/map_constructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ void recalculate_redundant_polygon_data(
/* calculates solidity, highest adjacent floor and lowest adjacent ceiling; not to be called
at runtime. */
void recalculate_redundant_endpoint_data(
short endpoint_index,
bool only_for_heights)
short endpoint_index)
{
struct endpoint_data *endpoint= get_endpoint_data(endpoint_index);
world_distance highest_adjacent_floor_height= INT16_MIN;
Expand Down Expand Up @@ -279,12 +278,9 @@ void recalculate_redundant_endpoint_data(
}
}

if (!only_for_heights)
{
SET_ENDPOINT_SOLIDITY(endpoint, solid);
SET_ENDPOINT_TRANSPARENCY(endpoint, transparent);
SET_ENDPOINT_ELEVATION(endpoint, elevation);
}
SET_ENDPOINT_SOLIDITY(endpoint, solid);
SET_ENDPOINT_TRANSPARENCY(endpoint, transparent);
SET_ENDPOINT_ELEVATION(endpoint, elevation);
endpoint->highest_adjacent_floor_height= highest_adjacent_floor_height;
endpoint->lowest_adjacent_ceiling_height= lowest_adjacent_ceiling_height;
endpoint->supporting_polygon_index= supporting_polygon_index;
Expand All @@ -293,8 +289,7 @@ void recalculate_redundant_endpoint_data(
/* calculates line length, highest adjacent floor and lowest adjacent ceiling and calls
recalculate_redundant_side_data() on the line’s sides */
void recalculate_redundant_line_data(
short line_index,
bool only_for_heights)
short line_index)
{
struct line_data *line= get_line_data(line_index);
struct side_data *clockwise_side= NULL, *counterclockwise_side= NULL;
Expand All @@ -304,9 +299,8 @@ void recalculate_redundant_line_data(
bool transparent_texture= false;

/* recalculate line length */
if (only_for_heights)
line->length= distance2d(&(get_endpoint_data(line->endpoint_indexes[0])->vertex),
&(get_endpoint_data(line->endpoint_indexes[1])->vertex));
line->length= distance2d(&(get_endpoint_data(line->endpoint_indexes[0])->vertex),
&(get_endpoint_data(line->endpoint_indexes[1])->vertex));

/* find highest adjacent floor and lowest adjacent ceiling */
{
Expand Down Expand Up @@ -347,9 +341,6 @@ void recalculate_redundant_line_data(
}
}

if (only_for_heights)
return;

if (line->clockwise_polygon_side_index!=NONE)
{
recalculate_redundant_side_data(line->clockwise_polygon_side_index, line_index);
Expand Down
13 changes: 6 additions & 7 deletions Source_Files/Lua/lua_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ static int Lua_Polygon_Floor_Set_Height(lua_State *L)
polygon->floor_height = static_cast<world_distance>(lua_tonumber(L,2)*WORLD_ONE);
for (short i = 0; i < polygon->vertex_count; ++i)
{
recalculate_redundant_endpoint_data(polygon->endpoint_indexes[i], true);
recalculate_redundant_line_data(polygon->line_indexes[i], true);
recalculate_redundant_endpoint_data(polygon->endpoint_indexes[i]);
recalculate_redundant_line_data(polygon->line_indexes[i]);
}
return 0;
}
Expand Down Expand Up @@ -893,8 +893,8 @@ static int Lua_Polygon_Ceiling_Set_Height(lua_State *L)
polygon->ceiling_height = static_cast<world_distance>(lua_tonumber(L,2)*WORLD_ONE);
for (short i = 0; i < polygon->vertex_count; ++i)
{
recalculate_redundant_endpoint_data(polygon->endpoint_indexes[i], true);
recalculate_redundant_line_data(polygon->line_indexes[i], true);
recalculate_redundant_endpoint_data(polygon->endpoint_indexes[i]);
recalculate_redundant_line_data(polygon->line_indexes[i]);
}
return 0;
}
Expand Down Expand Up @@ -1270,7 +1270,6 @@ const luaL_Reg Lua_Polygon_Sides_Metatable[] = {
{0, 0}
};

static void update_line_redundancy(short line_index);
int Lua_Polygon_Change_Height(lua_State* L)
{
if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
Expand All @@ -1288,8 +1287,8 @@ int Lua_Polygon_Change_Height(lua_State* L)
auto polygon = get_polygon_data(polygon_index);
for (auto i = 0; i < polygon->vertex_count; ++i)
{
recalculate_redundant_line_data(polygon->line_indexes[i], true);
recalculate_redundant_endpoint_data(polygon->endpoint_indexes[i], true);
recalculate_redundant_line_data(polygon->line_indexes[i]);
recalculate_redundant_endpoint_data(polygon->endpoint_indexes[i]);
}
}

Expand Down

0 comments on commit f54650b

Please sign in to comment.