Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
158
159
160
161
162
163
164
165
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty.  In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would be
//    appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
//    misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
// Changes, Additions and Refactoring : Copyright (c) 2010-2011 Lethal Concept,
// LLC
// Changes, Additions and Refactoring Author: Simon Wittenberg (MD)
// The above license is fully inherited.

#ifndef _NAVIGATION_MESH_LOADER_H_
#define _NAVIGATION_MESH_LOADER_H_

#include "NavMeshConfig.h"
#include "Core/Math/BoundingVolumes/Headers/BoundingBox.h"
#include "Graphs/Headers/SceneNode.h"

namespace Divide {
namespace AI {
namespace Navigation {

// This struct contains the vertices and triangles in recast coords
class NavModelData {
   public:
    NavModelData()
        : _vertices(0),
          _vertexCount(0),
          _vertexCapacity(0),
          _normals(0),
          _triangleCount(0),
          _triangleCapacity(0),
          _triangles(0),
          _valid(false) {}

    void clear(bool del = true) {
        _valid = false;

        _vertexCount = _triangleCount = 0;
        _vertexCapacity = _vertexCount = 0;
        _triangleCapacity = _triangleCount = 0;

        if (del) {
            MemoryManager::DELETE_ARRAY(_vertices);
        } else {
            _vertices = 0;
        }
        if (del) {
            MemoryManager::DELETE_ARRAY(_triangles);
        } else {
            _triangles = 0;
        }
        if (del) {
            MemoryManager::DELETE_ARRAY(_normals);
        } else {
            _normals = 0;
        }
        _triangleAreaType.clear();
        _navMeshName = "";
    }

    inline bool isValid() const { return _valid; }
    inline void isValid(bool state) { _valid = state; }

    inline void setName(const stringImpl& name) { _navMeshName = name; }
    inline const stringImpl& getName() const { return _navMeshName; }

    inline const F32* getVerts() const { return _vertices; }
    inline const F32* getNormals() const { return _normals; }
    inline const I32* getTris() const { return _triangles; }
    inline U32 getVertCount() const { return _vertexCount; }
    inline U32 getTriCount() const { return _triangleCount; }

    inline vectorImpl<SamplePolyAreas>& getAreaTypes() {
        return _triangleAreaType;
    }

    F32* _vertices;
    F32* _normals;
    I32* _triangles;
    U32 _vertexCapacity;
    U32 _vertexCount;
    U32 _triangleCount;
    U32 _triangleCapacity;

   private:
    bool _valid;
    stringImpl _navMeshName;
    vectorImpl<SamplePolyAreas> _triangleAreaType;
};

namespace NavigationMeshLoader {
enum class MeshDetailLevel : U32 { 
    MAXIMUM = 0,
    BOUNDINGBOX = 1
};

/// Load the input geometry from file (Wavefront OBJ format) and save it in
/// 'outData'
bool loadMeshFile(NavModelData& outData, const char* fileName);
/// Save the navigation input geometry in Wavefront OBJ format
bool saveMeshFile(const NavModelData& inData, const char* filename);
/// Merge the data from two navigation geometry sources
NavModelData mergeModels(NavModelData& a, NavModelData& b,
                         bool delOriginals = false);
/// Parsing method that calls itself recursively untill all geometry has been
/// parsed
bool parse(const BoundingBox& box, NavModelData& outData, SceneGraphNode& sgn);

void addVertex(NavModelData* modelData, const vec3<F32>& vertex);

void addTriangle(NavModelData* modelData, const vec3<U32>& triangleIndices,
                 U32 triangleIndexOffset = 0,
                 const SamplePolyAreas& areaType = SamplePolyAreas::SAMPLE_POLYAREA_GROUND);

char* parseRow(char* buf, char* bufEnd, char* row, I32 len);

I32 parseFace(char* row, I32* data, I32 n, I32 vcnt);
};
};  // namespace Navigation
};  // namespace AI
};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/AI/PathFinding/NavMeshes/Headers/NavMeshLoader.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

539 Diff Diff IonutCava picture IonutCava Wed 28 Oct, 2015 17:07:14 +0000

[IonutCava]
- Profile guided optimizations

524 Diff Diff IonutCava picture IonutCava Thu 08 Oct, 2015 16:14:58 +0000

[IonutCava]
- Profiler guided optimizations:
— Replace most hashMaps with vectors where the common access pattern is linear (e.g. SceneGraphNode’s child list)
— Specify ShaderBuffer access patters at creation time to properly inform the rendering API
— Fix and optimise the LockManager & BufferLockManager classes
— Add a AtomicWrapper class that allows assignment and copy-constructions for atomic variables
-— This allows us to use vector of atomic bools for BB creation for SkinnedSubMesh objects

438 Diff Diff IonutCava picture IonutCava Fri 15 May, 2015 15:46:43 +0000

[Ionut]
- SceneGraphNodes are now stored as shared pointers and Units/AI entities reference them with std::weak_ptr
— ToDo: Make constructor/destructor private again. (made public as a temporary hack to make it work with std::shared_ptr)
- SceneGraphNode’s children map is now read/updated with proper locking mechanism to avoid threading issues (e.g. AI tries to delete a node and rendering thread tries to read material data from it at the same time)
- GL_API does not need to store the previous shader program, just the previous shader program handle.
— Previous responsibilities shifted to glShaderProgram

390 Diff Diff IonutCava picture IonutCava Thu 26 Mar, 2015 22:41:09 +0000

[Ionut]
- Renamed most enum values to shorter names (possible due to enum-class type safety)
- Removed to redundant state change cases (glCullFace when CULL_MODE_NONE was used, and glLineWidth that didn’t have redundancy checks)
- Added a hacky SceneGraphNode render call count to skip the first 3 draw calls so that the data buffers have time to update properly (solves flickering and erroneous rendering when moving camera to include a new node)

366 Diff Diff IonutCava picture IonutCava Tue 10 Mar, 2015 16:56:30 +0000

[Ionut]
- More type safe enum replacement

350 Diff Diff IonutCava picture IonutCava Tue 10 Feb, 2015 16:25:39 +0000

[Ionut]
- Simplified some Util-namespace level functions by using STL algorithms where possible
- Formatted the entire codebase using clang-format with the following style: "{BasedOnStyle: Google, IndentWidth: 4}"
- Attempted to make ProfileTimer thread-safe (temp fix until std::chrono works properly in Visual Studio)

343 IonutCava picture IonutCava Thu 15 Jan, 2015 17:30:12 +0000

[Ionut]
- Refactored 2 singletons into static classes (Console and TerrainLoader)
- Changed some C-casts to static_casts
- Updated copyright notices