TVProjects top



TVProjects bottom
You are not registered.
Registration allows you to subscribe to projects, open projects, and more. Click here to register.

Hidden Space (Open Source)
NewsDownloadsMediaRoadmapBugtracker

 
Threads, Threads, Threads ...
11/04/08 07:15:46  Hidden Space (Open Source)

Hidden Space (Open Source)
Hidden Space (Open Source)

I've read several posts on the forums about Threading with TV3D and i though i try that. It's really something. I've created another thread to handle collisions avoidance and it worked like a charm, with brute force mathematical collision check (no optimizations) between 1000 objects (1.000.000 calculations) and it takes ~1sec at a 2Ghz Core 2 Duo. A brief test though, showed that position calculations inside a thread result in jittering motion, so i've removed all the position calculations from the threads and placed them inside the rendering loop which so far seems to have solved the problem. Also, after a lot of experimentation, i've figured out a way to syncronize the threads with each other and with the main loop (no mutex, no dlegates). The animation now should be exactly the same regardless of the machine. The scheme i'm gonna go for (for now) is ..... 3 threads and 1 main loop.

MAIN LOOP: Updates the position of all objects on scene using the latest velocity vectors from thread #3.

THREAD#1: Performs collision avoidance checks for all objects using the latest positions from the main loop and some other data.

THREAD#2: Performs best route navigation using the latest collision data from thread #1.

THREAD#3: Creates the velocity vectors by simulating the pilot skill and ship response, using the latest navigation data from thread #2.

 See you all later ...

 
 
Comments:
 
Hypnotron 11/04/08 13:42:36
what are you using to determine collisions? simple boundingsphere -> boundingsphere tests?
 
leahcim sonam 17/04/08 06:51:09
Sorry for the late response, no time ...

Collision check is done progressively.

1. Determine distance between objects.

2. If distance between objects > (Distance both objects can cover in full speed) - (BSphere1 + BSphere2) THEN no hit is possible at the next thread loop, so ignore the rest steps BUT re-check after the required time to close that distance has passed.

3. If bounding spheres don't collide, calculate time to collide bounding spheres (with full speed) and re-check after that time is elapsed. Ignore the next steps.

4. Normally, object navigation should avoid coming that close. If bounding spheres collide, then collision is imminent. Perform accurate ray collision with object, calculate distance to collision point & normal vector of the poly it's hitting. Use these information to plot an escape vector, away from the object.

Some points to clarify ....

a. Large models are sectionized to occupy a sphere (give or take). Of course, cavings in individual sections pose problems but i'm working it out.

b. Step 4 collision checks are performed for each object ONCE, when bounding spheres are crossed. The purpose is to define an escape vector for the object, which it follows to avoid collision.
 
You have to be registered to post comments.