Skip to content

Commit

Permalink
Misc cleanup
Browse files Browse the repository at this point in the history
Remove old test normal flip code for portals.

Make sure H1 to H2 scenario upgrader still works

Make sure H1 maze generator still works

fix some console errors
  • Loading branch information
Steven Garcia committed Dec 23, 2023
1 parent b8dadb9 commit 36851e5
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 47 deletions.
2 changes: 1 addition & 1 deletion io_scene_halo/file_tag/h1/file_scenario/build_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def write_scavenger_hunt_objects(output_stream, SCENARIO):

def write_object_names(output_stream, SCENARIO):
for object_name in SCENARIO.object_names:
output_stream.write(struct.pack('>31sx', tag_format.string_to_bytes(object_name, False)))
output_stream.write(struct.pack('>31sx', tag_format.string_to_bytes(object_name.name, False)))
output_stream.write(struct.pack('>4x'))

def write_object(output_stream, scenery_element):
Expand Down
43 changes: 20 additions & 23 deletions io_scene_halo/file_tag/h1/file_scenario/upgrade_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def get_scenery(scenery_tag_block, TAG, SCENARIO):
scenery.name_index = scenery_element.name_index
scenery.placement_flags = convert_object_flags(scenery_element.placement_flags)
scenery.position = scenery_element.position
scenery.rotation = tag_format.vector_as_radians(scenery_element.rotation)
scenery.rotation = scenery_element.rotation
scenery.scale = 0
scenery.transform_flags = 0
scenery.manual_bsp_flags = 0
Expand Down Expand Up @@ -357,7 +357,7 @@ def get_unit(unit_tag_block, TAG, SCENARIO, is_biped):
unit.name_index = unit_element.name_index
unit.placement_flags = convert_object_flags(unit_element.placement_flags)
unit.position = unit_element.position
unit.rotation = tag_format.vector_as_radians(unit_element.rotation)
unit.rotation = unit_element.rotation
unit.scale = 0
unit.transform_flags = 0
unit.manual_bsp_flags = 0
Expand Down Expand Up @@ -399,7 +399,7 @@ def get_equipment(equipment_tag_block, TAG, SCENARIO):
equipment.name_index = equipment_element.name_index
equipment.placement_flags = convert_object_flags(equipment_element.placement_flags)
equipment.position = equipment_element.position
equipment.rotation = tag_format.vector_as_radians(equipment_element.rotation)
equipment.rotation = equipment_element.rotation
equipment.scale = 0
equipment.transform_flags = 0
equipment.manual_bsp_flags = 0
Expand Down Expand Up @@ -430,7 +430,7 @@ def get_weapon(weapons_tag_block, TAG, SCENARIO):
weapon.name_index = weapon_element.name_index
weapon.placement_flags = convert_object_flags(weapon_element.placement_flags)
weapon.position = weapon_element.position
weapon.rotation = tag_format.vector_as_radians(weapon_element.rotation)
weapon.rotation = weapon_element.rotation
weapon.scale = 0
weapon.transform_flags = 0
weapon.manual_bsp_flags = 0
Expand Down Expand Up @@ -482,7 +482,7 @@ def get_device_machines(machine_tag_block, TAG, SCENARIO):
device_machine.name_index = machine_element.name_index
device_machine.placement_flags = convert_object_flags(machine_element.placement_flags)
device_machine.position = machine_element.position
device_machine.rotation = tag_format.vector_as_radians(machine_element.rotation)
device_machine.rotation = machine_element.rotation
device_machine.scale = 0
device_machine.transform_flags = 0
device_machine.manual_bsp_flags = 0
Expand Down Expand Up @@ -517,7 +517,7 @@ def get_device_controls(controls_tag_block, TAG, SCENARIO):
device_control.name_index = control_element.name_index
device_control.placement_flags = convert_object_flags(control_element.placement_flags)
device_control.position = control_element.position
device_control.rotation = tag_format.vector_as_radians(control_element.rotation)
device_control.rotation = control_element.rotation
device_control.scale = 0
device_control.transform_flags = 0
device_control.manual_bsp_flags = 0
Expand Down Expand Up @@ -553,7 +553,7 @@ def get_light_fixtures(light_fixtures_tag_block, TAG, SCENARIO):
light_fixture.name_index = light_fixture_element.name_index
light_fixture.placement_flags = convert_object_flags(light_fixture_element.placement_flags)
light_fixture.position = light_fixture_element.position
light_fixture.rotation = tag_format.vector_as_radians(light_fixture_element.rotation)
light_fixture.rotation = light_fixture_element.rotation
light_fixture.scale = 0
light_fixture.transform_flags = 0
light_fixture.manual_bsp_flags = 0
Expand Down Expand Up @@ -589,7 +589,7 @@ def get_sound_scenery(sound_scenery_tag_block, TAG, SCENARIO):
sound_scenery.name_index = sound_scenery_element.name_index
sound_scenery.placement_flags = convert_object_flags(sound_scenery_element.placement_flags)
sound_scenery.position = sound_scenery_element.position
sound_scenery.rotation = tag_format.vector_as_radians(sound_scenery_element.rotation)
sound_scenery.rotation = sound_scenery_element.rotation
sound_scenery.scale = 0
sound_scenery.transform_flags = 0
sound_scenery.manual_bsp_flags = 0
Expand Down Expand Up @@ -648,7 +648,7 @@ def get_player_starting_locations(player_starting_locations_tag_block, TAG, SCEN
player_starting_location = SCENARIO.PlayerStartingLocation()

player_starting_location.position = player_starting_location_element.position
player_starting_location.facing = radians(player_starting_location_element.facing)
player_starting_location.facing = player_starting_location_element.facing
player_starting_location.team_designator = player_starting_location_element.team_index
player_starting_location.bsp_index = -1
player_starting_location.type_0 = convert_game_type_setting(player_starting_location_element.type_0)
Expand Down Expand Up @@ -715,7 +715,7 @@ def get_netgame_flags(netgame_flags_tag_block, TAG, SCENARIO):
netgame_flag = SCENARIO.NetGameFlag()

netgame_flag.position = netgame_flag_element.position
netgame_flag.facing = radians(netgame_flag_element.facing)
netgame_flag.facing = netgame_flag_element.facing
netgame_flag.type = flag_type
netgame_flag.team_designator = team_designator
netgame_flag.identifer = identifer
Expand All @@ -731,7 +731,7 @@ def get_netgame_flags(netgame_flags_tag_block, TAG, SCENARIO):
netgame_flag = SCENARIO.NetGameFlag()

netgame_flag.position = netgame_flag_element.position
netgame_flag.facing = radians(netgame_flag_element.facing)
netgame_flag.facing = netgame_flag_element.facing
netgame_flag.type = NetGameEnum.ctf_flag_return.value
netgame_flag.team_designator = team_designator
netgame_flag.identifer = identifer
Expand Down Expand Up @@ -765,7 +765,7 @@ def get_netgame_equipment(netgame_equipment_tag_block, vehicles_tag_block, vehic
netgame_equipment.respawn_timer_starts = respawn_timer_starts
netgame_equipment.classification = classification
netgame_equipment.position = netgame_equipment_element.position
netgame_equipment.orientation = (0.0, 0.0, radians(netgame_equipment_element.facing))
netgame_equipment.orientation = (0.0, 0.0, netgame_equipment_element.facing)

item_collection_tag_group = netgame_equipment_element.item_collection.tag_group
item_collection_tag_path = netgame_equipment_element.item_collection.name
Expand All @@ -792,7 +792,7 @@ def get_netgame_equipment(netgame_equipment_tag_block, vehicles_tag_block, vehic
netgame_equipment.respawn_timer_starts = respawn_timer_starts
netgame_equipment.classification = classification
netgame_equipment.position = vehicle_element.position
netgame_equipment.orientation = tag_format.vector_as_radians(vehicle_element.rotation)
netgame_equipment.orientation = vehicle_element.rotation

item_collection_tag_group = "vehc"
item_collection_tag_path = vehicle_palette_tag_block[vehicle_element.type_index].name
Expand Down Expand Up @@ -896,8 +896,7 @@ def generate_h2_squads(H1_ASSET, TAG, SCENARIO, report):
firing_position.flags = 0
firing_position.area_index = active_groups.index(H1GroupEnum(firing_position_element.group_index).name)
firing_position.cluster_index = 0
firing_position.normal_y = 0.0
firing_position.normal_p = radians(90)
firing_position.normal = (0.0, 90)

zone.firing_positions.append(firing_position)

Expand Down Expand Up @@ -1006,8 +1005,7 @@ def generate_h2_squads(H1_ASSET, TAG, SCENARIO, report):
starting_location.name_length = len(starting_location.name)
starting_location.position = starting_location_element.position
starting_location.reference_frame = -1
starting_location.facing_y = radians(starting_location_element.facing)
starting_location.facing_p = 0
starting_location.facing = (0.0, starting_location_element.facing)

starting_location.flags = 0
starting_location.character_type_index = -1
Expand Down Expand Up @@ -1076,12 +1074,11 @@ def generate_point_sets(H1_ASSET, TAG, SCENARIO, report):
def get_cutscene_flags(cutscene_flags_tag_block, TAG, SCENARIO):
SCENARIO.cutscene_flags = []
for cutscene_flag_element in cutscene_flags_tag_block:
cutscene_flags = SCENARIO.CutsceneFlags()
cutscene_flags = SCENARIO.CutsceneFlag()

cutscene_flags.name = cutscene_flag_element.name
cutscene_flags.position = cutscene_flag_element.position
cutscene_flags.facing_y = radians(cutscene_flag_element.facing[0])
cutscene_flags.facing_p = radians(cutscene_flag_element.facing[1])
cutscene_flags.facing = cutscene_flag_element.facing

SCENARIO.cutscene_flags.append(cutscene_flags)

Expand All @@ -1090,13 +1087,13 @@ def get_cutscene_flags(cutscene_flags_tag_block, TAG, SCENARIO):
def get_cutscene_camera_points(cutscene_camera_points_tag_block, TAG, SCENARIO):
SCENARIO.cutscene_camera_points = []
for cutscene_camera_point_element in cutscene_camera_points_tag_block:
cutscene_camera_point = SCENARIO.CutsceneCameraPoints()
cutscene_camera_point = SCENARIO.CutsceneCameraPoint()

cutscene_camera_point.flags = 0
cutscene_camera_point.camera_type = 0
cutscene_camera_point.name = cutscene_camera_point_element.name
cutscene_camera_point.position = cutscene_camera_point_element.position
cutscene_camera_point.orientation = tag_format.vector_as_radians(cutscene_camera_point_element.orientation)
cutscene_camera_point.orientation = cutscene_camera_point_element.orientation

SCENARIO.cutscene_camera_points.append(cutscene_camera_point)

Expand Down Expand Up @@ -1301,7 +1298,7 @@ def upgrade_h2_scenario(H1_ASSET, patch_txt_path, report):
SCENARIO.scenario_body.scenario_type = H1_ASSET.scenario_body.scenario_type
SCENARIO.scenario_body.scenario_flags = convert_scenario_flags(H1_ASSET.scenario_body.scenario_flags)
SCENARIO.scenario_body.child_scenarios_tag_block = TAG.TagBlock(len(SCENARIO.child_scenarios), 0, 0, 0)
SCENARIO.scenario_body.local_north = radians(H1_ASSET.scenario_body.local_north) # Value in radians
SCENARIO.scenario_body.local_north = H1_ASSET.scenario_body.local_north # Value in radians
SCENARIO.scenario_body.predicted_resources_tag_block = TAG.TagBlock(0, 0, 0, 0)
SCENARIO.scenario_body.functions_tag_block = TAG.TagBlock(0, 0, 0, 0)
SCENARIO.scenario_body.editor_scenario_data = TAG.RawData(0, 0, 0, 0, 0)
Expand Down
11 changes: 6 additions & 5 deletions io_scene_halo/file_tag/h2/file_scenario/build_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import struct

from math import radians
from ....global_functions import tag_format

def write_body(output_stream, SCENARIO, TAG):
Expand All @@ -34,7 +35,7 @@ def write_body(output_stream, SCENARIO, TAG):
SCENARIO.scenario_body.skies_tag_block.write(output_stream, False)
output_stream.write(struct.pack('<HH', SCENARIO.scenario_body.scenario_type, SCENARIO.scenario_body.scenario_flags))
SCENARIO.scenario_body.child_scenarios_tag_block.write(output_stream, False)
output_stream.write(struct.pack('<f', SCENARIO.scenario_body.local_north))
output_stream.write(struct.pack('<f', radians(SCENARIO.scenario_body.local_north)))
SCENARIO.scenario_body.predicted_resources_tag_block.write(output_stream, False)
SCENARIO.scenario_body.functions_tag_block.write(output_stream, False)
SCENARIO.scenario_body.editor_scenario_data.write(output_stream, False)
Expand Down Expand Up @@ -565,7 +566,7 @@ def write_squads(output_stream, SCENARIO, TAG):
output_stream.write(struct.pack('>i', len(starting_location.name)))
output_stream.write(struct.pack('<fff', starting_location.position[0], starting_location.position[1], starting_location.position[2]))
output_stream.write(struct.pack('<i', starting_location.reference_frame))
output_stream.write(struct.pack('<ff', starting_location.facing_y, starting_location.facing_p))
output_stream.write(struct.pack('<ff', radians(starting_location.facing[0]), radians(starting_location.facing[1])))
output_stream.write(struct.pack('<i', starting_location.flags))
output_stream.write(struct.pack('<h', starting_location.character_type_index))
output_stream.write(struct.pack('<h', starting_location.initial_weapon_index))
Expand Down Expand Up @@ -605,7 +606,7 @@ def write_zones(output_stream, SCENARIO, TAG):
output_stream.write(struct.pack('<h', firing_position.area_index))
output_stream.write(struct.pack('<h', firing_position.cluster_index))
output_stream.write(struct.pack('<4x'))
output_stream.write(struct.pack('<ff', firing_position.normal_y, firing_position.normal_p))
output_stream.write(struct.pack('<ff', radians(firing_position.normal[0]), radians(firing_position.normal[1])))

if len(zone.areas) > 0:
zone.areas_header.write(output_stream, TAG, True)
Expand Down Expand Up @@ -643,7 +644,7 @@ def write_scripting_data(output_stream, SCENARIO, TAG):
output_stream.write(struct.pack('<fff', point.position[0], point.position[1], point.position[2]))
output_stream.write(struct.pack('<i', point.reference_frame))
output_stream.write(struct.pack('<i', point.surface_index))
output_stream.write(struct.pack('<ff', point.facing_direction_y, point.facing_direction_p))
output_stream.write(struct.pack('<ff', radians(point.facing_direction[0]), radians(point.facing_direction[1])))

def write_cutscene_flags(output_stream, SCENARIO, TAG):
if len(SCENARIO.cutscene_flags) > 0:
Expand All @@ -652,7 +653,7 @@ def write_cutscene_flags(output_stream, SCENARIO, TAG):
output_stream.write(struct.pack('<4x'))
output_stream.write(struct.pack('>31sx', tag_format.string_to_bytes(cutscene_flag.name, False)))
output_stream.write(struct.pack('<fff', cutscene_flag.position[0], cutscene_flag.position[1], cutscene_flag.position[2]))
output_stream.write(struct.pack('<ff', cutscene_flag.facing_y, cutscene_flag.facing_p))
output_stream.write(struct.pack('<ff', radians(cutscene_flag.facing[0]), radians(cutscene_flag.facing[1])))

def write_cutscene_camera_points(output_stream, SCENARIO, TAG):
if len(SCENARIO.cutscene_camera_points) > 0:
Expand Down
7 changes: 0 additions & 7 deletions io_scene_halo/global_functions/mesh_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,6 @@ def generate_mesh_object_retail(asset, object_vertices, object_triangles, object
mesh.from_pydata(verts, [], tris)
object_mesh = bpy.data.objects.new(object_name, mesh)
for tri_idx, poly in enumerate(mesh.polygons):
tri = object_triangles[tri_idx]
v0_index = tri.v0
vert = object_vertices[v0_index]

if poly.normal.dot(vert.normal) < 0:
poly.flip()

poly.use_smooth = True

region_attribute = mesh.get_custom_attribute()
Expand Down
2 changes: 0 additions & 2 deletions io_scene_halo/global_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
)

from .maze_ui import (
Halo_SurfaceFlags,
set_surface_usage,
get_surface_usage,
set_character_usage,
Expand Down Expand Up @@ -167,7 +166,6 @@ class Halo_ScenePropertiesGroup(PropertyGroup):
)

classeshalo = (
Halo_SurfaceFlags,
ASS_JMS_ObjectPropertiesGroup,
ASS_JMS_MeshPropertiesGroup,
ASS_JMS_MaterialPropertiesGroup,
Expand Down
3 changes: 1 addition & 2 deletions io_scene_halo/misc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ def execute(self, context):
from ..misc import generate_level
scene_maze = context.scene.halo_maze

return global_functions.run_code("generate_level.generate_level(context, scene_maze.game_title, scene_maze.level_seed, scene_maze.level_theme, scene_maze.level_damage, scene_maze.level_goal, scene_maze.player_biped, scene_maze.level_conflict, scene_maze.mutator_random_weapons, scene_maze.mutator_extended_family, scene_maze.maze_height, scene_maze.maze_width, scene_maze.output_directory)")
return global_functions.run_code("generate_level.generate_level(context, scene_maze.game_title, scene_maze.level_seed, scene_maze.level_theme, scene_maze.level_damage, scene_maze.level_goal, scene_maze.player_biped, scene_maze.level_conflict, scene_maze.mutator_random_weapons, scene_maze.mutator_extended_family, scene_maze.maze_height, scene_maze.maze_width, scene_maze.output_directory, self.report)")

class ExportLightmap(Operator, ExportHelper):
"""Write a LUV file"""
Expand Down Expand Up @@ -1853,7 +1853,6 @@ def unregister():
del bpy.types.Scene.halo_h3ek_path
del bpy.types.Scene.halo_h3ek_data_path
del bpy.types.Scene.halo_mattype
del bpy.types.Scene.halo_lightmapper
for clshalo in classeshalo:
bpy.utils.unregister_class(clshalo)

Expand Down
Loading

0 comments on commit 36851e5

Please sign in to comment.