Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletMultiThreaded/SequentialThreadSupport.cpp @ 1963

Last change on this file since 1963 was 1963, checked in by rgrieder, 16 years ago

Added Bullet physics engine.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#include "SequentialThreadSupport.h"
17
18
19#include "SpuCollisionTaskProcess.h"
20#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
21
22SequentialThreadSupport::SequentialThreadSupport(SequentialThreadConstructionInfo& threadConstructionInfo)
23{
24        startThreads(threadConstructionInfo);
25}
26
27///cleanup/shutdown Libspe2
28SequentialThreadSupport::~SequentialThreadSupport()
29{
30        stopSPU();
31}
32
33#include <stdio.h>
34
35///send messages to SPUs
36void SequentialThreadSupport::sendRequest(uint32_t uiCommand, uint32_t uiArgument0, uint32_t taskId)
37{
38        switch (uiCommand)
39        {
40        case    CMD_GATHER_AND_PROCESS_PAIRLIST:
41                {
42                        btSpuStatus&    spuStatus = m_activeSpuStatus[0];
43                        spuStatus.m_userPtr=(void*)uiArgument0;
44                        spuStatus.m_userThreadFunc(spuStatus.m_userPtr,spuStatus.m_lsMemory);
45                }
46        break;
47        default:
48                {
49                        ///not implemented
50                        btAssert(0 && "Not implemented");
51                }
52
53        };
54
55
56}
57
58///check for messages from SPUs
59void SequentialThreadSupport::waitForResponse(unsigned int *puiArgument0, unsigned int *puiArgument1)
60{
61        btAssert(m_activeSpuStatus.size());
62        btSpuStatus& spuStatus = m_activeSpuStatus[0];
63        *puiArgument0 = spuStatus.m_taskId;
64        *puiArgument1 = spuStatus.m_status;
65}
66
67void SequentialThreadSupport::startThreads(SequentialThreadConstructionInfo& threadConstructionInfo)
68{
69        m_activeSpuStatus.resize(1);
70        printf("STS: Not starting any threads\n");
71        btSpuStatus& spuStatus = m_activeSpuStatus[0];
72        spuStatus.m_userPtr = 0;
73        spuStatus.m_taskId = 0;
74        spuStatus.m_commandId = 0;
75        spuStatus.m_status = 0;
76        spuStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc();
77        spuStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc;
78        printf("STS: Created local store at %p for task %s\n", spuStatus.m_lsMemory, threadConstructionInfo.m_uniqueName);
79}
80
81void SequentialThreadSupport::startSPU()
82{
83}
84
85void SequentialThreadSupport::stopSPU()
86{
87        m_activeSpuStatus.clear();
88}
89
90void SequentialThreadSupport::setNumTasks(int numTasks)
91{
92        printf("SequentialThreadSupport::setNumTasks(%d) is not implemented and has no effect\n",numTasks);
93}
Note: See TracBrowser for help on using the repository browser.