//////////////////////////////////////////////////////////////////////////
| 1793 | |
| 1794 | /////////////////////////////////////////////////////////////////////////////// |
| 1795 | void NpScene::simulateOrCollide(PxReal elapsedTime, physx::PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation, const char* invalidCallMsg, Sc::SimulationStage::Enum simStage) |
| 1796 | { |
| 1797 | PX_SIMD_GUARD; |
| 1798 | |
| 1799 | { |
| 1800 | // write guard must end before simulation kicks off worker threads |
| 1801 | // otherwise the simulation callbacks could overlap with this function |
| 1802 | // and perform API reads,triggering an error |
| 1803 | NP_WRITE_CHECK(this); |
| 1804 | |
| 1805 | PX_PROFILE_START_CROSSTHREAD("Basic.simulate", getContextId()); |
| 1806 | |
| 1807 | if(getSimulationStage() != Sc::SimulationStage::eCOMPLETE) |
| 1808 | { |
| 1809 | //fetchResult doesn't get called |
| 1810 | Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, invalidCallMsg); |
| 1811 | return; |
| 1812 | } |
| 1813 | |
| 1814 | PX_CHECK_AND_RETURN(elapsedTime > 0, "PxScene::collide/simulate: The elapsed time must be positive!"); |
| 1815 | |
| 1816 | PX_CHECK_AND_RETURN((reinterpret_cast<size_t>(scratchBlock)&15) == 0, "PxScene::simulate: scratch block must be 16-byte aligned!"); |
| 1817 | |
| 1818 | PX_CHECK_AND_RETURN((scratchBlockSize&16383) == 0, "PxScene::simulate: scratch block size must be a multiple of 16K"); |
| 1819 | |
| 1820 | #if PX_SUPPORT_PVD |
| 1821 | //signal the frame is starting. |
| 1822 | mScene.getScenePvdClient().frameStart(elapsedTime); |
| 1823 | #endif |
| 1824 | |
| 1825 | #if PX_ENABLE_DEBUG_VISUALIZATION |
| 1826 | visualize(); |
| 1827 | #endif |
| 1828 | |
| 1829 | updateDirtyShaders(); |
| 1830 | |
| 1831 | #if PX_SUPPORT_PVD |
| 1832 | mScene.getScenePvdClient().updateJoints(); |
| 1833 | #endif |
| 1834 | |
| 1835 | mScene.getScScene().setScratchBlock(scratchBlock, scratchBlockSize); |
| 1836 | |
| 1837 | mElapsedTime = elapsedTime; |
| 1838 | if (simStage == Sc::SimulationStage::eCOLLIDE) |
| 1839 | mScene.getScScene().setElapsedTime(elapsedTime); |
| 1840 | |
| 1841 | mControllingSimulation = controlSimulation; |
| 1842 | |
| 1843 | //sync all the material events |
| 1844 | NpPhysics& physics = static_cast<NpPhysics&>(this->getPhysics()); |
| 1845 | NpMaterialManager& manager = physics.getMaterialManager(); |
| 1846 | NpMaterial** materials = manager.getMaterials(); |
| 1847 | mScene.updateLowLevelMaterial(materials); |
| 1848 | |
| 1849 | setSimulationStage(simStage); |
| 1850 | mScene.setPhysicsBuffering(true); |
| 1851 | mHasSimulatedOnce = true; |
| 1852 | } |
nothing calls this directly
no test coverage detected