ScummVM API documentation
tracer.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_TRACER_H_INCLUDED
28 #define ICB_TRACER_H_INCLUDED
29 
30 #include "engines/icb/game_volume.h"
31 #include "engines/icb/p4.h"
32 #include "engines/icb/p4_generic.h"
33 
34 #include "engines/icb/common/px_3drealpoint.h"
35 #include "engines/icb/common/px_2drealline.h"
36 
37 namespace ICB {
38 
39 class _floor_world;
40 
41 class _tracer : public _game_volume {
42 public:
43  // Definitions used by this class.
44  enum FaceID { NO_FACE, LEFT, RIGHT, FRONT, BACK, TOP, BOTTOM };
45 
46  // Default constructor and destructor.
47  inline _tracer() { m_pyBarrierMemFile = NULL; m_nPadding[0] = 0; }
48  virtual inline ~_tracer() { ; }
49 
50  // This checks a line through game-world space and returns the point of its first impact.
51  bool8 Trace(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, eBarrierRayType eRayType, px3DRealPoint &oImpact, eBarrierLogicValue eImpactType);
52 
53  // Call this before using the tracer, to point it at its barriers.
54  void SetBarrierPointer(LinkedDataFile *pyBarriers) { m_pyBarrierMemFile = pyBarriers; }
55 
56  // Call this to give the tracer access to the floor data.
57  void SetFloorsPointer(_floor_world *pFloorWorld) { m_pFloorWorld = pFloorWorld; }
58 
59 private:
60  LinkedDataFile *m_pyBarrierMemFile; // The memory image of the barrier file.
61  _floor_world *m_pFloorWorld; // The floors data (loaded by the routing code).
62  PXreal m_fXDiff, m_fYDiff, m_fZDiff; // Delta x, y and z for the line we're tracing.
63  PXreal m_fSqrLength; // Square length of the vector we're tracing.
64  bool8 m_bXPositiveGoing; // These 3 get set once for each
65  bool8 m_bYPositiveGoing; // call to the tracer, and indicate
66  bool8 m_bZPositiveGoing; // which way the line is going.
67  uint8 m_nPadding[1];
68 
69  // Here I block the use of the default '='.
70  _tracer(const _tracer &t) : _game_volume(t) { ; }
71  void operator=(const _tracer &t) { ; }
72 
73  // Private functions used only by this class.
74  void GetBarriersForCube(const _XYZ_index &oCubeIndices, uint32 *oThisCubesBarriers, int32 &nNumBarriers, int32 nExtraSliceIndex) const;
75 
76  px3DRealPoint CalculateEntryToNextCube(const px3DRealPoint &oCurrentPoint, const px3DRealPoint &oTo, const _bullet_cube &oThisCube, FaceID &eCubeLeavingFace) const;
77 
78  bool8 CheckRayHeightAgainstBarrier(const px3DRealPoint &oFrom, const px3DRealPoint &oTo, const RouteBarrier *pBarrier, px3DRealPoint &o3DImpactPoint) const;
79 
80  uint32 FindClosest(const px3DRealPoint &oFrom, px3DRealPoint *oImpactList, uint32 nNumImpacts) const;
81 
82  px3DRealPoint CalculateRayIntersectionWithCubeWall(const px3DRealPoint &oCurrentPoint, const px3DRealPoint &oTo, const _bullet_cube &oThisCube, FaceID eLeavingFace) const;
83 
84  inline const RouteBarrier *GetBarrier(uint32 i) const;
85 };
86 
87 inline const RouteBarrier *_tracer::GetBarrier(uint32 i) const {
88  RouteBarrier *pBarriers;
89 
90  if (!m_pyBarrierMemFile)
91  Fatal_error("No barrier file in _tracer::GetBarrier()");
92 
93  pBarriers = (RouteBarrier *)LinkedDataObject::Fetch_item_by_name(m_pyBarrierMemFile, "Data");
94  return &(pBarriers[i]);
95 }
96 
97 extern _tracer *g_oTracer; // Object for doing the plotting of bullets and line-of-sight.
98 
99 } // End of namespace ICB
100 
101 #endif // #if !defined( TRACER_H_INCLUDED )
Definition: px_3drealpoint.h:45
Definition: game_volume.h:72
Definition: actor.h:32
Definition: floors.h:39
Definition: tracer.h:41
Definition: px_linkeddatafile.h:53
Definition: game_volume.h:55
Definition: game_volume.h:85
Definition: px_route_barriers.h:146