RTL_Shadow
1020 posts
|
yeah- they look pretty good. You can pass in a start angle and an end angle and they create a little “sun ray” dynamically.
Here is the class (not really primed for public release but whatever): http://pastebin.com/pxVBKSf5
I’d also appreciate if you could check out the demo and tell me how well it runs. Use WASD/Arrow keys to move. http://www.fastswf.com/Dx8M9Do
|
|
|
UnknownGuardian
8130 posts
|
FastMath class is referenced. What is this class?
|
|
|
alecz127
817 posts
|
If the rays were red and the background was white, it would remind me a lot of chinese symbolism. It looks really weird in the centre where all the rays meet. Not in a bad way, just…. weird.
It runs fairly well on my 6 year old custom.
Would test the code myself, but I don’t know anything about this fastmath class thats referenced.
|
|
|
qwerber
4717 posts
|
Using a Math class like that really doesn’t help with fastness unless you can inline it :P
|
|
|
DrYoshiyahu
678 posts
|
I was really upset when I wasn’t allowed to get the star. :(
|
|
|
RTL_Shadow
1020 posts
|
Yea- i forgot to include a few classes- very sorry about that. Later today I’ll set up a GitHub repo.
@alecz, yeah, it does look pretty weird. In game I’ll probably have a sun there
@qwerber my FastMath.ceil and floor functions are 7x faster than Adobe’s.
@Yoshi, that’s the point of the game :P
|
|
|
BobTheCoolGuy
3750 posts
|
RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?
Also, this:
Originally posted by DrYoshiyahu:
I was really upset when I wasn’t allowed to get the star. :(
|
|
|
RTL_Shadow
1020 posts
|
Originally posted by BobTheCoolGuy:
RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?
Also, this:
Originally posted by DrYoshiyahu:
I was really upset when I wasn’t allowed to get the star. :(
I could very well be wrong, but when I did the whole getTimer trick it all added up.
FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn
|
|
|
BobTheCoolGuy
3750 posts
|
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:
RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?
Also, this:
Originally posted by DrYoshiyahu:
I was really upset when I wasn’t allowed to get the star. :(
I could very well be wrong, but when I did the whole getTimer trick it all added up.
FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn
Ah, well, I didn’t test it, but you do have one small bug. Say you do Math.floor(-9.7). Your code would return -9 instead of -10. Same thing could happen for ceil I think. You also don’t have to explicitly cast your results to Number. I’m not sure what the performance impact of that is though.
|
|
|
qwerber
4717 posts
|
Originally posted by BobTheCoolGuy:
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:
RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?
Also, this:
Originally posted by DrYoshiyahu:
I was really upset when I wasn’t allowed to get the star. :(
I could very well be wrong, but when I did the whole getTimer trick it all added up.
FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn
Ah, well, I didn’t test it, but you do have one small bug. Say you do Math.floor(-9.7). Your code would return -9 instead of -10. Same thing could happen for ceil I think. You also don’t have to explicitly cast your results to Number. I’m not sure what the performance impact of that is though.
Yes; your floor and ciel functions are bugged. If you already know you’re dealing wiht positive numbers however, I would simply inline int() instead of writing out FastMath.floor()
|
|
|
RTL_Shadow
1020 posts
|
Originally posted by qwerber:
Originally posted by BobTheCoolGuy:
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:
RTL, I’m curious as qwerber is. A lot of performance increase in math stuff does come from avoiding a function call (luckily we’ll have inlining in ASC 2.0) Post your FastMath class and performance test maybe?
Also, this:
Originally posted by DrYoshiyahu:
I was really upset when I wasn’t allowed to get the star. :(
I could very well be wrong, but when I did the whole getTimer trick it all added up.
FastMath Class: http://pastebin.com/LrnCBk3H
Vector2D Class: http://pastebin.com/ExE4XPWY
VectorUtils Class: http://pastebin.com/6W9qntDn
Ah, well, I didn’t test it, but you do have one small bug. Say you do Math.floor(-9.7). Your code would return -9 instead of -10. Same thing could happen for ceil I think. You also don’t have to explicitly cast your results to Number. I’m not sure what the performance impact of that is though.
Yes; your floor and ciel functions are bugged. If you already know you’re dealing wiht positive numbers however, I would simply inline int() instead of writing out FastMath.floor()
Yeah- I’ve removed the two functions. Thanks guys. I’ll probably make the sun rays a bit more effecient and document them, then I’ll release them out on github.
As of now UG has helped me set up my GitHub with my FlashUtils here
Feel free to suggest things or point out bugs. Free use too!
|
|
|
BobTheCoolGuy
3750 posts
|
For your radians and degree functions, you should calculate the conversion value and just manually enter the value by hand in the actual function, instead of using a constant.
|
|
|
BigJM
468 posts
|
I disagree; multiplying by a constant is much faster than calling a function (essentially it’s inlining the function). You should, however, actually label them with const so that the compiler folds the division. Or you can precalculate; I prefer seeing Math.PI/180 vs. 0.017453292519943295, though.
|
|
|
BobTheCoolGuy
3750 posts
|
Originally posted by BigJM:
I disagree; multiplying by a constant is much faster than calling a function (essentially it’s inlining the function). You should, however, actually label them with const so that the compiler folds the division. Or you can precalculate; I prefer seeing Math.PI/180 vs. 0.017453292519943295, though.
I don’t think you actually disagree. :D My very confusingly worded statement just meant that this would be better than what he has now:
public static function toRadians( deg:Number ):Number
{
return deg * 0.017453292519943295;
}
|
|
|
BigJM
468 posts
|
No, I do disagree :P I wouldn’t have a toRadians function at all.
|
|
|
qwerber
4717 posts
|
i dont even use degeree; my engine entirely uses radians.
|