1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TETRAEDGE_TE_TE_FREE_MOVE_ZONE_H
#define TETRAEDGE_TE_TE_FREE_MOVE_ZONE_H
#include "common/array.h"
#include "tetraedge/te/te_bezier_curve.h"
#include "tetraedge/te/te_camera.h"
#include "tetraedge/te/te_intrusive_ptr.h"
#include "tetraedge/te/te_obp.h"
#include "tetraedge/te/te_pick_mesh2.h"
#include "tetraedge/te/te_vector3f32.h"
#include "tetraedge/te/te_act_zone.h"
#include "tetraedge/te/te_timer.h"
namespace Tetraedge {
namespace micropather {
class MicroPather;
}
// TODO: should these structs be moved to their own headers?
struct TeBlocker {
Common::String _s;
TeVector2f32 _pts[2];
bool _enabled;
};
struct TeRectBlocker {
Common::String _s;
TeVector2f32 _pts[4];
bool _enabled;
};
class TeFreeMoveZoneGraph;
class TeFreeMoveZone : public TePickMesh2 {
public:
struct CollidePoint {
TeVector3f32 _point;
float _distance;
};
TeFreeMoveZone();
~TeFreeMoveZone();
float bordersDistance() const;
void buildAStar();
void calcGridMatrix();
void clear();
Common::Array<TeVector3f32> collisions(const TeVector3f32 &v1, const TeVector3f32 &v2);
TeVector3f32 correctCharacterPosition(const TeVector3f32 &pos, bool *flagout, bool f);
TeIntrusivePtr<TeBezierCurve> curve(const TeVector3f32 &startpt, const TeVector2s32 &endpt, float param_5, bool findMeshFlag);
TeIntrusivePtr<TeBezierCurve> curve(const TeVector3f32 &startpt, const TeVector3f32 &endpt);
void draw() override;
TeVector3f32 findNearestPointOnBorder(const TeVector2f32 &pt);
byte hasBlockerIntersection(const TeVector2s32 &pt);
bool hasCellBorderIntersection(const TeVector2s32 &pt);
TeActZone *isInZone(const TeVector3f32 &pt);
// loadBin() 2 versions, seem unused
// name(), onPositionChanged(), position(), rotate(), rotation(), scale(),
// setName(), setPosition(), setRotation(), setScale(), setVisible(),
// translate(), and visible() are all implemented in original, but all
// just do the same as super.
bool onViewportChanged();
void preUpdateGrid();
TeVector2s32 projectOnAStarGrid(const TeVector3f32 &pt);
Common::Array<TeVector3f32> removeInsignificantPoints(const Common::Array<TeVector3f32> &points);
void setBordersDistance(float dist);
void setCamera(TeIntrusivePtr<TeCamera> &cam, bool noRecalcProjPoints);
void setNbTriangles(uint len);
void setPathFindingOccluder(const TeOBP &occluder);
void setVertex(uint offset, const TeVector3f32 &vertex);
TeVector3f32 transformAStarGridInWorldSpace(const TeVector2s32 &gridpt);
float transformHeightMin(float minval);
TeVector3f32 transformVectorInWorldSpace(float param_3, float param_4);
void updateBorders();
void updateGrid(bool force);
void updatePickMesh();
void updateProjectedPoints();
void updateTransformedVertices();
static float normalizeAngle(float angle);
static void deserialize(Common::ReadStream &stream, TeFreeMoveZone &dest, Common::Array<TeBlocker> *blockers,
Common::Array<TeRectBlocker> *rectblockers, Common::Array<TeActZone> *actzones);
static void serialize(Common::WriteStream &stream, const TeFreeMoveZone &src, bool updateFirst);
static TePickMesh2 *findNearestMesh(TeIntrusivePtr<TeCamera> &camera, const TeVector2s32 &frompt,
Common::Array<TePickMesh2*> &pickMeshes, TeVector3f32 *outloc, bool lastHitFirst);
private:
TeVector2s32 aStarResolution() const;
Common::Array<TeActZone> *_actzones;
Common::Array<TeBlocker> *_blockers;
Common::Array<TeRectBlocker> *_rectBlockers;
Common::Array<TeVector3f32> _freeMoveZoneVerticies;
Common::Array<uint> _pickMesh;
Common::Array<TeVector3f32> _transformedVerticies;
Common::Array<uint> _borders;
// TODO: Find better names..
TeVector2f32 _gridOffsetSomething;
TeVector2f32 _someGridVec1;
TeVector2f32 _someGridVec2;
TeMatrix4x4 _gridMatrix;
TeMatrix4x4 _inverseWorldTransform;
float _gridWorldY;
TeOBP _obp;
TeIntrusivePtr<TeCamera> _camera;
//static TeIntrusivePtr<TeCamera> _globalCamera;
TeFreeMoveZoneGraph *_graph;
bool _loadedFromBin;
bool _gridDirty;
bool _transformedVerticiesDirty;
bool _bordersDirty;
bool _pickMeshDirty;
bool _projectedPointsDirty;
micropather::MicroPather *_micropather;
TeTimer _updateTimer;
};
} // end namespace Tetraedge
#endif // TETRAEDGE_TE_TE_FREE_MOVE_ZONE_H
|