| 1544 | } |
| 1545 | |
| 1546 | void DrawShapes() |
| 1547 | { |
| 1548 | for (int i = 0; i < g_buffers->shapeFlags.size(); ++i) |
| 1549 | { |
| 1550 | const int flags = g_buffers->shapeFlags[i]; |
| 1551 | |
| 1552 | // unpack flags |
| 1553 | int type = int(flags&eNvFlexShapeFlagTypeMask); |
| 1554 | //bool dynamic = int(flags&eNvFlexShapeFlagDynamic) > 0; |
| 1555 | |
| 1556 | Vec3 color = Vec3(0.9f); |
| 1557 | |
| 1558 | if (flags & eNvFlexShapeFlagTrigger) |
| 1559 | { |
| 1560 | color = Vec3(0.6f, 1.0, 0.6f); |
| 1561 | |
| 1562 | SetFillMode(true); |
| 1563 | } |
| 1564 | |
| 1565 | // render with prev positions to match particle update order |
| 1566 | // can also think of this as current/next |
| 1567 | const Quat rotation = g_buffers->shapePrevRotations[i]; |
| 1568 | const Vec3 position = Vec3(g_buffers->shapePrevPositions[i]); |
| 1569 | |
| 1570 | NvFlexCollisionGeometry geo = g_buffers->shapeGeometry[i]; |
| 1571 | |
| 1572 | if (type == eNvFlexShapeSphere) |
| 1573 | { |
| 1574 | Mesh* sphere = CreateSphere(20, 20, geo.sphere.radius); |
| 1575 | |
| 1576 | Matrix44 xform = TranslationMatrix(Point3(position))*RotationMatrix(Quat(rotation)); |
| 1577 | sphere->Transform(xform); |
| 1578 | |
| 1579 | DrawMesh(sphere, Vec3(color)); |
| 1580 | |
| 1581 | delete sphere; |
| 1582 | } |
| 1583 | else if (type == eNvFlexShapeCapsule) |
| 1584 | { |
| 1585 | Mesh* capsule = CreateCapsule(10, 20, geo.capsule.radius, geo.capsule.halfHeight); |
| 1586 | |
| 1587 | // transform to world space |
| 1588 | Matrix44 xform = TranslationMatrix(Point3(position))*RotationMatrix(Quat(rotation))*RotationMatrix(DegToRad(-90.0f), Vec3(0.0f, 0.0f, 1.0f)); |
| 1589 | capsule->Transform(xform); |
| 1590 | |
| 1591 | DrawMesh(capsule, Vec3(color)); |
| 1592 | |
| 1593 | delete capsule; |
| 1594 | } |
| 1595 | else if (type == eNvFlexShapeBox) |
| 1596 | { |
| 1597 | Mesh* box = CreateCubeMesh(); |
| 1598 | |
| 1599 | Matrix44 xform = TranslationMatrix(Point3(position))*RotationMatrix(Quat(rotation))*ScaleMatrix(Vec3(geo.box.halfExtents)*2.0f); |
| 1600 | box->Transform(xform); |
| 1601 | |
| 1602 | DrawMesh(box, Vec3(color)); |
| 1603 | delete box; |
no test coverage detected