AGX Dynamics  2.35.0.1
GroupFooCollider.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXCOLLIDE_GROUP_FOO_COLLIDER_H
18 #define AGXCOLLIDE_GROUP_FOO_COLLIDER_H
19 
23 
24 namespace agxCollide
25 {
26  template <agx::UInt8 ShapeType>
27  class GroupFooCollider : public ShapeCollider
28  {
29  public:
30  GroupFooCollider() : ShapeCollider(agxCollide::Shape::GROUP, ShapeType) {}
31  virtual ~GroupFooCollider() {}
32 
33  virtual void _calculateContacts(
34  agx::Physics::Geometry::ShapeInstance shape1, agx::Physics::Geometry::ShapeInstance shape2,
35  const agx::AffineMatrix4x4&, const agx::AffineMatrix4x4& transform2,
37  const agx::Vec3& linearVelocity1, const agx::Vec3& linearVelocity2,
38 #else
39  const agx::Vec3& /*linearVelocity1*/, const agx::Vec3& linearVelocity2,
40 #endif
41  const agx::Vec3& angularVelocity1, const agx::Vec3& angularVelocity2,
42  bool /*earlyOut*/, LocalContactPointVector& result) override
43  {
44  agx::Physics::Geometry::ShapeGroupInstance group = shape1;
45 
46 
47  const agx::Vector<agx::Physics::Geometry::ShapePtr>& childShapes = group.childShapes();
48  // const agx::Vector<AffineMatrix4x4>& childTransforms = group.childTransforms();
49  for (size_t i = 0; i < childShapes.size(); ++i)
50  {
51  agx::Physics::Geometry::ShapeInstance childShape = childShapes[i];
52 
53  ShapeCollider *collider = ColliderTable::getCollider(childShape.type(), shape2.type());
54 
55  // AffineMatrix4x4& localTransform = childTransforms[i];
56  // AffineMatrix4x4 childTransform = localTransform * transform1;
57 
58  #if SHAPE_COLLIDER_VELOCITIES
59  agx::Vec3 childLinearVelocity = (angularVelocity1 ^ localTransform.getTranslate()) + linearVelocity1;
60  #else
61  agx::Vec3 childLinearVelocity;
62  #endif
63 
64  if ( !collider )
65  continue;
66 
67  collider->calculateContacts(
68  childShape, shape2,
69  childShape.transform(), transform2,
70  childLinearVelocity, linearVelocity2,
71  angularVelocity1, angularVelocity2,
72  false, result);
73  }
74  }
75  };
76 }
77 
78 #endif
#define SHAPE_COLLIDER_VELOCITIES
static ShapeCollider * getCollider(const Shape *a, const Shape *b)
Get a shape collider for testing two shapes against each other.
Definition: ColliderTable.h:76
virtual void _calculateContacts(agx::Physics::Geometry::ShapeInstance shape1, agx::Physics::Geometry::ShapeInstance shape2, const agx::AffineMatrix4x4 &, const agx::AffineMatrix4x4 &transform2, const agx::Vec3 &, const agx::Vec3 &linearVelocity2, const agx::Vec3 &angularVelocity1, const agx::Vec3 &angularVelocity2, bool, LocalContactPointVector &result) override
Base class for a shape.
Definition: Shape.h:54
size_t size() const
Definition: Container.h:134
Templated vector class.
Definition: agx/Vector.h:53
This namespace consists of a set of classes for handling geometric intersection tests including boole...