Skip to content

Implement a Collision Table Generator #21

@KcRobin9

Description

@KcRobin9

Approximately the second half of the {map_name}_HITID.BND file consists of lookup tables.
These tables are crucial for optimizing collision performance by quickly determining the room/cell an object is located in.

Reverse engineering the table generator is challenging. The game engine generates these tables through a series of function calls as outlined below:

mmCullCity::Init --> asRenderWeb::Load --> mmBoundTemplate::GetBoundTemplate -->

mmBoundTemplate::Load      
(if (x_dim && y_dim && z_dim))

	mmBoundTemplate::MakeTable
		
		mmBoundTemplate::DoMakeTable 	

			mmPolygon::Plot
			
					mmPolygon::PlotTriangle
							
							Vector3::Swap
							swapf
							
							mmPolygon::PlotScan 
							
									j_clamp
									mmBoundTemplate::AddIndex

			mmPolygon::MaxY
			
					mmPolygon::CornersHeight
					
							sqrtf_fast_0
							mmPolygon::CheckCorner
							
					mmPolygon::CheckCellXSide
                    
					mmPolygon::CheckCellZSide

For more context, see the pictures below.

Chicago without a collision table:

Chicago_No_Table

Chicago_No_Table_Perf

Chicago with a collision table:

Chicago_With_Table

Visual representation of the collision table in-game:

Grid_Example_1

Grid_Example_2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions