Skip to Main Content
Intel Threading Building Blocks
book

Intel Threading Building Blocks

by James Reinders
July 2007
Intermediate to advanced content levelIntermediate to advanced
332 pages
10h 4m
English
O'Reilly Media, Inc.
Content preview from Intel Threading Building Blocks

Physics Interaction and Update Code

The source code for the physics interaction (Example 11-54 and Example 11-55) and update (Example 11-56) are presented here for you to study. You can download the complete source code from http://www.threadingbuildingblocks.org/book. Look for errata and notes at this web site as well.

For more in-depth reading on this topic, Intel engineers wrote several articles covering the topic of threading games, which you can download at the web site as well.

Example 11-54. Physics interaction code: InteractTask

class InteractTask : public tbb::task { SceneNode* m_node; size_t m_i; D3DBlackHole* m_bh; float m_universeRadius; size_t m_DummyCount; public: // Interact all stars in task InteractTask(SceneNode* node, size_t i, D3DBlackHole* bh, float universeRadius, size_t DummyCount) : m_node(node), m_i(i), m_bh(bh), m_universeRadius(universeRadius), m_DummyCount(DummyCount) {} tbb::task* execute() { if (m_node->getChildCount()) { // High in scene graph, Create parallel domain tasks for the children size_t i; tbb::task_list list; tbb::task& c = *new(allocate_continuation()) tbb::empty_task(); for (i = 0; i < m_node->getChildCount(); ++i) { list.push_back(*new(c.allocate_child()) InteractTask(m_node->getChild(i), i, m_bh, m_universeRadius, m_DummyCount)); } c.set_ref_count((int)i); c.spawn(list); } if (m_node->getUserID() > 0) { // Low-level object tasks, interact each star serially D3DStar* pStar = (D3DStar*)m_node; float elapsedTime = g_elapsedTime - pStar->getTimeStamp(); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Rezaur Rahman

Publisher Resources

ISBN: 9780596514808Errata Page