Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Kazan on February 11, 2008, 05:20:58 pm

Title: SLDC: Shield Collision Tree, and you
Post by: Kazan on February 11, 2008, 05:20:58 pm
I created a new chunk in POF CS2 - the Shield Collision Tree (SLDC chunk ID).  I just wrote, tested and commited FS2 engine support.

Some of you may have heard of this, some of you may have not - so I'll go through it.

When FS2 loads the SHLD (Shield) chunk it loads all the shield geometry into "Shield Info" but then it creates 8 octents (a shield triangle may appear in more than one).  When it's checking the shields of a ship it checks every shield triangle in each octent until it gets a collision.  So... best case scenario it has exactly the number of triangles to check (no duplicates).. worst case scenario it has duplicates and no hits....

inefficient.. slows down the entire game.


The SLDC chunk is a collision tree like that found in OBJ2's BSP data (infact PCS2 uses the same code to generate the trees, just different code to pack them into their appropriate data lists).  It should significantly improve performance in missions would many fighters.

All models saved with PCS2 that have a shield mesh will have an SLDC.
Title: Re: SLDC: Shield Collision Tree, and you
Post by: Turambar on February 11, 2008, 05:38:52 pm
it's times like these i wish i had a hot chick i could command to flash her boobies at you.

seeing as i don't and my chest area is furry and generally unattractive, i'll just express gratitude and appreciation.

nice work Kaz.
Title: Re: SLDC: Shield Collision Tree, and you
Post by: Kazan on February 11, 2008, 05:45:42 pm
 :lol:
Title: Re: SLDC: Shield Collision Tree, and you
Post by: blowfish on February 11, 2008, 05:52:16 pm
Cool!  How much of a performance boost can we expect from this?
Title: Re: SLDC: Shield Collision Tree, and you
Post by: taylor on February 11, 2008, 06:12:54 pm
What's the format of the chunk?  You didn't serialize it so it's not cross-platform.  A function needs to be added to byte-swap all of the elements, if needed, based on the platform.
Title: Re: SLDC: Shield Collision Tree, and you
Post by: Kazan on February 11, 2008, 06:13:54 pm
bah good call taylor, sry.  it's intel order as normal - look for mc_sheck_sldc() which is where it's being walked and where you'd have to do byte-swaps (to temp vars obviously)

[edit]
if you have byte swaps in a macro just tell me the macro and i can do it

[edit]
think i found them

[edit more!]
ok.. i have INTEL_INT, INTEL_FLOAT, etc macros in place now... i am currently implementing a feature in the same section of the code so soon as i test it and see it's working ok i'll have the fix for this commited.
Title: Re: SLDC: Shield Collision Tree, and you
Post by: taylor on February 11, 2008, 06:34:49 pm
The byte-swapping needs to be done on model load rather than in the mc function (byte-swapping isn't cheap, and should only ever be done once).  For an example of how it's done with the normal BSP data, have a look at swap_bsp_data() at the bottom of modelread.cpp.
Title: Re: SLDC: Shield Collision Tree, and you
Post by: Kazan on February 11, 2008, 06:41:54 pm
The byte-swapping needs to be done on model load rather than in the mc function (byte-swapping isn't cheap, and should only ever be done once).  For an example of how it's done with the normal BSP data, have a look at swap_bsp_data() at the bottom of modelread.cpp.

i can do that.. revert the change i just made and do it that way :P