AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
WireOldContactController.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
21
23#include <agxSDK/Simulation.h>
24
26#include <agxCollide/Line.h>
27
30
32
33
34namespace agxSDK
35{
36 class WireContactEdge;
37 class WireContactPosition;
38}
39
40namespace agxCollide
41{
42 class Box;
43 class Cylinder;
44 class Sphere;
45}
46
47namespace agxWire
48{
49 class Wire;
50 class WireGeometryController;
51 class WireContactController;
52 // Typedefs
53 typedef agx::Vector< std::pair< NodeRef, std::pair< NodePtrIterator, agx::Real > > > NodeRefNodePtrListIterRealVector;
54 typedef agx::Vector<agxSDK::LineContactEdge> WireContactEdgeVector;
55
56 class AGXPHYSICS_EXPORT WireSensorController : public agx::Referenced
57 {
58 public:
59 WireSensorController(WireGeometryController* geometryController, WireContactController* contactController);
60
64 void addNotification();
65
69 void removeNotification();
70
74 bool handleSensorContact(agxCollide::GeometryContact *gc);
75
80 void setSensorPosition(agxWire::ContactNode* cln);
81
85 agxWire::WireGeometryController* getGeometryController() const { return m_geometryController; }
86
90 agxWire::WireContactController* getActiveContactController() const { return m_contactController; }
91
95 bool match(agx::Physics::GeometryPtr geometry) const;
96
97 protected:
98 virtual ~WireSensorController() {}
99
100 private:
103 agx::UInt32 m_wireId;
104 };
105
106 typedef agx::ref_ptr< WireSensorController > WireSensorControllerRef;
107
108 class WireContactGeometryTransferController
109 {
110 public:
111 WireContactGeometryTransferController(WireContactController *contactController);
112 ~WireContactGeometryTransferController() {}
113
114 //int handleBox(ContactNode* cln, agxCollide::Geometry* sensor, agxCollide::Geometry* oldGeometry, agxCollide::Geometry* newBoxGeometry);
115 //int handleCylinder(ContactNode* cln, agxCollide::Geometry* sensor, agxCollide::Geometry* oldGeometry, agxCollide::Geometry* newCylinderGeometry);
116 agx::Real getGeometryPenetrationDepth(agxCollide::Geometry* geometry, const agx::Vec3& contactPoint, const agx::Vec3& edge);
117 WireContactController* getActiveContactController() { return m_contactController; }
118
119 private:
120 bool getWithinGeometryMovementRange(agxCollide::Geometry* geometry, const agx::Vec3& contactPoint, agxSDK::LineContactEdge* edge);
121 bool getWithinBoxMovementRange(agxCollide::Box* boxShape, const agx::Vec3& contactPoint, agxSDK::LineContactEdge* edge);
122 bool getWithinCylinderMovementRange(agxCollide::Cylinder* cylinderShape, const agx::Vec3& contactPoint, agxSDK::LineContactEdge* edge);
123
124 agx::Real getBoxPenetrationDepth(agxCollide::Box* box, const agx::Vec3& contactPoint, agx::Vec3 edge);
125 agx::Real getCylinderPenetrationDepth(agxCollide::Cylinder* cylinder, agx::Vec3 contactPoint, agx::Vec3 edge);
126
128 };
129
130 class ContactNodePlacementData
131 {
132 public:
133 ContactNodePlacementData() : movingFromStartToEnd(false), openAngle(false), wireRadius(0), shortOffsetLength(0), triangleIndex(0), edgeIndex(0) {}
134 agx::Vec3 contactPointInsideGeometry;
135 agx::Vec3 contactPointOnSurface;
136 agx::Vec3 newWP;
137 agx::Vec3 edgeStartRelativeMovementWorld;
138 agx::Vec3 offsetW;
139 agx::Vec3 moveDir;
140 bool movingFromStartToEnd;
141 bool openAngle;
142 agx::Real wireRadius;
143 agx::Real shortOffsetLength;
144 size_t triangleIndex;
145 size_t edgeIndex;
146
147 ~ContactNodePlacementData() {}
148 };
149
150 class WireRay// : public agx::Referenced
151 {
152 public:
153 WireRay() {}
154 WireRay(agx::Vec3 begin, agx::Vec3 end) : m_begin(begin), m_end(end) {}
155 AGX_FORCE_INLINE agx::Vec3 getBegin() const { return m_begin; }
156 AGX_FORCE_INLINE agx::Vec3 getEnd() const { return m_end; }
157 AGX_FORCE_INLINE agx::Vec3 getDir() const { return m_end - m_begin; }
158 private:
159 agx::Vec3 m_begin;
160 agx::Vec3 m_end;
161 };
162 //typedef agx::ref_ptr<WireRay> WireRayRef;
163
164 class AGXPHYSICS_EXPORT WireOldContactController : public agxWire::WireContactController
165 {
166 public:
167 WireOldContactController(Wire* wire);
168
169 static BodyFixedNode* changeToBodyFixed(ContactNode* contactNode, WireDistanceCompositeConstraint* wdcc);
170
174 virtual void preCollideUpdate();
175 virtual void preUpdate();
176 virtual void postUpdate();
177
178 virtual agx::Bool handleGeometryContact(agxCollide::GeometryContact* geometryContact, agxCollide::Geometry* otherGeometry);
179
180 WireContactGeometryTransferController* getContactGeometryTransferController() { return m_contactGeometryTransferController; }
181
185 bool almostPerpendicularCylinders(agxCollide::Geometry* cyl1, agxCollide::Geometry* cyl2);
186
187 bool getIfStuckNode(Node* cln) { return m_stuckNodes.contains(cln); }
188 bool getIfStuckNode(const Node* cln) const { return m_stuckNodes.contains(const_cast<Node*>(cln)); }
189 bool getIfStuckWhereNextGeometryIsAvailable(Node* cln);
190 int getClampDirection(ContactNode* cln, agxCollide::Geometry* collidingGeometry, const agx::Vec3& axis, const agx::Vec3& sensorPos, agx::Vec3& moveDirection, agxCollide::Geometry* sensor = nullptr, agxCollide::GeometryContact *gc = nullptr);
191
195 agx::Vec3 calculateShapeEdgeOffset(ContactNode* cln, agxCollide::Shape* shape, agx::Real wireRadius) const;
196
197 bool removeContact(WireDistanceCompositeConstraint* ldcc, ContactNode* cln);
198 WireSensorController* getSensorController() const { return m_sensorController; }
199
200 protected:
201 friend class WireContactGeometryTransferController;
202 friend class WireSensorController;
203 friend class WireImpactController;
204 virtual ~WireOldContactController();
205
206
207 protected:
211 class ContactNodeCustomData : public agx::Referenced
212 {
213 public:
214 ContactNodeCustomData(bool passedEdgePassTest = false) : m_passedEdgePassTest(passedEdgePassTest) {}
215 ContactNodeCustomData(const agx::Vec3& worldDirTowardSurface, const agx::Vec3& orgShapeEdgeStart, const agx::Vec3& orgShapeEdgeEnd)
216 : m_passedEdgePassTest(false), m_dirTowardSurface(worldDirTowardSurface), m_orgShapeEdgeStart(orgShapeEdgeStart),
217 m_orgShapeEdgeEnd(orgShapeEdgeEnd) {}
218
219 bool m_passedEdgePassTest;
220 agx::Vec3 m_dirTowardSurface;
221 agx::Vec3 m_orgShapeEdgeStart;
222 agx::Vec3 m_orgShapeEdgeEnd;
223 protected:
224 virtual ~ContactNodeCustomData() {}
225 };
226
227 typedef agx::ref_ptr< ContactNodeCustomData > ContactNodeCustomDataRef;
228 typedef agx::Vector< ContactNodeCustomDataRef > ContactNodeCustomDataRefVector;
229
230 private:
231 class EdgeTransferController
232 {
233 public:
234 EdgeTransferController(WireOldContactController* contactController);
235 ~EdgeTransferController() {}
239 agx::Real transferToNextEdge(ContactNode* cln, agx::Real tPos);
240
241
242 private:
243
247 bool handleBoxEdgeTransfer(ContactNode* cln, agx::Real& tPos, agxSDK::LineContactEdge* oldEdge);
251 bool getNeighboringBoxEdges(ContactNode* cln, agx::Real tPos, WireContactEdgeVector& edges);
255 void chooseCorrectBoxEdge(ContactNode* cln, agx::Real& tPos, WireContactEdgeVector& edges);
256
257
261 bool handleCylinderEdgeTransfer(ContactNode* cln, agx::Real& tPos, agxSDK::LineContactEdge* oldEdge);
262
266 bool getNeighbourAlsoCircleFallOff(ContactNode* cln, Node* otherNode, WireContactEdgeVector& edges);
267
271 bool getNeighboringCylinderEdges(ContactNode* cln, agx::Real tPos, WireContactEdgeVector& edges, bool onCircle);
275 void chooseCorrectCylinderEdge(ContactNode* cln, agx::Real& tPos, WireContactEdgeVector& edges, bool onCircle);
276
280 bool handleMeshEdgeTransfer(ContactNode* cln, agx::Real& tPos, agxSDK::LineContactEdge* oldEdge);
281
282
284 };
285
290 static void flipContactNormals(agxCollide::GeometryContact* geometryContact, agxCollide::Geometry* otherGeometry);
291
292 agx::Real calculateMassForContact(WireDistanceCompositeConstraint* wdcc, Node* cln);
293
294 bool validateDistanceBetweenWires(const agx::Vec3& eStartNewWorld, const agx::Vec3& eEndNewWorld, const agx::Vec3& eStartOldWorld, const agx::Vec3& eEndOldWorld, agx::Real sensorRadius);
295
296 void getAllContactNodeTypes(WireDistanceCompositeConstraint* ldcc, NodePtrContainer& allMeshContacts, NodePtrContainer& allBoxContacts, NodePtrContainer& allCylinderContacts);
297 void getAllContactNodes(WireDistanceCompositeConstraint* ldcc, agx::List<NodeIterator>& allContacts);
298 void getMovableContactNodes(const agx::List<NodeIterator>& allContacts, agx::List<NodeIterator>& contacts, agx::List<NodeIterator>& noMovementContacts);
299 bool analyzeIfBoxContactIsLoose(agx::Vec3 edgeStart, agx::Vec3 edgeEnd, agx::Vec3 cnPoint, agx::Vec3 prevPoint, agx::Vec3 nextPoint);
300 bool nodeFallsOffCylinderWithoutCircleEdges(const ContactNode* cln);
301 bool areContactsOnNeighboringEdges(ContactNode* cln1, ContactNode* cln2);
302 bool checkIfPulledOffAlongEdge(ContactNode* cln, const agx::Vec3 vPrev, const agx::Vec3 vNext);
303 int validateContact(ContactNode* cln);
304 bool surroundingNodeInsideGeometry(const agx::Vec3& prev, const ContactNode* cln, const agx::Vec3& next, agxCollide::Geometry* geometry);
305 bool surroundingNodeInsideBox(const agx::Vec3& prev, const ContactNode* cln, const agx::Vec3& next, agxCollide::Box* box);
306 bool surroundingNodeInsideCylinder(agx::Vec3 prev, agx::Vec3 next, agxCollide::Cylinder* cylinder);
307 bool considerTurningToFree(ContactNode* cln, const agx::Vec3& prev, const agx::Vec3& next, const agx::Vec3& edge, const agx::Vec3& center);
308 bool checkIfFuturePositionIsBad(Node* middleContact);
309 void fixFreeEndContactPassings(WireDistanceCompositeConstraint* ldcc);
310 Node* getContactAtBadConfiguration(const NodeIterator it, const NodeIterator next, const NodeIterator nextNext, const agxCollide::Shape* shape, const WireDistanceCompositeConstraint* ldcc);
311 void catchBadContactConfiguration(WireDistanceCompositeConstraint* ldcc, agx::List<NodeIterator>& allContacts);
312 void moveEdgeContactNodes();
313 bool testWireGeometryCollision(agxCollide::Geometry* collidedGeometry, agxCollide::Geometry* wire, agx::Real& depth, agx::Vec3& contactPointW, agx::Vec3& contactNormalW, bool allowStartInsideGeometry);
314 bool clipLine(agxCollide::Geometry* collidedGeometry, const WireRay& wireRay, agx::Vec3& point);
315 bool testWireGeometryCollision(agxCollide::Geometry* collidedGeometry, const WireRay& wireRay, agx::Real& depth, agx::Vec3& contactPointW, bool allowStartInsideGeometry);
316 void removeTightCylinderContacts(WireDistanceCompositeConstraint* ldcc, agx::List<NodeIterator>& allContacts);
317 agx::Real testEdgeTransfer(ContactNode* cn, agx::Real t);
318 bool findNextTriangleAndEdge(agxCollide::Geometry* meshGeometry, agxCollide::Mesh* mesh, agx::Vec3& clnPosW,
319 agx::Vec3& lineDirW, agx::Real& lineLength, size_t& triangleIndex, size_t& edgeIndex, bool& convexAngle,
320 agx::Vec3 nodePosW, agx::Vec3 linePlaneNormal, bool useRelVel, size_t numIterations);
321 bool analyzeMeshContact(ContactNode* cln, agxCollide::Mesh* mesh, bool forward, agx::Vec3Vector& newContactShapeTranslates, agx::Vector< size_t >& newTriangleIndices, agx::Vector< size_t >& newEdgeIndices);
322 void fixPenetrationProblems();
323 void fixMeshPenetrationProblems(NodePtrContainer& meshContacts, WireDistanceCompositeConstraint* ldcc);
324 bool addBoxContactNearBoxContact(WireDistanceCompositeConstraint* ldcc, ContactNode* cln, bool beforeNode);
325 void fixBoxPenetrationProblems(NodePtrContainer& boxContacts, WireDistanceCompositeConstraint* ldcc);
326 void handleNewPossibleEdges();
327 bool changeToNextGeometry(agxWire::ContactNode* cn, agx::Vec3 edgeStart, agx::Vec3 edgeEnd, agx::Vec3 pointWorld, const agx::Vec3& depthVector);
328 agx::Vec3 moveNodeOutsideGeometry(agx::Vec3 contactPointInside, agx::Vec3 contactPointOnSurface, agx::Vec3 newWP, agx::Vec3 edgeStartRelativeMovementWorld, agx::Vec3 offsetW, bool openAngle, agx::Real wireRadius, agx::Real shortOffsetLength, agx::Real relativeMoveDist = 0.0);
329 bool interestingGeometryForContact(ContactNode* cln, agxCollide::Geometry* otherGeometry);
330 void getWireAndEdgeInfo(ContactNode* cln, agx::Real t, agx::Vec3& oldWP, agx::Vec3& newWP, agx::Vec3& edgeStartW, agx::Vec3& edgeEndW, agx::Vec3& wireStartW, agx::Vec3& wireEndW, agx::Vec3& moveDirW, agx::Vec3& offsetW, agx::Vec3& edgeW, agx::Vec3& edgeStart, agx::Vec3& edgeEnd, agx::Vec3& wireStart, agx::Vec3& wireEnd, agx::Vec3& moveDir, agx::Vec3& offset, agx::Vec3& edge, agx::Real& wireRadius, agx::Real& edgeLength);
331 bool analyzeGeometriesSimple(ContactNode* cln, const agxCollide::GeometryRefVector& geometries, agx::Real& t, ContactNodePlacementData& data);
332 bool analyzeGeometries(ContactNode* cln, const agxCollide::GeometryRefVector& geometries, agx::Real& t, ContactNodePlacementData& data, bool allowStartOfWireInsideGeometry/* = false*/);
333
334 bool rayCastToFindNextGeometries(ContactNode* cn, const agxCollide::GeometryRefVector& geometries, ContactNodePlacementData& data, agx::Real& t, bool advanced);
335 agx::Vec3 contactBendForce(WireDistanceCompositeConstraint* ldcc, Node* node1, Node* node2, Node* node3, agx::Vec3 edgeW);
336
337 void getData(const agx::Vector<NodeIterator>& movableContactsOnOneMassless, WireDistanceCompositeConstraint* ldcc, BodyFixedNode* nextBfn,
338 agx::Vec3Vector& positions, agx::Vec3Vector& edgeStartPoints, agx::Vec3Vector& edgeEndPoints, agx::RealVector& velocities,
339 agx::RealVector& normalForces, agx::Real& maxTension, const agx::Real wireRestLength, const agx::Vec3 beginPos);
340 agx::Real calculateNormalForces(WireDistanceCompositeConstraint* ldcc, const agx::Real wireTension, const agx::Real restLength, const agx::Vec3Vector& positions, const agx::Vec3Vector& normalEdges, agx::RealVector& normalForces);
341
342 void updateNormalForces(agxWire::WireDistanceCompositeConstraint* wireConstraint, agx::List<NodeIterator>& contactNodeIterators);
343
344 bool moveEdgeContactNode(WireDistanceCompositeConstraint* ldcc, ContactNode* cln, agx::Real maxLengthDifference, bool updatePreviousPosition = false, bool ignoreFrictionAndMaxmovement = false, agx::Vec3 newShapePosition = agx::Vec3(0, 0, 0));
345 agx::Real changeMovementSoThatTheWireIsNotShorterThanRestlength(agx::Real t, agx::Real to, agx::Real oldL, agx::Real newL, agx::Real midL, agx::Real violation, const agx::Vec3& av, const agx::Vec3& bv, const agx::Vec3& edge_start, const agx::Vec3& edge_vector);
346 void moveContact(ContactNode* cln, const agx::Vec3& edgeStart, const agx::Vec3& edgeVector, agx::Real t);
347 void clearStuckNodes() { m_stuckNodes.clear(); }
348 void setIfStuckNode(ContactNode*cln, const agx::Vec3& eStartNewWorld, const agx::Vec3& eEndNewWorld, const agx::Vec3& eStartOldWorld, const agx::Vec3& eEndOldWorld, const agx::Vec3& clnPosWorld, const agx::Vec3& newGeomCenter, const agx::Vec3& oldGeomCenter, agx::Real sensorRadius, agxCollide::Geometry* nextGeometry);
349 void unStuck(ContactNode*cln);
350 void setStuckNode(ContactNode* cn);
351 void setIfStuckNode(Node* cln, bool nextIsPossible) { m_stuckNodes.insert(cln, nextIsPossible); }
352 void resetPreviousPositions(agx::List<NodeIterator>& contacts);
353 bool saveContactNewPosition(ContactNode*cln, const agx::Vec3& eStart, const agx::Vec3& eEnd, agx::Real t);
354 agxSDK::LineContactPosition& getSavedNewContactPosition(ContactNode* cln);
355 void removeSavedNewContactPosition(ContactNode* cln);
356 void clearContactsNewPosition() { m_contactToNewPosition.clear(); }
357 bool hasUsableNextGeometry(ContactNode* cln);
358 void removeContactsNearSourceDrain(WireDistanceCompositeConstraint* ldcc);
359
369 bool handleSensor(ContactNode* cln, agxCollide::Geometry* geometry, agxCollide::GeometryContact* geometryContact, agx::Vec3& edge, agx::Vec3& shapeContactPoint, agx::Vec3& startMovementRange, agx::Vec3& endMovementRange, agx::Vec3& shapeEdgeOffset);
370
380 bool handleSensor(ContactNode* cln, agxCollide::Geometry* geometry, agx::Vec3 contactPointWorld, agx::Vec3& edge, agx::Vec3& shapeContactPoint, agx::Vec3& startMovementRange, agx::Vec3& endMovementRange, agx::Vec3& shapeEdgeOffset);
381
385 void addMeshInfoToContact(const agxCollide::Mesh* meshShape, ContactNode* cln, size_t triangleIndex, size_t edgeIndex);
386
394 ContactNode* createContactNode(agxCollide::Geometry* geometry, const agx::Vec3& shapePosition, const agx::Vec3& shapeEdge, agx::Vec3 edgeStart, agx::Vec3 edgeEnd, agx::Vec3 shapeEdgeOffset = agx::Vec3(0, 0, 0), size_t triangleIndex = 0, size_t edgeIndex = 0) const;
395
402 void getUnregistredNodes(NodeIterator begin, NodeIterator end, NodePtrContainer& nodes) const;
403
407 bool isOnSameEdge(const ContactNode* cln1, const ContactNode* cln2) const;
408
414 int validateEdges(const agx::AffineMatrix4x4& invShapeTransform, const agx::Vec3& halfExtent, const Node* geomBeginNode, const Node* geomEndNode, NodePtrContainer& newContacts, NodeRefNodePtrListIterRealVector& acceptedNodes) const;
415
416
421 bool handleCylinder(agxCollide::Geometry* geometryCylinder, agxCollide::GeometryContact* geometryContact);
422
423
428 bool handleMesh(agxCollide::Geometry* geometryMesh, agxCollide::GeometryContact* geometryContact);
429
434 bool handleBox(agxCollide::Geometry* geometryBox, agxCollide::GeometryContact* geometryContact);
435
436
442 bool handleSensorBox(ContactNode* cln, agxCollide::Geometry* geometryBox, agx::Vec3 contactPointWorld, agx::Vec3& edge, agx::Vec3& shapeContactPoint, agx::Vec3& startMovementRange, agx::Vec3& endMovementRange, agx::Vec3& shapeEdgeOffset);
443
449 bool handleSensorCylinder(ContactNode* cln, agxCollide::Geometry* geometryCylinder, agx::Vec3 contactPointWorld, agx::Vec3& edge, agx::Vec3& shapeContactPoint, agx::Vec3& startMovementRange, agx::Vec3& endMovementRange, agx::Vec3& shapeEdgeOffset);
450
451
452 bool findNextTriangleAndEdge(const ContactNode* cln, const agxCollide::Mesh* meshShape, const size_t triangleIndex, const size_t vertexIndex, const agx::Vec3& lineStartW, const agx::Vec3& lineEndW, agx::Vec3& edge1StartW, agx::Vec3& edge1EndW, size_t& tempNewTriangleIndex, size_t& tempEdgeLocalIndex);
453
462 bool validatePoint(const agxCollide::Geometry* wireGeometry, const agx::Vec3& point, agx::Real threshold) const;
463
472 bool validatePoint(const NodePtrContainer& nodes, const agx::Vec3& point, agx::Real threshold) const;
473
480 int validateAngles(const agx::AffineMatrix4x4& invShapeTransform, const agx::Vec3& shapeWireGeomBeginPos, const agx::Vec3& shapeWireGeomEndPos, NodePtrContainer& newContacts, NodeRefNodePtrListIterRealVector& acceptedNodes, const agx::Vec3& halfExtent = agx::Vec3(), agx::Real threshold = 0) const;
481
495 int validateEdgePassings(const agxCollide::Geometry* boxGeometry, const agx::AffineMatrix4x4& invShapeTransform, const Node* geomBeginNode, const Node* geomEndNode, int numTimeStepsBackToEvaluateFrom, agx::Real maxDepth, agx::Real timeStep, NodePtrContainer& newContacts, NodeRefNodePtrListIterRealVector& acceptedNodes) const;
496
506 agx::Vec3 validateNormal(const agx::Vec3& normal, const agx::AffineMatrix4x4& invShapeTransform, const Node* geomBeginNode, const Node* geomEndNode, agx::Real timeStep) const;
507
508 int testCircleContacts(size_t i, const agxCollide::Geometry* geometryCylinder, const agxCollide::Cylinder* cylinder, const agx::Vec3& shapeWireGeomBeginPos, const agx::Vec3& shapeWireGeomEndPos, const agx::Vec3& worldWireGeomBeginPos, const agx::Vec3& worldWireGeomEndPos, agx::Real circlePos, NodePtrContainer& newContacts, NodeRefNodePtrListIterRealVector& acceptedNodes) const;
509
522 void calculateContactPoint(const agxCollide::Box* box, const agx::Vec3& localContactPoint, const agx::Vec3& localSegmentBegin, const agx::Vec3& localSegmentEnd, agx::Vec3& retLocalCorrectedContactPoint, agx::Vec3& retEdge, agx::Vec3& retEdgeStart, agx::Vec3& retEdgeEnd) const;
523 void calculateContactPoint(const agxCollide::Box* box, const agx::Vec3& localContactPoint, agx::Vec3& retLocalCorrectedContactPoint, agx::Vec3& retEdge, agx::Vec3& retEdgeStart, agx::Vec3& retEdgeEnd) const;
524
537 void calculateContactPoint(const agxCollide::Cylinder* cylinder, const agx::Vec3& localContactPoint, const agx::Vec3& localContactNormal, const agx::Vec3& localSegmentBegin, const agx::Vec3& localSegmentEnd, agx::Vec3& retLocalCorrectedContactPoint, agx::Vec3& retEdge, agx::Vec3& retEdgeStart, agx::Vec3& retEdgeEnd) const;
538 void calculateContactPoint(const agxCollide::Cylinder* cylinder, const agx::Vec3& localContactPoint, const agx::Vec3& localContactNormal, agx::Vec3& retLocalCorrectedContactPoint, agx::Vec3& retEdge, agx::Vec3& retEdgeStart, agx::Vec3& retEdgeEnd) const;
539
540 void calculateCircleContactPointAndEdge(const agxCollide::Cylinder* cylinderShape, agx::Vec3& Q1, agx::Vec3& shapeLocalEdgeStart, agx::Vec3& shapeLocalEdgeEnd, agx::Vec3& shapeLocalEdge, agx::Vec3& shapeEdgeOffset, agx::Real planePos, bool validateAgainstEnds = false, const agx::Vec3& shapeGeomBeginPos = agx::Vec3(), const agx::Vec3& shapeGeomEndPos = agx::Vec3()) const;
541
552 NodePtrContainer::iterator insertShortestDistance(NodePtrContainer& nodes, ContactNode* contactNode, const agx::Vec3& wireGeomBeginPos, const agx::Vec3& wireGeomEndPos, agx::Real closeThreshold) const;
553
558 bool createAndInsertNode(NodePtrContainer& newContacts, size_t indexInAcceptedNodes, NodeRefNodePtrListIterRealVector& acceptedNodes, const agxCollide::Geometry* geometry, const agx::Vec3& worldWireGeomBeginPos, const agx::Vec3& worldWireGeomEndPos, const agx::Vec3& contactPoint, const agx::Vec3& edgeStart, const agx::Vec3& edgeEnd, const agx::Vec3& edge, const agx::Vec3& shapeEdgeOffset, agx::Real closeThreshold) const;
559
568 void insertValidNodesInWire(NodeIterator wireGeomBeginIt, NodePtrContainer& newContacts, WireDistanceCompositeConstraint* wire, const NodeRefNodePtrListIterRealVector& acceptedNodes, const agxCollide::GeometryContact* geometryContact);
569
570
578 void removeLocalNode(NodePtrContainer& newContacts, NodeRefNodePtrListIterRealVector& acceptedNodes, size_t index) const;
579
580 inline bool hasSavedNewContactPosition(ContactNode* cln)
581 {
582 return m_contactToNewPosition.contains(cln);
583 }
584
585
587#if HASH_FOR_WIRE == HASH_NEW
589 using ContactWireNodePtrContactPositionTable = agx::LinearProbingHashTable<ContactNode*, agxSDK::LineContactPosition>;
590#elif HASH_FOR_WIRE == HASH_OLD
592 typedef agx::QuadraticProbingHashTable<ContactNode*, agxSDK::LineContactPosition> ContactWireNodePtrContactPositionTable;
593#else
594#error
595#endif
596
597 agx::ref_ptr< WireSensorController > m_sensorController;
598 WireContactGeometryTransferController* m_contactGeometryTransferController;
599 EdgeTransferController* m_edgeTransferController;
600
601#if HASH_FOR_WIRE == HASH_NEW
603#elif HASH_FOR_WIRE == HASH_OLD
604 agx::QuadraticProbingHashTable<Node*, bool> m_stuckNodes; //bool is if it is possible to switch to nextGeometry if validateContact says we could try
605#else
606#error
607#endif
608
609 ContactWireNodePtrContactPositionTable m_contactToNewPosition;
610
611 agxCollide::Geometry *initLineGeometry(const agx::Vec3& start, const agx::Vec3& end);
612
613 agxCollide::GeometryRef m_lineGeometry;
614 agxCollide::Line *m_lineShape;
615 };
616
617 typedef agx::ref_ptr< WireOldContactController > WireOldContactControllerRef;
618
619 AGX_FORCE_INLINE bool WireSensorController::match(agx::Physics::GeometryPtr geometry) const
620 {
621 agx::Physics::Geometry::ShapePtr shape = geometry.shape();
622 return shape && shape.type() == agxCollide::Shape::SPHERE && geometry.model()->hasGroup(m_wireId);
623 }
624}
625
#define AGXPHYSICS_EXPORT
A box shape for geometric intersection tests.
Definition Box.h:33
A cylinder shape for geometric intersection tests.
Definition Cylinder.h:37
A contact between two geometries.
Definition Contacts.h:271
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
bool hasGroup(agx::UInt32 id) const
This is performing a linear search among the collision group id for this Geometry.
Definition Geometry.h:831
A line shape for intersection tests, mostly for depth sensing and picking.
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Definition Mesh.h:70
Base class for a shape.
Definition Shape.h:54
Contact node class is a node that, currently, is defined to live on an edge on a geometry (agxCollide...
Inheritance with partial specialization due to bug with ref_ptr containers.
Pointer to a entity instance of type Physics.Geometry.
AGXPHYSICS_EXPORT agx::Physics::Geometry::ShapePtr & shape()
AGXPHYSICS_EXPORT agxCollide::Geometry *& model()
Pointer to a entity instance of type Physics.Geometry.Shape.
AGXPHYSICS_EXPORT agx::UInt8 & type()
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
#define AGX_FORCE_INLINE
Definition macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
Implements a Wire model with adaptive resolution.
Definition MergedBody.h:40
uint32_t UInt32
Definition Integer.h:32
bool Bool
Definition Integer.h:40
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
double Real
Definition Real.h:42
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)