| 03-17-2007, 01:18 PM | #1 |
The Graphic System is a library that makes certain graphical aspects in Warcraft 3 much easier. Version: 1.3 Last updated: March 25 - 2007 Features - Easily create primitive and more advanced static shapes such as circles, lines, spirals and more. - Flexibility: manipulate the parameters of the shapes created in many ways. - Geometrical checks - Dynamic effect birth & death: create static objects with a slight delay between units composing them and destroy them in the same manner. - Timed effects. - Dynamic and static destruction of the effects. Promising features to come - Dynamic effects: orbiting around units/a certain point, dynamic wheels - Lightning pools: effects with lightnings - More static effects (eg: stars) I expect criticism to fix possible leaks, flaws and problems. Suggestions are heartily welcome as this system is made for the modding community for great usefulness and easy implementability. Expect new versions. History: Version 1.0 - First version of the system with the basic static shapes (circle,arc,line,spiral,hypercycloid). - Basic geometric checks. Version 1.1 - Dynamic birth and death shapes included. - Radius reduction function added for safety reasons. Version 1.2 - GS_DestroyEffectDynamic() function added. - Timed versions of both static and dynamic (fixed) shapes added. Version 1.21 - Epicycloid shape added and fixed a small bug with hypocycloids. Version 1.3 - Rose shape included - Fixed major bug which caused imperfect (and most of the times incomplete) shapes. Credits: Thanks to Vexorian for the dummy unit model. ~Daelin |
| 03-17-2007, 01:40 PM | #2 |
JASS:function GS_Sin takes real angle returns real local integer k local real kr set angle = GS_ReduceAngle(angle) set kr = (angle-R2I(angle))*GS_Position() set k = R2I(kr) if (kr>(k+0.5)) then set k = k + 1 endif set angle = R2I(angle)+I2R(k)/GS_Position() return udg_LSine[R2I(angle*GS_Position())] endfunction How is calling 4 wrapper functions (Each using at least 15 LoC) in a function that in itself has 13 LoC and is slower because it's a wrapper going to be faster than just calling Sin()? While I realize Sin() is slow, I'll be damned if it's that slow. Your Cos() replacement is negligibly better. If you've done tests on it and somehow it is faster, then please cast aside my ignorance. But seeing that just made lil' red alert lights go off in my head. And erm... Maybe it's ironic here, but your "GS_CircleQuick" function uses TSAs en mass inside of a loop. That would be pretty... Slow, and inaccurate on BNet. Timers would be far superior. I really like the PART 5 stuff for geometric tests. Some of those checks really aren't intuitive and in themselves are pretty useful to have 'round. But yeah, looks like it would be useful for some people. |
| 03-17-2007, 01:41 PM | #3 |
The idea to use precalc for trig functions appeared in the forums one day. When I benchmarked stuff, native Sin was faster than a non-native function call... Of course, the one to blame would be blizz for making function calls so slow, but there you go. Gamecache is not exactly the best idea. I would have done something like this: JASS:globals effect array GS_linked1 effect array GS_linked2 endglobals function GS_H2I takes handle h returns integer return h return 0 endfunction function GS_LinkEffect takes handle pivot, effect which returns nothing local integer i=GS_H2I(pivot)-0x100000 if (i>=16382) then call StoreInteger(udg_GSCache, "GS_Effect",I2S(i) , GS_H2I(which)) //swapped it, this should be faster and take less memory since it will have a main hash and many values in that hash, // instead of a lot of hashes one value each elseif (i>=8191) then set GS_linked2[i-8191]=which else set GS_linked2[i]=which endif endfunction function GS_GetEffect takes handle pivot returns effect local integer i=GS_H2I(pivot)-0x100000 if (i>=16382) then return GetStoredInteger(udg_GSCache, "GS_Effect",I2S(i) ) elseif (i>=8191) then return GS_linked2[i-8191] endif return GS_linked2[i] endfunction edit: Darn dusk |
| 03-17-2007, 01:46 PM | #4 |
The TSA was mistakenly left there... I forgot it there. Sorry bout that. And indeed... I intuitively found that the Sin would be faster as it doesn't actually calculate the value. It's time to switch to Grimoire I guess. Edit: Just saw Vex's post. What's wrong with gamecache anyway? ~Daelin |
| 03-17-2007, 02:00 PM | #5 |
After seeing the whole graphics system and the precalc trig functions I guessed you were pursuing for speed? |
| 03-17-2007, 03:23 PM | #6 |
Wow looks very nice. And easy to understand and implement too. You should definatle contiue to develop it as i'm sure it will become very popular for making effects. Maybee you should check out http://www-groups.dcs.st-and.ac.uk/~...es/Curves.html if you haven't seen it allready. |
| 03-17-2007, 05:35 PM | #7 |
Oh yes Vex... about that, I just wanted to make certain effects as fast as possible (for example the Cos and Sin stuff). I have a request if someone could nicely help me with it. Would anyone offer to test whether Sin is actually slower than my GS_SinQuick? Because of it isn't, I'll just drop those functions and focus on other aspects of the system. Thanks Oglog... I was planning to implement other curves too. I remember some "flower" made out of multiple cusps I think. I may try to implement something like that too. As you find it useful I'm sure many others will, so what the heck? Time to continue with developing. ~Daelin |
| 03-17-2007, 07:31 PM | #9 |
Maybee a Sinusoidal where p = 2.5? |
| 03-17-2007, 07:55 PM | #10 |
oooooh soo preety |
| 03-17-2007, 08:40 PM | #11 |
Isn't it iFraNe dummy model? -Av3n |
| 03-17-2007, 10:00 PM | #12 |
It is my dummy model, I used INFraNe's model coordinates for animations the rest is mine (my version takes less space...) |
| 03-17-2007, 10:52 PM | #13 |
Sin vs. DoNothing, the benchmark: JASS:function Trig_Melee_Initialization_Actions takes nothing returns nothing local integer sw=StopWatchCreate() local real t0 local real t1 local real t2 local real t3 local integer i call TriggerSleepAction(5.) set t0=StopWatchMark(sw) set i=1000 loop exitwhen i==0 call Sin(GetRandomReal(0,7.283185)) set i=i-1 endloop set t1=StopWatchMark(sw) set i=1000 loop exitwhen i==0 call GetRandomReal(0,7.283185) call DoNothing() set i=i-1 endloop set t2=StopWatchMark(sw) call StopWatchDestroy(sw) call BJDebugMsg( "DoNothing: "+R2S(t2-t1)+" vs Sin: "+R2S(t1-t0) ) endfunction "DoNothing: 0.122 vs Sin: 0.092" |
| 03-17-2007, 10:54 PM | #14 |
So u used iFraNe animations in other words? Lucky yr admin double poster -Av3n |
| 03-18-2007, 02:02 AM | #15 |
That is hawt... +rep... Even if it doesn't work correctly it's still hawt! |
