Antares
Spell Reviewer
- Joined
- Dec 13, 2009
- Messages
- 924
Hello,
Im currently working on a racing map and I wanted to make a physics system with more then just turning, accelerating, braking.
I am still doing the math, but I am worried about the calculations drastically reducing the performance of the map.
I calculate speed, position, forces etc. every 0.02 seconds. With 8 players, this means 400 calculation loops per second.
Each calculation includes several trigonometric functions, which to my knowledge, require more processing time then + - * / ^. This means 4000 or so trigonometric functions per second.
Is this still operated fast enough to not reduce performance?
If it isnt, I had the idea of precalculating the functions into an array.
For example, for the Cosine function:
For each Integer myInteger from 0 to 360, do the following actions:
Set ConstCos[myInteger] = Cos(Real(myInteger))
A cosine operator would then be replaced with a reference to the array: ConstCos[Integer(MyDegree)]. Saving only integer degrees wouldnt reduce accuracy by much, as Warcraft 3 only calculates to the 2nd decimal anyway.
Does this make any sense? Or am I worrying about inanities?
Im currently working on a racing map and I wanted to make a physics system with more then just turning, accelerating, braking.
I am still doing the math, but I am worried about the calculations drastically reducing the performance of the map.
I calculate speed, position, forces etc. every 0.02 seconds. With 8 players, this means 400 calculation loops per second.
Each calculation includes several trigonometric functions, which to my knowledge, require more processing time then + - * / ^. This means 4000 or so trigonometric functions per second.
Is this still operated fast enough to not reduce performance?
If it isnt, I had the idea of precalculating the functions into an array.
For example, for the Cosine function:
For each Integer myInteger from 0 to 360, do the following actions:
Set ConstCos[myInteger] = Cos(Real(myInteger))
A cosine operator would then be replaced with a reference to the array: ConstCos[Integer(MyDegree)]. Saving only integer degrees wouldnt reduce accuracy by much, as Warcraft 3 only calculates to the 2nd decimal anyway.
Does this make any sense? Or am I worrying about inanities?