Sign in to follow this  
Guest GerrishGray

Crash Detection code

Recommended Posts

Hi allIt might be useful if we could collate information on the correct use of the various commands for crash detection in scenery BGLs. (This follows on from a mention in another current thread, and an earlier thread that never reached a proper conclusion.)Mental Health Warning: This stuff is a bit techie ... you might not want to get involved if you're not a bit of a 'codehead'!!!The particular question that has arisen is whether the CrashIndirect command is necessary to 'activate' crash detection code encapsulated in a library object. This command was introduced when library objects first appeared. The SDK never explained what the command actually does, but the implication was that it was required to initialise crash detection monitoring, and this separate command was necessary because of the slightly different nature of 'section 10' library objects rather than traditional section 9 objects.There have been several reports, however, that some FS2002 library objects will generate crashes even without a CrashIndirect command in the section 9 calling sequence to turn the crash detection on.Sometimes this is probably a result of the methods different designers and/or design tools use for crash detection. For example, FSDS doesn't use the 'standard' crash detection commands but instead checks the distance from the centre of the object in the x,y,z directions by checking three global variables with the IFIN3 (IfVarRange3) command. This code probably doesn't need any separate initialisation anyway.So the immediate questions are[ol][li]What exactly do the Crash (opcode 0x94) and CrashIndirect (opcode 0x95) commands do?[/li][li]Are they still required in FS2002?[/li][li]And if the answer to 2. is "sometimes", which crash detection methods require this initialisation and which don't?[/li][/ol]If nobody knows the precise answers - and I suspect that this will prove to be the case - then some testing and even a bit of constructive speculation might help!Anyone got any information (beyond what the SDKs fail to tell us properly!), ideas, experiences or useful thoughts ...?!CheersGerrishPS. I rarely bother with crash detection in stuff I design anyway - so I don't know much about this topic. But it would certainly be interesting to know more!

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

This is a topic I have been wondering about. My alternative add-on question is why there is an option for Crash Detection in GMAX and it does not work when converted through MakeMDL. Does it work in aircraft?In my DCA scenery I also ignored the crash detection basically because I tried a few things and it did not activate so just thought I would leave it.I am not a techie but if you want me to try the code then by all means let me know what is your desired direction.RegardsShez

Share this post


Link to post
Share on other sites

Hi all.Here's a small SCASM code that places a library object. The object's code ( in the default 'scenery_fs_sco.bgl' library ) contains older "CrashBox" code. The placing bgl requires no crash detection, and the sim registers the crash:

; ----------------------------------------; DelavanStateCapitol.sca ( Sco_statecapital1 ) ; ----------------------------------------Header( 1  N42:38:01.80 N42:38:01.80 W088:36:33.00 W088:36:33.00 )LatRange(  N42:38:01.80  N42:38:01.80 )Area( A N42:38:01.78 W088:36:33.00 100 )	IfVarRange( :  0346 2 32767 )	PerspectiveCall( :_PlaceObject_1 )	ShadowCall( :_PlaceObject1 )	Jump( :EndA ):_PlaceObject_1	RefPoint( rel :ReturnObject_1 0.50 N42:38:01.80 W088:36:33.00 V1= 0 V2= 187 )	RotatedCall( :CallObject_1 0 0 0 )	Return:CallObject_1	CallLibObj( 0 C545A292 11D2E2EC 1000849C 2AE60C5A ):ReturnObject_1	ReturnEndA

Dick

Share this post


Link to post
Share on other sites

