AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ContactMeasurement.h
Go to the documentation of this file.
1/*
2Copyright 2007-2023. 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
19#ifndef AGXMODEL_CONTACTMEASUREMENT_H
20#define AGXMODEL_CONTACTMEASUREMENT_H
21
22#include <map>
23#include <unordered_map>
24
25#include <agx/RigidBody.h>
26#include <agxCollide/Geometry.h>
27#include <agxCollide/Shape.h>
28#include <agxModel/export.h>
29#include <agx/Journal.h>
30#include <agxData/Buffer.h>
31
34
35#include <agx/BitState.h>
36
37namespace agxModel
38{
52
54 {
55 public:
61 ContactMeasurement(bool onlyEmittedBodies=true);
62
68
73
78 virtual void pre(const agx::TimeStamp& time) override;
79
84 virtual void post(const agx::TimeStamp& time) override;
85
90 virtual void addNotification() override;
91
97
103
108
109 public:
111
112#ifndef SWIG
114#endif
115
116 protected:
117 void storeChangedImpacts();
118
119 void restoreImpacts();
120
121 void initImpactEnergyStorage();
122
123 void createJournalBindings(agx::Journal* journal);
124
125 agxData::Buffer* getMaxImpactBuffer();
126
128 // Variables
130 protected:
132 agxData::BufferRef m_maxImpactBuffer;
133 agx::ComponentRef m_dataRoot;
134 agx::Uuid m_dataRootUUID;
135 agx::JournalObserver m_journal;
136
137
138 protected:
140
141 private:
142 void calculateImpactEnergy(const agxCollide::GeometryContactPtrVector& contacts, std::unordered_map<agx::Index, std::vector<agx::Vec3f>> preImpactSpeeds);
143
144
145 enum StateEnum : agx::UInt32
146 {
147 DEBUG_RENDER = 1 << 0,
148 };
149 using State = agx::BitState<StateEnum, agx::UInt32>;
150
151 private:
153 State m_state;
154 std::map<agx::UInt32, agx::Real> m_maxImpactEnergies;
155 bool m_onlyEmittedBodies;
156 bool m_clearMaxImpacts;
157 int m_numNonEmittedBodies;
158 };
159}
160#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXMODEL_EXPORT
Abstract representation of a data buffer.
Definition Buffer.h:56
agx::Real getMaxImpactEnergy(agx::RigidBody *body)
Return the max impact energy for a body.
void setEnableDebugRendering(agx::Bool enable)
Enable/disable debug rendering of contact points handled by this component.
agx::Bool getEnableDebugRendering() const
void journalAttachedCallback(agxSDK::Simulation *simulation, agx::Journal *journal)
Attach journal.
static ContactMeasurement * getListener(agxSDK::Simulation *simulation)
If the simulation contains a agxModel::ContactMeasurement then that listener is returned,...
virtual void addNotification() override
Called when this listener is added to the simulation.
ContactMeasurement(bool onlyEmittedBodies=true)
Default constructor.
virtual void post(const agx::TimeStamp &time) override
Calculate the impact energy in the post step between all rigid bodies of interreset.
virtual void pre(const agx::TimeStamp &time) override
Calculate the impact energy in the post step between all rigid bodies of interreset.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Derive from this class to implement a listener for simulation step events.
T CallbackType
Definition Event.h:37
The rigid body class, combining a geometric model and a frame of reference.
Definition RigidBody.h:52
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition Uuid.h:42
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition FlowUnit.h:37
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition Integer.h:40
double Real
Definition Real.h:42
agx::Real TimeStamp
Definition TimeStamp.h:26
STL namespace.