TraceResult.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
5 */
6
7 #ifndef CAFU_CLIPSYS_TRACE_RESULT_HPP_INCLUDED
8 #define CAFU_CLIPSYS_TRACE_RESULT_HPP_INCLUDED
9
10 #include "Math3D/Vector3.hpp"
11
12
13 class MaterialT;
14
15
16 namespace cf
17 {
18  namespace ClipSys
19  {
20  class ClipModelT;
21
22
23  /// This class describes the result of tracing an object (a ray, a bounding-box,
24  /// or a convex solid) through a collision model, a clip model, or a clip world.
25  ///
26  /// - If `StartSolid` is `true`, the trace started in solid. In this case,
27  /// `Fraction` is accordingly set to 0.0.
28  ///
29  /// - If `Fraction` is smaller than the value that the trace was started with,
30  /// something was hit along the trace. `Fraction`, `ImpactNormal` and `Material`
31  /// provide details about the point of impact.
32  ///
33  /// - If `Fraction` did not change, the entire trace succeeded without hitting
34  /// anything.
35  ///
36  struct TraceResultT
37  {
38  /// The constructor.
39  TraceResultT(double Fraction_ = 1.0) : Fraction(Fraction_), StartSolid(false), Material(NULL) { }
40
41  double Fraction; ///< How much of the trace could be completed before a hit occurred (if any).
42  bool StartSolid; ///< Did the trace start in a solid part of the collision or clip model?
43  Vector3dT ImpactNormal; ///< On impact, this is the normal vector of the hit surface.
44  MaterialT* Material; ///< The material at the point of impact. Can be NULL when an edge (i.e. a bevel plane) was hit.
45  };
46
47
48  /// This class describes one result (of possibly several) of tracing an object
49  /// (a ray, a bounding-box, or a convex solid) through a clip world.
51  {
52  WorldTraceResultT() : Result(), ClipModel(NULL) { }
53  WorldTraceResultT(const TraceResultT& TR, ClipModelT* CM) : Result(TR), ClipModel(CM) { }
54
55  TraceResultT Result; ///< The result of the trace that hit ClipModel (`Result.Fraction < 1.0`).
56  ClipModelT* ClipModel; ///< The clip model related to the trace result. If `NULL`, the trace result is related to the ClipWorldT::WorldCollMdl.
57  };
58  }
59 }
60
61 #endif
Vector3dT ImpactNormal
On impact, this is the normal vector of the hit surface.
Definition: TraceResult.hpp:43
A clip model represents an object in the world against which clipping queries can be performed...
Definition: ClipModel.hpp:31
bool StartSolid
Did the trace start in a solid part of the collision or clip model?
Definition: TraceResult.hpp:42
TraceResultT Result
The result of the trace that hit ClipModel (Result.Fraction < 1.0).
Definition: TraceResult.hpp:55
This class describes one result (of possibly several) of tracing an object (a ray, a bounding-box, or a convex solid) through a clip world.
Definition: TraceResult.hpp:50
This class represents a surface material ("A datastructural representation of a scripts material def...
Definition: Material.hpp:22
MaterialT * Material
The material at the point of impact. Can be NULL when an edge (i.e. a bevel plane) was hit...
Definition: TraceResult.hpp:44
double Fraction
How much of the trace could be completed before a hit occurred (if any).
Definition: TraceResult.hpp:41
This class describes the result of tracing an object (a ray, a bounding-box, or a convex solid) throu...
Definition: TraceResult.hpp:36
ClipModelT * ClipModel
The clip model related to the trace result. If NULL, the trace result is related to the ClipWorldT::W...
Definition: TraceResult.hpp:56
TraceResultT(double Fraction_=1.0)
The constructor.
Definition: TraceResult.hpp:39