当前位置: 首页 > news >正文

物理引擎系统-ode

物理引擎系统-ode

目录

物理引擎系统-ode

一、物理引擎系统-ode——processIslands

二、物理引擎系统-ode——processIslands

三、物理引擎系统-ode——processIslands

四、物理引擎系统-ode——processIslands

五、物理引擎系统-ode——processIslands

一、物理引擎系统-ode——processIslands 

static void processIslands (dxWorld *world, dReal stepsize)
{
  dxBody *b,*bb,**body;
  dxJoint *j,**joint;

  // nothing to do if no bodies
  if (world->nb <= 0) return;

二、物理引擎系统-ode——processIslands 

  // make arrays for body and joint lists (for a single island) to go into
  body = (dxBody**) ALLOCA (world->nb * sizeof(dxBody*));
  joint = (dxJoint**) ALLOCA (world->nj * sizeof(dxJoint*));
  int bcount = 0;    // number of bodies in `body'
  int jcount = 0;    // number of joints in `joint'

三、物理引擎系统-ode——processIslands 

  // set all body/joint tags to 0
  for (b=world->firstbody; b; b=(dxBody*)b->next) b->tag = 0;
  for (j=world->firstjoint; j; j=(dxJoint*)j->next) j->tag = 0;

  // allocate a stack of unvisited bodies in the island. the maximum size of
  // the stack can be the lesser of the number of bodies or joints, because
  // new bodies are only ever added to the stack by going through untagged
  // joints. all the bodies in the stack must be tagged!
  int stackalloc = (world->nj < world->nb) ? world->nj : world->nb;
  dxBody **stack = (dxBody**) ALLOCA (stackalloc * sizeof(dxBody*));

四、物理引擎系统-ode——processIslands 

  for (bb=world->firstbody; bb; bb=(dxBody*)bb->next) {
    // get bb = the next enabled, untagged body, and tag it
    if (bb->tag || (bb->flags & dxBodyDisabled)) continue;
    bb->tag = 1;

// tag all bodies and joints starting from bb.
    int stacksize = 0;
    b = bb;
    body[0] = bb;
    bcount = 1;
    jcount = 0;
    goto quickstart;
    while (stacksize > 0) {
      b = stack[--stacksize];    // pop body off stack
      body[bcount++] = b;    // put body on body list
      quickstart:

五、物理引擎系统-ode——processIslands 

      // traverse and tag all body's joints, add untagged connected bodies
      // to stack
      for (dxJointNode *n=b->firstjoint; n; n=n->next) {
    if (!n->joint->tag) {
      n->joint->tag = 1;
      joint[jcount++] = n->joint;
      if (n->body && !n->body->tag) {
        n->body->tag = 1;
        stack[stacksize++] = n->body;
      }
    }
      }
      dIASSERT(stacksize <= world->nb);
      dIASSERT(stacksize <= world->nj);
    }

http://www.lryc.cn/news/45387.html

相关文章:

  • 函数设计—参数规则
  • rsync远程同步
  • 中国大陆IP段(仅大陆地区)【2020-07-24】
  • 从零开始的嵌入式Linux生活(一) 背景介绍
  • 后缀为whl的文件是什么?如何安装whl文件?学习一下(22)
  • 整合Juit
  • C#,码海拾贝(11)——拉格朗日(Lagrange)三点式曲面插值算法,《C#数值计算算法编程》源代码升级改进版
  • CentOS7系统安装MySQL 5.7
  • 基于粒子群算法优化BP神经网络的高炉si预测,PSO-BP
  • STM32输出PWM波控制电机转速,红外循迹避障智能车+L298N的详细使用手册、接线方法及工作原理,有代码
  • 3、AI的道德性测试
  • 银行数字化转型导师坚鹏:银行业务需求分析师技能快速提升之道
  • C++IO流
  • 交友项目【后端环境搭建】
  • 大事务问题解决方案
  • python开启局域网传输
  • 病毒丨熊猫烧香病毒分析
  • SparkSQL学习——SparkSQL配置与文件的读取与保存
  • 随想录Day45--动态规划:70. 爬楼梯 (进阶), 322. 零钱兑换, 279.完全平方数
  • 原理+案例,关于主从延迟,一篇文章给你讲明白!
  • QT开发笔记(Camera)
  • 从C++的角度讲解C#容器
  • React组件库实践:React + Typescript + Less + Rollup + Storybook
  • c++ atomic
  • 要想孩子写作文没烦恼?建议家长这样做
  • 基于Python的高光谱图像分析教程
  • 【图神经网络】从0到1使用PyG手把手创建异构图
  • 2023美赛春季赛思路分析汇总
  • GPT4国内镜像站
  • 代码随想录算法训练营第四十八天| 198 打家劫舍 213 打家劫舍II 337 打家劫舍III