zoukankan      html  css  js  c++  java
  • Bullet 学习笔记之 Soft Body Physics Pipeline

    在最近几个新的版本中,Bullet 物理引擎逐步加入并完善了软体形变的仿真。btSoftBody 类用于软体的模拟,仿真场景则通过 btSoftRigidDynamicsWorld 搭建。下面简单介绍一下 Soft Body Physics Pipeline 。


    0、Overview

    软体仿真的场景类 btSoftRigidDynamicsWorld 继承自 btDiscreteDynamicsWorld ,主要添加了存放软体对象的数组 m_softBodies 、软体对像的求解器 m_softBodySolver 类,并重载了函数 predictUnconstraintMotioninternalSingleStepSimulation ,添加了成员函数 solveSoftBodiesConstraintsrayTestrayTestSingle 等。

    在初始化阶段,新建了软体对象的求解器为 m_softBodySolver = new btDefaultSoftBodySolver() 。当向场景中添加刚体时,调用的是 btDiscreteDynamicsWorld::addRigidBody() ,向场景中添加软体时,一方面,向 btDiscreteDynamicsWorld 添加碰撞对象,同时将该软体添加到 btSoftRigidDyanmicsWrold.m_softBodies 中。

    在仿真步骤的执行阶段,仍然是通过 btDiscreteDynamicsWorld::stepSimulation() 函数完成。只是,这里面的一些补充,重新改写了。


    1、仿真流程及函数分解

    仿真步骤总体上仍包含在 btDiscreteDynamicsWorld::stepSimulation() 函数中,其中的部分细分函数相较于刚体仿真 场景有所变化。下面分层次列出 stepSimulation() 中的内容:

    [1] btDiscreteDynamicsWorld::saveKinematicState(..);

    [2] btDiscreteDynamicsWorld::applyGravity();

    [3] btSoftRigidDynamicsWorld::internalSingleStepSimulation(); *

       [3.1] m_softBodySolver->optimize(getSoftBodyArray()); *

       [3.2] btDiscreteDynamicsWorld::internalSingleStepSimulation(timeStep);

         [3.2.1] btSoftRigidDynamicsWorld::predictUnconstraintMotion(..); *

            [3.2.1.1] btDiscreteDynamicsWorld::predictUnconstraintMotion(timeStep);

            [3.2.1.2] m_softBodySolver->predictMotion(float(timeStep)); *

         [3.2.2] btDiscreteDynamicsWorld::createPredictiveContacts(timeStep);

         [3.2.3] btCollisionWorld::performDiscreteCollisionDetection();

         [3.2.4] btDiscreteDynamicsWorld::calculateSimulationIslands();

         [3.2.5] btDiscreteDynamicsWorld::solveConstraints(getSolverInfo());

         [3.2.6] btDiscreteDynamicsWorld::integrateTransforms(timeStep);

         [3.2.7] btDiscreteDynamicsWorld::updateActions(timeStep);

         [3.2.8] btDiscreteDynamicsWorld::updateActivationState(timeStep);

       [3.3] btSoftRigidDynamicsWorld::solveSoftBodiesConstraints(timeStep); *

       [3.4] 遍历 btSoftRigidDynamicsWorld.m_softBodies ,执行 psb->defaultCollisionHandler(psb); *

       [3.5] m_softBodySolver->updateSoftBodies(); *

    [4] btDiscreteDynamicsWorld::synchronizeMotionStates();

    [5] btDiscreteDynamicsWorld::clearForces();

    以上便是软体场景的仿真步骤及框架。

    总体上来说,涉及软体的部分有:(1)预测软体位移 predict motion;(2)求解软体约束 solve softbodies constraints;(3)求解软体的碰撞(好像是碰撞处理,而不是求解) soft body collision handle;(4)更新软体的最终状态 update soft body。

    此外,在软体-刚体 、软体-软体 的碰撞检测阶段,内部函数好像还附带了碰撞求解。


    2、软体形变仿真相关的类 btSoftBodybtSoftBodySolver

    在软体形变仿真场景中,新加入的类主要是 btSoftBodybtSoftBodySolver

    具体内容参见:

    Bullet 学习笔记之 btSoftBody

    Bullet 学习笔记之 btSoftBodySolver


    3、SoftBody->predictMotion

    在软体形变仿真中,首先涉及到的是无约束状态下的形变计算,即 m_softBodySolver->predictMotion(float(timeStep));

  • 相关阅读:
    linux 查找最后几条数据
    O(n) 取得数组中每个元素右边最后一个比它大的元素
    O(n) 取得数组中每个元素右边第一个比它大的元素
    位运算实现整数运算
    随手练——P1141 01迷宫
    迷宫寻路问题全解
    N皇后问题 各种优化
    八数码问题(三种解决办法)
    随手练——Uva-11584 划分成回文串(区间DP)
    【2016蓝桥杯省赛】试题C++ B组试题
  • 原文地址:https://www.cnblogs.com/wghou09/p/12826275.html
Copyright © 2011-2022 走看看