| 05-22-2006, 09:25 PM | #1 |
Problem: When I call this, it lags terribly. Of course, its more than likely because it loops through everypoint between location start and location end. Question: Is there a way to optimize this function or replace it? Description: I am too terribly lazy to go through and raise every road terrain on the map because I have so much. So, I am trying to raise it all through this function. Also, this would give me more freedom if I could get it to work on all other terrains. JASS:See below for my updated code! |
| 05-22-2006, 09:57 PM | #2 |
Try increasing the interval of the loop and the radius in the function. This way will always lag anyway. Much better to do some real terraining. |
| 05-22-2006, 10:00 PM | #3 | |
Quote:
Ugh that could take hours. Heres a question though...what does the Wc3 engine do to calcuate terrain that my function does not? I am guessing they use native functions of C (or whatever its built with) - but that can't make as big a difference...can it? |
| 05-22-2006, 11:01 PM | #4 |
Youre using un-needed locations and you also leak one, although that won't cause as much lag as the terrain deformation (which also leaks). Making multiple terrain deformation will always cause lag, you can reduce it by making your map smaller, but best suggestion: dont make many terrain deformations at the same time. |
| 05-23-2006, 12:30 AM | #5 |
Question: How do I clean up TerrainDeform leaks? I can't find a remove or destroy function for them.... Okay....what the hell was I thinking using 1 distance intervals. I ended up raising it to 1000 with 650 radius and lags much less. Furthermore, I ended up removing the BJ functions (which I just learned leak themselves ). I also removed all use of locations, replacing them with reals. The lag is now down to 10 seconds which I've hidden through a cinematic that says "Loading Terrain Generator..." - ![]() |
| 05-23-2006, 12:39 AM | #6 |
JASS:native TerrainDeformStop takes terraindeformation deformation, integer duration returns nothing |
| 05-23-2006, 12:52 AM | #7 |
But I I do that, will it not just undue everything the function is supposed to do? |
| 05-23-2006, 12:54 AM | #8 |
Well if you want to keep them then you have to keep the leaks. |
| 05-23-2006, 05:56 PM | #9 |
Your creating 2*2*2 times too much terrain deformations in those loops. Il create a optimized way for this. Il reply in 5 min |
| 05-23-2006, 06:10 PM | #10 |
Ok, im not sure if this is what you wanted, but its looks like it. I wasent completly sure what you wanted the function to be like. JASS:function updateTerrain takes location start, location end, integer terrainType, real amount returns nothing local real CurrentX = GetLocationX(start) local real CurrentY = GetLocationY(start) local real DestX = GetLocationX(end) local real DestY = GetLocationY(end) local location CurrentLoc = start loop exitwhen CurrentLoc == end if (GetTerrainTypeBJ(Location(CurrentX, CurrentY)) == terrainType) then call TerrainDeformationCraterBJ(3600, true, CurrentLoc, 0.50, amount ) endif set CurrentLoc = Location(GetLocationX(CurrentLoc) + 1. * Cos(AngleBetweenPoints(CurrentLoc, end) * bj_DEGTORAD), GetLocationY(CurrentLoc) + 1. * Sin(AngleBetweenPoints(CurrentLoc, end) * bj_DEGTORAD)) endloop call RemoveLocation(CurrentLoc) set CurrentLoc = null endfunction EDIT: Sorry for doubleposting, i dident notice =/ |
| 05-23-2006, 06:14 PM | #11 |
Well, now that I think about it, I don't think that Terrain Deformations really leak. If you look, there is a function that stops all Terrain Deformations. I might be wrong, but that means there must a handle pointing to those Terrain Deformations which means that technically, its not leaked. Because of that, I won't need to clean it up until 3600 seconds pass at which I call that function and then re-call this function. Either way, this is my "updated" code. Course, I bet the guy above me will think up something better. Edit: I guess He did. I'll test his and get back to yall. JASS:function updateTerrain takes real startX, real startY, real finalX, real finalY, integer terrainType, real amount returns nothing local real currentX = startX local real currentY = startY local real endX = finalX local real endY = finalY loop exitwhen currentX >= endX loop exitwhen currentY >= endY if (GetTerrainType(currentX, currentY) == terrainType) then call TerrainDeformCrater(currentX,currentY,375,amount,3600,true) endif set currentY = currentY + 750 endloop set currentY = startY set currentX = currentX + 750 endloop call DisplayTextToForce( GetPlayersAll(), "Exit: Terrain Height Map" ) endfunction |
| 05-23-2006, 06:21 PM | #12 |
Your code is ok, but the problem is, you want to create deformations going from 1 location too another, this is going nearly the oppsite. This is a example of 1 location too another: A = Startpoint B = Endpoint Code:
A######### #\######## ##\####### ###\###### ####\##### #####\#### ######\### #######\## ########\# #########B This is what 2 loops will do for you: A = Startpoint B = Endpoint Code:
A--------- #########| #########| #########| #########| #########| #########| #########| #########| #########B Your making all the y's then all the x's, not changing them both at the same time, so it will do them seperatly |
| 05-23-2006, 06:29 PM | #13 |
Just tested it and your idea looks fine but there seems to be a logical flaw (I think) in your incrementer because it is causing an infinite loop (or just taking a really long time to do without crashing or lagging) because the rest of my code in the same trigger will not execute once this runs. I will see what I find.... |
| 05-23-2006, 06:47 PM | #14 |
Hmm, odd. Lemme just scan over my code and see what code be causing this EDIT: i think i know why il edit it asap and give the new 1, all i was doing was not using CurrentX and CurrentY but using the Location() function, so all the old locations still exsisted, bad lag. Brb EDIT2: ok its finished, this destroys all locations. JASS:function updateTerrain takes location start, location end, integer terrainType, real amount returns nothing local real CurrentX = GetLocationX(start) local real CurrentY = GetLocationY(start) local real DestX = GetLocationX(end) local real DestY = GetLocationY(end) local location CurrentLoc loop exitwhen (CurrentX == DestX) and (CurrentY == DestY) set CurrentLoc = Location(CurrentX, CurrentY) if (GetTerrainTypeBJ(CurrentLoc) == terrainType) then call TerrainDeformationCraterBJ(3600, true, CurrentLoc, 0.50, amount ) endif call RemoveLocation(CurrentLoc) set CurrentX = GetLocationX(CurrentLoc) + 1. * Cos(AngleBetweenPoints(CurrentLoc, end) * bj_DEGTORAD) set CurrentY = GetLocationY(CurrentLoc) + 1. * Sin(AngleBetweenPoints(CurrentLoc, end) * bj_DEGTORAD) endloop call RemoveLocation(CurrentLoc) set CurrentLoc = null endfunction |
| 05-23-2006, 07:06 PM | #15 |
It still loops infinitly because if you add a game text message at the end for testing, you'll notice it never reaches it since the engine terminated it. |