This reply is a bit off topic (meant as a reply on Shez, but I now see it doesn't appear there :)), but when you include crash detection in GMax your object will certainly have it.BUT, I think you placed your objects with FsRegen and a lib? And FsRegen only takes the object information from the _0.asm file, while the crash information is in the other file (that also places the object). This means that you will not see crash detection then (unless you add some code to your calling API to get it back again).And for Gerrish, just like you say, I have never wondered much about the crash detection (and left it out most of the time, because it is more annoying then usefull), so I can't add much usefull info about the different commands to the discussion.Arno


Member Netherlands 2000 Scenery Team[a href=http://home.wanadoo.nl/arno.gerretsen]http://home.wanadoo.nl/arno.gerretsen/banner.jpg[/a]

Share this post


Link to post
Share on other sites

Hi Arno.You are exactly right.When using fsregen to create the object library, it doesn't include the crash detection code that actually lies in the example.asm, not the example_0.asm. So it never gets to the library. That can be cured by copying the crash routine to preceed the start of the library object code:; Library Compiler - fsregen v0.31b by G.Ioannu ; Freeware. Commercial use is prohibited.; header label word dw 0001 dd 000989D57H dd 0FF6914C5H dd 07FFFFFFFH dd 080B60B62H dw 22 dup(0) dd (offset LIBRARY_DATA) - (offset header) dw 10 dup(0) dd 0B86CAFDAh dd 049133A72h dd 0B86CAFDAh dd 049133A72h dw 14 dup(0)LIBRARY_DATA label word dd (offset LIBRARY_0) - (offset LIBRARY_DATA) dd 0B86CAFDAh, 049133A72h, 085C23CA8h, 0D335043Fh dd 0,6,8 dd (offset LIBRARY_DATA)LIBRARY_0 label word dd 0B86CAFDAh, 049133A72h, 085C23CA8h, 0D335043Fh db 100 dd (offset LIBRARY_0_HE) - (offset LIBRARY_0) dd (offset LIBRARY_0_END) - (offset LIBRARY_0_START) dd 263 dd 131072 dd 0 dd 0 db "HouseObject" dd 0LIBRARY_0_HE label wordLIBRARY_0_START label word; i; fsregen labels !!!! DO NOT REMOVE THIS LINE !!!;--------- WARNING - WARNING - WARNING - WARNING - WARNING - WARNING ---------;; This file was automatically generated from C:Program FilesgmaxgamepacksFlightSimHouseObject; using the MakeMDL tool. Do not edit by hand, re-run the; tool instead.;; generated on 12/12/02 09:01:39;;--------- WARNING - WARNING - WARNING - WARNING - WARNING - WARNING ---------; BGL model for C:Program FilesgmaxgamepacksFlightSimHouseObject;; $Header:$;;----------------------------------------------------------------------------model_crash label BGLCODE BGL_CRASH_START model_crash_end, 481 BGL_CRASH_OCTTREE crash_end_1 dw CRASH_FLAG_OBJECT ; crash type dw 113 ; nodes used real4 -344.344849,0.000000,-342.940613 ; Box x,y,z real4 680.296814,296.904022,519.955750 ; Box w,h,d dw 1, 24, 24, 45, 62, 72, 72, 97 ; base offset into node table, one for each top-level branch ; So if you take branch 2 (count from 0), you add 24 to indices you encounter on that branch ; Nodes (254=empty 255=full, else an index into branch) OCTTREE_NODE 0, 255, 0, 0, 0, 255, 0, 0 ; node 0 OCTTREE_NODE .........and so on........crash_end_1 label wordmodel_crash_end label word;; Final Status: 82 polys; Alpha Status: 0 polys; Light Status: 0 polys; Library Status: 0 polys;; Start Time: 12/12/02 09:01:39; Stop Time : 12/12/02 09:01:39;; Modeling units = 2.0000; Radius = 262.0722; Radius in meters = 262.0722; Radius in modeling units = 525;HouseObject_topG0 label BGLCODE BGL_BEGIN 0800h ; version = 8.00 TEXTURE_LIST_BEGIN TEXTURE_DEF TEXTURE_AIRCRAFT , <255,255,255,255>, 234.702213, "HOUSE.BMP" ; 0 TEXTURE_DEF TEXTURE2_NIGHT , <255,255,255,255>, 234.702213, "HOUSE_LM.BMP" ; 1 TEXTURE_LIST_END MATERIAL_LIST_BEGIN MATERIAL_DEF 1.000000,1.000000,1.000000,1.000000, 0.392157,0.392157,0.392157, 0.000000,0.000000,0.000000, 0.000000,0.000000,0.000000, 0.000000 ; 0 MATERIAL_LIST_END VERTEX_LIST_BEGIN VERTEX_DEF -344.344025, 199.640015, 176.584015, -1.000000, 0.000000, 0.000000, 0.363202,0.965067 ; 0 part= 1 prim=0.........If you note where I pasted it in the library.asm, you'll see that it performs the crash routine before the object is created. Works perfectly.This also needs no Crash routine in the Library Object placing BGL... the crash is essentially part of the object:; ----------------------------------------; DelavanHouse.sca ( HouseObjectLib2.bgl Library object Placer ) ; ----------------------------------------Header( 1 N42:38:01.80 N42:38:01.80 W088:36:33.00 W088:36:33.00 )LatRange( N42:38:01.80 N42:38:01.80 )Area( A N42:38:01.78 W088:36:33.00 100 ) IfVarRange( : 0346 2 32767 ) PerspectiveCall( :_PlaceObject_1 ) ShadowCall( :_PlaceObject1 ) Jump( :EndA ):_PlaceObject_1 RefPoint( rel :ReturnObject_1 0.3 N42:38:01.80 W088:36:33.00 V1= 0 V2= 187 ) RotatedCall( :CallObject_1 0 0 5 ) Return:CallObject_1 CallLibObj( 0 B86CAFDA 49133A72 85C23CA8 D335043F ):ReturnObject_1 ReturnEndA-------------------------------------------Of course, now there is a decision to make: Is it better to include the crash detection in the Library object, or should it be part of the placing BGL ( or placing API )?For a single tree or house, it wouldn't matter. But if I were to recreate my hometown, I need thousands of buildings and tens of thousands of trees... do I want crash detection with them all? I don't know what the CPU overhead is with the crash dection routine, but multiplied by thousands, it might be a problem, even if the sim's crash detection is turned off! The sim will probably still process the detection routine.So perhaps the Gmax-fsregen method is best... to have the crash routine outside the Object Library code.Dick

Share this post


Link to post
Share on other sites

Maybe I am wrong, but I thought that the library.asm file from FsRegen included the _0.asm file of the object? So then the object code is not part of the library.asm file and the easiest way is probably to paste the crash code at the top of the _0.asm file.Arno


Member Netherlands 2000 Scenery Team[a href=http://home.wanadoo.nl/arno.gerretsen]http://home.wanadoo.nl/arno.gerretsen/banner.jpg[/a]

Share this post


Link to post
Share on other sites

Hi Arno.Yes... could be done.; Library Compiler - fsregen v0.31b by G.Ioannu ; Freeware. Commercial use is prohibited.; header label word dw 0001 dd 000989D57H dd 0FF6914C5H dd 07FFFFFFFH dd 080B60B62H dw 22 dup(0) dd (offset LIBRARY_DATA) - (offset header) dw 10 dup(0) dd 0B86CAFDAh dd 049133A72h dd 0B86CAFDAh dd 049133A72h dw 14 dup(0)LIBRARY_DATA label word dd (offset LIBRARY_0) - (offset LIBRARY_DATA) dd 0B86CAFDAh, 049133A72h, 085C23CA8h, 0D335043Fh dd 0,6,8 dd (offset LIBRARY_DATA)LIBRARY_0 label word dd 0B86CAFDAh, 049133A72h, 085C23CA8h, 0D335043Fh db 100 dd (offset LIBRARY_0_HE) - (offset LIBRARY_0) dd (offset LIBRARY_0_END) - (offset LIBRARY_0_START) dd 263 dd 131072 dd 0 dd 0 db "HouseObject" dd 0LIBRARY_0_HE label wordLIBRARY_0_START label word; Paste the Crash Code here ( or make an 'include HouseObjectCrash_0.asm' , and create "HouseObjectCrash_0.asm" which contains just the crash code ripped from "HouseObject.asm" ). That would make the code a bit more readable, and 'modular' in nature. include C:Program FilesfsregenHouseObject_0.asmLIBRARY_0_END label word dd 0,0,0,0Dick

Share this post


Link to post
Share on other sites

I see so we will then have to hand code each (finalised) library object within the 0asm so when it compiles it will have crash detection. A novel way to bypass FSRegen I guess. I wish Giorgio was around to do this as a routine in FSRegen...:-( Shez

Share this post


Link to post
Share on other sites

'object_0.asm' is the object itself, from the Gmax derived code. 'object.asm' is placing code, and which contains the crash routine.Fsregen "includes" the original Gmax-derived 'object_0.asm' code in the library.asm, which now defines the object, but not the crash-code.Fsregen doesn't put the crash code anywhere, so that's why Shez has no crash detection for his Gmax-Fsregen library objects.So the crash routine must be manually added to the library.asm code ( or "included" in the library.asm code ), or put in the placing API. The placing API is SCASM, so it would be difficult to place the original crash-code there, as the crash-code is in BGLC format. But it can be done if you're willing to hand-translate the BGLC-ASM crash code to SCASM equivalents. ( BGLAnalyze doesn't seem to be able to handle the conversion ).Dick

Share this post


Link to post
Share on other sites

Hi guysFrom what you say, Dick, and from other previous reports, it is begining to appear that including the CrashIndirect command in the calling sequence is entirely unnecessary in FS2002 and that crash detection in a library object will always work in FS2002 without this initialisation (or whatever it was supposed to do). The only contra-indication will be if someone reports results of some testing where removing/omitting CrashIndirect turned crash detection off for a particular model ...In the new CRASH_START, CRASH_OCTTREE sequence, CRASH_START seems to be the only initialisation required, and its function seems simply to be to say where the crash detection code ends and to do a simple 'crash sphere' test before embarking on the full-scale crash detection, so that the crash detection overhead is minimised and only takes effect when close to the object anyway.In the examples I have examined, there is usually a Return after the Crash OctTree, which seems logical, but I notice that you have omitted this in your example - was that intentional? Mind you, it's not entirely clear what address those Returns actually return to. Perhaps CrashStart pushes the label address onto the scenery engine's stack so that it becomes the return address to be used. That would work (but is a rather unusual way of doing things). It could also explain why your sample code might still work correctly without a Return, because the net effect would be the same apart from a failure to pop the unused address off the stack. This wouldn't matter as long as the rest of the code in the object was correctly structured, because I suspect that the stack structure used within an object is automatically cleaned up at the end of the object anyway (simply by discarding it). This would also account for the some of the tolerance of the engine to missing returns and other structural errors.I think this modern crash detection code is probably quite efficient and the overhead and frame rate effect may be fairly minimal, as long as one keeps the radius argument to CRASH_START as small as possible.As regards CrashOctTree, I believe that the node branch addresses are always relative to the current node, allowing 0 to be used as a recursive re-entry, and also explaining why 254 is used as the 'empty' value rather than 0. This use of recursion makes an octtree a really efficient data storage structure for 3D spatial data. The wording in the SDK appears to be a bit misleading as it seems to suggest that the offsets are relative to the base node, which I don't think can be correct?But one thing that still needs confirming is the spatial arrangement of the eight cells in each node of the octtree structure. Perhaps CrashOctTree should be discussed in a separate thread. Otherwise, as usual, we could end up hiding important conclusions within a great long thread dealing with a different topic ... :-)CheersGerrish

Share this post


Link to post
Share on other sites

Hi Gerrish.There are 3 older ways of adding a crash to an object: BGL_CRASH ( 0x94 ) is to be used as part of the object before the ADDOBJ command. It allows a density activation level. It is NOT to be used as part of a library object.BGL_CRASH_INDIRECT ( 0x95 ) is used when you are "calling" an object ( library or other ), and is to be NOT to be used as part of that library code, but should be used in the "placing" BGL ( library placing API ), for a library object that doesn't have it's own crash-code. It allows a density activation level.BGL_CRASH_START ( 0x96 ) is used as part of a library object ( and I don't see any density activation level ).--------------------------- Here's some library code from CFS1:

; Library Object #4, Offset 0x15A8, size 17752 (= 0x10000); ----------------------------------------ObjID( 9797FC57 8A930060 11D14AC5 A028DBB3 )LibObj( 	PWR   0	SIZE  6	SCALE 0.100	TYPE  1024	NAME   "AM75MM"	)	CrashStart( :L0015FB 23 ); offset to end of crash code  +  radius of 23	CrashBox( :L0015F9 -9 0 -29 9 23 29 0 0 0 ); failure return  +  the box	SetCrashCode( 14 ); set to CRASH_BUILDING_PLANE ( Gmax sets it to 20 ? )	Return:L0015F9	Return:L0015FB;--------------------------- end of crash code	IfVSize( :L001611 18 1 )	IfVSize( :L00162B 3 2 )	Jump32( :L001A4D ):L001611	Points( 0			0	0	 0;   0	)	LineColor( 00 F0 )	Dot( 0 0 0 )	Return:L00162B	VecPoints( m 0		  -11	0	19 -32767	  0	  0;  0.........

This Library object would NOT be called with BGL_CRASH_INDIRECT, as it already contains crash code from SCASM's CrashStart ( BGL_CRASH_START ).-----------------------I think most default library objects already have crash detection in the library object, and so don't need a BGL_CRASH or BGL_CRASH_INDIRECT calling routine.-----------------------Apparently, the newer BGL_OCTTREE can be used either as part of a library object, or as part of a non-library object ( I have tried both ). I don't know if BGL_OCTTREE can be used outside the object, as part of an API (?) or library object placing routine for a crashless library object. That would be the next logical place to check, as that would allow us to create libraries with non-crashing objects, and API-place them with the more advanced OCTTREE Crash detection ( which we could cut'n'paste from a Gmax-derived ASM ).------------------------Meanwhile, what is FSDS2 using for crash detection, and where is it placed?-----------------------And, does the shadow placement affect the crash for any of these methods, as that does call a library object.Dick

Share this post


Link to post
Share on other sites

Hi againThe crash detection code properly belongs with the object in the library - it would be silly to put it in the calling API - rather goes against the idea of using library objects in the first place!There is no problem coding the CrashStart(), CrashOctTree() crash detection method in SCASM if one wants, though - the only reason that BGLAnalyse has problems decoding many of the default FS2002 library objects into SCASM code is because there is a mistake in the coding of those objects with an extra, redundant, Return command that gets BGLAnalyse confused. I guess this comes from a mistake in makemdl.exe (another one!).Returning once again to my favourite hobby-horse: the only valid reasons for working with BGLC rather than SCASM are (a) creation of TMF, or (:( hacking/creating/enhancing the assembler code output by gMax/makemdl.exe Using BGLC for anything else is just plain masochism (unless one is deliberately trying to learn a little about assembler coding - although using BGLC doesn't really teach you much about that beyond a few basic principles). Incidentally, this is the reason why it is relatively difficult to lay your hands on a copy of MASM these days and why it is no longer sold as a separate product - not that many people in the programming world have much use for it any more, and those that do usually get a free copy bundled with their C++ development suite anyway.CheersGerrish

Share this post


Link to post
Share on other sites

Hi Gerrish.The only advantage of a no_crash library object, would be if it were found that the crash-detect subroutines were causing a large CPU hit.For example, if you were to place 20,000 of your trees from crashless library objects, would they have less of a CPU drag than placing 20,000 from a library object that has crash detection? I suspect the crashless objects would be less of a burden for the sim... but I don't have any idea what the amount of difference would be.Also, there might be the possibility of crashing into invisible objects by fooling with the density-level activation.... a rather evil usage of 'exterior' crash detection. :-wink2 P.S.The whole TMF-TDF BGL creation process would be helped if it were incorporated into SCASM's code. I'm not very fond of BGLC either.I thought an ASM_SCASM translator would be a good idea, especially for GMAX-derived code. Shez, and other Gmax users, are now forced to hack the ASM up to make proper library objects. And George won't be updating Fregen.Dick

Share this post


Link to post
Share on other sites

Hi DickThe current problem with SCASM is that it has no provision for including a pointer to section 8 structures in the BGL header. If someone could persuade Manfred to do this, then you could provide some SCASM macros for the TMF stuff and it would also be possible to write a BGLC to SCASM translator as you suggest.A BGLC to SCASM translator for non section 8 code shouldn't be too difficult to write though, if somebody has the time and will to have a try ...I believe that the SCASM alternative, FreeSC, actually is able to generate code for any BGL section. I've tried writing to the author, Takuya Murakami, expressing interest and offering to help with the future development/documentation of his project, but have received no reply. Perhaps someone else who knows Takuya better might have more luck? FreeSC also has the facilities you need for writing your TMF stuff as 'SCASM' commands - it's potentially a great alternative to SCASM if Takuya is still interested in developing it. Doug Pouk uses it successfully with FS Architect.Gerrish

Share this post


Link to post
Share on other sites

Yes, what I was saying about CrashOctTree was that there was no logic in placing it in the calling api if one is using a library object. It's better off in the library object. But it can of course be used in section 9 objects as well - that is how gMax uses it.I have never included crash detection in my trees because frame rate efficiency is SO important with trees. But that situation is changing because Autogen now provides the majority of the background trees and individually programmed trees like mine are now only needed for the immediate surroundings of a scenery, where crash detection is possibly more important (e.g. on runway approaches and when taxying around an airfield). I might even add crash detection to a future version of the trees library, perhaps as a selectable option, but I haven't made my mind up yet whether to bother (and that isn't why I started this thread - that was motivated merely by a desire for better understanding!).To return to the original question, what we need to clarify is whether CrashIndirect() is EVER required in FS2002, or whether crash detection code in library objects always works fine without it. It's beginning to look as though this is a redundant command that actually does nothing in FS2002?I don't think that CrashIndirect ever created crash detection by itself - it's apparent purpose was always only to 'initialise' or activate crash detection in a library object in some way. The actual crash detection code using the other commands always had to be in the library object code anyway. Hence the puzzle of why CrashIndirect() was required, what it actually did, and why it no longer seems to be needed.Or perhaps all it effectively does is provide an independant control of the scenery density level at which crash detection becomes active?CheersGerrish

Share this post


Link to post
Share on other sites

Just to add some random thoughts:The default FS2002 gmax library call bgls use crash_indirect if I remember right (I decompiled them). BUT makemdl doesn't place a crash_indirect in the BGLC source. As far as CPU hit is concerned, I think the octtree solution should allow for many, many objects with hit detection enabled, but if we want numbers, I guess we'd have to experiment...Cheers, Christian

Share this post


Link to post
Share on other sites

Hi Christian.Am I right in assuming the OCTTREE commands are a "fitted" crash detection, instead of a radius or a box... Clinging more closely to the objects exterior 'skin'?---------------Here's a section of decompiled "cheklap_placement.bgl", from the 'hongkongscenery' folder:

; ----------------------------------------; Object # 1, offset: 0x0013 size: 111 bytes (0x006F) ;; Lat: 00025D6EFh Lon: 05104AB2Dh; ----------------------------------------Area( A N22:18:53.24 E113:55:54.82 100 )	IfVarRange( :  0346 5 32767 )	CrashIndirect( :L00006C :L000040 :L000060 0 0 )	ShadowCall( :L000040 )	PerspectiveCall( :L00003E )	Jump( : ):L00003E	Perspective:L000040	RefPoint( rel :L00006A  0.50 N22:18:53.25 E113:55:54.82		V1= 500 V2= 10 ):L000060	RotatedCall( :L00006C   0   0  67 ):L00006A	Return:L00006C	CallLibObj( 0 8C038540 4C47B71C FC133C87 904A8940 )	ReturnEndA

That object is found in vehicles.bgl... veh10 is the name, and the library object does seem to have CRASH_START and OCTTREE commands, as Christian indicated it might. It's an FS2002 FL-point object with 3 LODs ( that I can tell ).Attached is a pic.Odd. And I can taxi through the object, and it doesn't cause a crash.Dick

Share this post


Link to post
Share on other sites

Hi ChristianWe started this conversation about CrashIndirect once before I remember, but never reached a firm conclusion as to whether it is actually needed in FS2002 or not. Dick's contributions seem to be suggesting that it may not actually be necessary in FS2002 (despite what the SDK still says), even though it still seems to be included in some of the code sequences used for calling library objects. I never really understood what it was supposed to do anyway, which is why I started this thread ...One possible hypothesis is that it controls the scenery complexity at which crash detection becomes active for any particular object (given that the object contains crash detection code anyway). This would enable higher-complexity scenery to use crash detection whilst a lower complexity setting would turn it off and save further on frame rates / CPU load. But if that is ALL it does (did?), why the need for all those labels as well - it looks more as though it was necessary for some sort of initialisation of the crash detection process to me, but I'm only guessing here and don't understand why it might have been needed in an earlier sim version but not, perhaps, now? Any useful thoughts?If only MS gave us proper reference documentation of the BGL language! It is Christmas in a couple of weeks so I'm entitled to dream the improbable ... but I don't really expect Santa Claus to be coming down my chimney with any such present from Redmond!Gerrish

Share this post


Link to post
Share on other sites

Hi DickYes, an octtree can indeed produce an accurate representation of any solid shape, whether it is for crash detection purposes in FS or for some other purpose entirely.An octtree is a data structure that is designed to contain 'binary tree' data about a 3D space. The space is divided into 8 cells by dividing each of the three dimensions in half. Each cell can be successively halved into 8 more cells, to any required level of detail, thus creating a sort of binary tree in three dimensions.Hence the eight values at each node of the tree.By allowing recursive entry into the same node for different branch levels, the structure can be used to create a very accurate description of a 3D shape with sloping surfaces, pointed 'cusps' etc. with a fairly small amount of data. Rather like a fractal, each successive cell for some shapes is just a one-eighth size version of the cell containing it, so the same node data can be used over and over to any required level of detail.In the BGL version, a value of 255 is used to indicate a 'solid' cell that causes a crash, whilst 254 indicates an empty cell space with no crash potential. All other node values are pointers (or rather offsets) to other nodes that break the cell down into eight more cells. An offset of zero gives an infinitely re-entrant recursion into the same node. Like me, you might need to visualise, or draw, this in a 3D representation to understand.At least, that's my present understanding. Octtrees hadn't been invented in my day (i.e. when my poor old brain was still using a reasonable proportion of its grey matter), so I don't claim to be any sort of authority on the subject!!!Interestingly, the full specification for the DDS texture format available in DirectX includes provision for a 3D octtree version as an alternative to the 2-dimensional bitmaps we are accustomed to. Support for this might well be introduced in a future version of FS for modelling true volumetric 3D clouds etc - CFS3 has already adopted the DDS format in place of DXT, but I don't know whether it supports the 3D variant.At this rate, before long we are all going to need a degree in brain surgery or quantum physics (or maybe both) to understand how FS works!!!CheersGerrish

Share this post


Link to post
Share on other sites

Hi Gerrish.In the above example, The scenery density needs to be set to extreme density, or the object doesn't show... and it obviously is 3 LOD levels, each with their own crash OCTTREE. Does the 0 in the density parameter mean there is no crash? I think yes, because the library object does have crash code, and now needs something to deactivate it. It requires extreme density to show, and we could have aircraft crashing into an invisible object at lower density... so it deactivates the crash code of the library object, with the zero setting in the CRASH_INDIRECT call? Perhaps.So there is a use for CRASH_INDIRECT.Dick

Share this post


Link to post
Share on other sites

Surely a 0 in the density parameter for CrashIndirect is going to turn crash detection ON at all density settings, not disable it? I think the value would need to be > 5 to turn crash detection off completely, or 5 in your example where the crash detection is only required at extreme density. But isn't there a density check in the calling sequence before the code ever reaches the CrashIndirect anyway?Gerrish

Share this post


Link to post
Share on other sites

Hi Gerrish.I think in:IfVarRange( : 0346 5 32767 )the 5 sets the object density as Extremely Dense:Sparse = 1Normal = 2Dense = 3Very Dense = 4Extremely Dense = 5... at least this is essentially what Gmax does:IFIN1 OBJECT_0_FAIL, image_complex, 3, 32767with 3 the setting for Normal. Zero isn't used in Gmax, as a condition doesn't need to be set if the density is Very Sparse... it always shows.------------Then:CrashIndirect( :L00006C :L000040 :L000060 0 0 )sets the crash detection to zero... or nothing. That's a guess, but I can verify tomorrow, that zero turns crash detection off... Very Sparse is again not needed, because the crash-code is in the Library object code, and doesn't need to be activated, if all levels will have the crash.I'm pretty sure you can 'tune' the activation of the crash separately from the scenery density activation.Dick

Share this post


Link to post
Share on other sites

Hi Gerrishocttrees well explained, I couldn't have done it better...>One possible hypothesis is that it controls the scenery >complexity at which crash detection becomes active for any >particular object (given that the object contains crash >detection code anyway). I think this is a good theory, and it makes sense too!>But if that is ALL it does (did?), why the need >for all those labels as wellYou need those labels, because FS2002 still has to place and rotate the octtree (so it fits the visual object), at least that's what I'm guessing.>If only MS gave us proper reference documentation of the BGL >language! It is Christmas in a couple of weeks so I'm >entitled to dream the improbable ... but I don't really >expect Santa Claus to be coming down my chimney with any >such present from Redmond! Dream on. Just thinking about this subject brings my blood to boil :-fume I recently learned that SOME documents were floating around in the FS group for MONTHS, at a time I actually asked them for help about the TMF data structure. I got no replies and to think that they had all the answers I wanted sitting in documented form as an SDK which they never released... I have to stop here or I'm going to cry :'( Cheers, Christian

Share this post


Link to post
Share on other sites

:( Anyway...one question, if we have a scene with many buildings does the whole scene get the crash detection? or individual objects? am at work so do not have access to the asm file.Shez

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this