getCollision extreemely slow... Whats wrong?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Suliman

getCollision extreemely slow... Whats wrong?

Post by Suliman »

Hi guys

Im doing a collisionCheck with my terrainNode so I can know where on my RTS-map mouseclicks hits.

I try this and it works but:
Is it reasonable that my program freezes for 6 to 12 entire seconds first time I run the code


code:
--------------------------------------------------------------------------------

raytrace = colManager->getRayFromScreenCoordinates(m, mainCamera);
colManager->getCollisionPoint(raytrace, selector, target, triangle);

--------------------------------------------------------------------------------




It seemes strange, that is ten times as long as my map takes to build... After the first run of this code, it runs smoothly, but the first time it is as I said extremely slow...

Well thanks
Suliman
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Out of curiosity, for that first call that is so slow, what is the value of the line? Start and end?
Image
Omberon

Post by Omberon »

You probably need to set all of your variables to zero.
Suliman

Post by Suliman »

What variebles should be set to zero? How could that help?

Spintz it might be only the second line that eat my time, i'm not at that computer now :) Besides that I dont know what "value of a line" means...

Im not an advanced user, I just posted here since the code that got me this far was from this forum.

Suliman, Your thrusty trader in Lime
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

THe line has 2 vectors, a start and end. What are the X, Y and Z values of the start and end?
Image
Suliman

Post by Suliman »

Hmm I dont have that but it was resonable figures i think, like

start 2200,800,1000
end maybe 1000,-200,2000 (one was negative im sure)

target and triangle had all variebles 0

Would that really matter? I dont see how, and why that only matters the first time... I can get exact figures from my home-computer if it might solve the problem...

Thanks
suliman

Post by suliman »

noone? This is really a problem for me...

1. Do you have the same problem? I dont understand how this can be the general method if its so slow...
2. Any tips to get me past this problem?
3. Any alternative ways to do it faster?

Thankful for anything that might lead me in a constructive direction
Suliman
Talaxy

I may be wrong

Post by Talaxy »

I may be completly wrong and i proberbly am, but i think the first time its done requires quite and amount of movent of data into the function, perhaps if during the loading phase u some how simulate the first use of the function, i kno this will make the load time longer so it may be a crap idea lol sorry
SuperElectric
Posts: 19
Joined: Fri May 13, 2005 7:20 am
Location: New York, NY

Post by SuperElectric »

Are you sure that it's those two lines you posted that cause the 6 second pause? I know that for me, my program pauses for a good 18 seconds when building the OcttreeTriangleSelector. For debugging purposes, I just use a regular triangle selector instead, which loads pretty much instantly (but gives a lower FPS while the program is running).

-- Matt
Post Reply