Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Say I have a group of large meshes that I have to intersect rays against. Assume also, for whatever reason, I cannot further simplify/reduce poly check count by spatial subdivisioning. I can do this in parallel:

bool intersects( list of meshes ) // a mesh is a group of triangles
{
    create n threads

    foreach mesh in meshes 
        assign to a thread in threads

    wait until ( threads.run() ) ; // run asynchronously

    // when they're all done
    // pull out intersected triangles
    // from per-thread context data
}

Can you do this in ios for games? Or is the overhead of thread creation and mutex waiting going to beat-out the benefit of multithreading?

share|improve this question
add comment

2 Answers

If your array is a NSArray, use method like -enumerateObjectsUsingBlock:. This method will use GCD and will dispatch enumeration to different cores, according to number of CPU cores and the array size.

share|improve this answer
add comment

iPhone has 2 cores. Your code looks more like you have 8 or 16 cores. If you have 2 cores then you may split app in animation and physics threads. Physics thread would be connected with animation thread with 2 channels (pipes)

Everyframe animation will write commands/messages to pipe and read messages Message may contain anything.

Object A Position Time Velocity

So if phsyics do not give update for object A then animation thread will be able to interpolate position for every frame knowing it original position at a time, ceocity and current time.

With that system you can outsource any tasks to second thread.

But high frame rate is most important. It is more important then long time waiting.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.