| 03-31-2007, 01:13 AM | #1 |
This is my physic system, but it dont work as i expect, it lags alot when there are alot of particles, while Anitarf & Infrane's particle system doesnt. I cant find anything in my system (as far as i know) tat leaks anything. So im thinking of slow functions or methods, but i dont know that much. I want the good guys to check my system or simply list all the slow functions or methods to avoid. since im a bit outdated. But in my system im sure i remove every locations, and set their vars to null, also vars of temporarily units to null when not use anymore. But i dont know what else may cause lag. I use asin, acos ect... in my system, not sure if these lags. |
| 03-31-2007, 01:40 AM | #2 | |
First;
Simply to much math to fast. Try and set it to like .04 second / cycle and multiply all increments by 4. Even simple multiplication can lag very badly, and you're using it all over the place, along with SquareRoot. But the main point of the lag seems to be when the particles collide and also when removed. I'd say avoid square root because it's slow, but that's kind of hard to do. So I'll just say cut down on multiplying in any ways you can think of. |
| 03-31-2007, 02:50 AM | #3 | |||
wow why are you making all of this now without using structs? such a waste. what's supposed to be the purpose of this engine over infrane's? or you could wait a few more weeks for mine to be done, unless you are just doing this for learning purposes, which would be a good thing. There are 2 main reasons it's slow: 1. you are doing all kinds of un-needed function calls. function calls are ultra slow in JASS. they take longer than trig functions. 2. the period is 100x per second which is way too much. there's no visual benefit to using anything more than 30x per second. Quote:
Quote:
Quote:
|
| 03-31-2007, 08:26 AM | #4 |
JASS:function Trig_Periodic_Actions takes nothing returns nothing call CameraSetupApplyForPlayer( false, gg_cam_Camera_001, Player(0), 0 ) call CameraSetupApplyForPlayer( false, gg_cam_Camera_001, Player(1), 0 ) call CameraSetupApplyForPlayer( false, gg_cam_Camera_001, Player(2), 0 ) call CameraSetupApplyForPlayer( false, gg_cam_Camera_001, Player(3), 0 ) call PSM_run() endfunction //=========================================================================== function InitTrig_Periodic takes nothing returns nothing set gg_trg_Periodic = CreateTrigger( ) call TriggerRegisterTimerEventPeriodic( gg_trg_Periodic, 0.01 ) call TriggerAddAction( gg_trg_Periodic, function Trig_Periodic_Actions ) endfunction I imagine this lags horribly? Why not just lock the camera to the unit? And as grim001 said, the human eye cannot see quicker than 30 frames per second (.03 periodic). |
| 03-31-2007, 03:36 PM | #5 |
Apart from all the stuff which has already been mentioned (all of which is quite relevant) you have other stuff. Your vector storage seems quite inefficient. You check if your vector exists by looping through 'free pointers' (the system seems rather cryptic and I haven't explored it, so I don't even what it's for, but a debug message showed it getting up to 15+ with only a few particles going). 15+ checks per particle per iteration will add up. I don't even know exactly what you are doing, but I'm sure there is a better way. (You also do the check whenever deleting the particle, getting the unit etc, which you do often and this would further contribute) And yes, you have an inordinate number of fluff functions. PM_destroy (calls particle_getUnit (calls particle_exists) and particle_delete (calls particle_exists)). All of this also applies to your physics stuff. |
| 03-31-2007, 04:08 PM | #6 | |
Quote:
Well, anyone who has played a high-end FPS can tell the difference between 60 FPS and 30 FPS, but in Warcraft 3 the difference isn't great enough to be worth the performance cost. |
| 04-01-2007, 01:15 PM | #7 |
a ok thnx guys, tats all i needed, my current system is alot faster now tho. but still it still lags when it gets to around 30-40 particles And i made this system jsut for learning yes, cus i know others have better systems :D |
| 04-01-2007, 04:29 PM | #8 |
I suggest you port it to structs for a better learning experience |
