[Include] gStream Helper
#1

This include may be interesting for you,if you use an object streamer ( doesn't matter which one ! ).
It gives you the exact distance an Object is visible in GTA San Andreas.
I released a script like this months ago ( here ) but it was very slow and used a lot of memory.Furthermore it didn't include the distance for every object.

It now includes every object,saves a lot of memory compared to the old version and is much faster!
I made two version, the first one is slighty faster then the seconds one,but needs about 250kb more then the seconds version. As alreasy said,the seconds version is a bit slower,because it uses bitwise operations.However,it saves a lot of memory. You decide which one you want to use.
I use the seconds version, but it's up to you.

Quote:

readme;
This Include gives you the exact distance the Object is
visible in GTA San Andreas.
All distances are collected from the GTA IDE Files and contains
normal Objects, timed-Objects and animated Objects.

Why should you use this?
If you have many objects in your script and you stream all of them at
a distance of 200 units,this might not be very clever because some
of those objects get streamed by GTA at distance of 100 units or even
250 units.
Streaming the object then at a distance of 200 units is either to high
or too low. This include will help you and give you the distance the object
will be streamed by GTA, no matter from which distance you want it to get streamed


It is very usefull in combination with an Object streamer, I would
advise you to use the one by Incognito ( Incognitos Streamer Plugin ).
At the moment it is the best one you can find for SA:MP !

Usage:

GetObjectMaxDistance( #MODELID , #DEFAULT_DISTANCE );

#MODELID , the modelid you want to get the distance for
if you use an invalid MODELID,it will return the #DEFAULT_DISTANCE


#DEFAULT_DISTANCE , this is used in case you use an invalid #MODELID
the function will then return you given value instead of a random one


CreateDynamicObjectEX( ... );

An extra function you might choose if you use the Streamer Plugin by Incognito.
You only have to rename the function CreateDynamicObject() to CreateDynamicObjectEX().
I added an extra parameter at the end which add an extra_distance to the draw distance


COMPILE_OPTIONS :

- FAST_VERSION , Doesn't include Debug-Informations



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

gStream_Help.inc - 297 kb ; 18500 functions call @ 8ms


gStream_Compress_Help.inc - 41,8 kb ; 18500 functions call @ 8ms ( some extra calls,slighty slower )

!! Important !! Limits the MaxDistance to 512 Units !

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

by Daniel "Goldkiller" , gStream Helper
8.11.2010


IMPORTANT:

DO NOT CHANGE THE ARRAY IN IT'S ORDER OR YOU WILL GET WRONG RETURN VALUES!

gStream_Helper.rar
Reply
#2

Thanks for your post,I really appreciate it.I actually learned how to use bitwise operations from your code optimisation thread.You do a great job.
Quote:
Originally Posted by ******
Посмотреть сообщение
You shift values by 10 and 20, but then mask them by 1FF when you could use 3FF and get a max view distance of 1023 without modifying any other code.
Guess I made a mistake,I thought 2^10 is 512 instead of 1024.That's why I used 511 / 0x1FF instead of 1023 / 0x3FF.
if (!(0 <= iIndex < sizeof (IDEData)))[/PAWN][/quote]
Is it actually faster? I have seen this method in your code optimisation thread.However,I never really used it.

Quote:
Originally Posted by ******
Посмотреть сообщение
if (IDEData[iIndex][IDE_iDistance] == DEFAULT_NOT_VALID)
Uhm.Yeah :-O

Quote:
Originally Posted by ******
Посмотреть сообщение
The one thing I've thought of before is a LOD lookup table so where LOD versions of models are available, creating an object will also create a LOD version with a much higher view distance in the streamer.
I get what you mean.I already wanted to make a list which gives you easy access to the LOD parent of a model.
The problem was,the only way to get the LOD parent of an object is going through all the IPL files,see if there is a pointer to a specific IPL line ( not -1 ) and look up which modelid is used in this speicific IPL line. I was too lazy to script something for this :/.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
Answers in reverse order for no good reason...

The LOD thing would be a bit of work - that's the main reason I've not done it.
Alright,I collected all ( I hope so ) the information needed.
pawn Код:
//fDistance , iLODModelID,
// fDistance , should be clear, the draw distance
// iLODModelID , the modelid of the LOD parent.
// IS_PARENT , this model is an LOD parent
// NO_PARENT , this model doesn't have a LOD parent.
{110.0, IS_PARENT}// 7861
{130.0, IS_PARENT}// 7862
{230.0, 7876}// 7863
{230.0, 7875}// 7864
{230.0, 7874}// 7865
{230.0, 7872}// 7866
{230.0, 7871}// 7867
{230.0, 7870}// 7868
{1500.0, IS_PARENT}// 7869
{1500.0, IS_PARENT}// 7870
{1500.0, IS_PARENT}// 7871
{1500.0, IS_PARENT}// 7872
{1500.0, IS_PARENT}// 7873
{1500.0, IS_PARENT}// 7874
{1500.0, IS_PARENT}// 7875
{1500.0, IS_PARENT}// 7876
{1500.0, IS_PARENT}// 7877
{230.0, NO_PARENT}// 7878
{1500.0, IS_PARENT}// 7879
{195.0, 7887}// 7880
{230.0, 7855}// 7881
{270.0, 7883}// 7882
{1500.0, IS_PARENT}// 7883
{170.0, NO_PARENT}// 7884
...
However,I'm not sure if the LOD parent uses exactly the same co-ordinates and rotations as the normale object.
If you want to take a look at it,just send me an message.
Would be awesome to see an inbuild-LOD system in a good object streamer ( Incognitos for instance ).

Edit:
Uhm,this might be pretty useless thought.
Quote:

CreateObject:
Float : DrawDistance (optional) The distance that San Andreas renders objects. 0.0 will cause objects to render at their default distances. 300.0 is the usable maximum.

No matter what drawdistance you use,the maximum is still 300 units ...
Reply
#4

Delete please.
Reply
#5

Link doesn't work. Someone post it again, please
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)