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
// With huge thanks to:
//    Mikko Mononen http://groups.google.com/group/recastnavigation
// And thanks to  Daniel Buckmaster, 2011 for his
// T3D 1.1 implementation of Recast's DebugUtils.

#include "Headers/NavMeshDebugDraw.h"
#include "Headers/NavMesh.h"

#include "Platform/Video/Headers/GFXDevice.h"
#include "Platform/Video/Headers/RenderStateBlock.h"

namespace Divide {
namespace AI {
namespace Navigation {
NavMeshDebugDraw::NavMeshDebugDraw()
    : _overrideColor(false),
      _dirty(true),
      _paused(false),
      _color(0),
      _primitive(nullptr) {
    // Generate a render state
    RenderStateBlockDescriptor navigationDebugDesc;
    navigationDebugDesc.setCullMode(CullMode::CULL_MODE_NONE);
    navigationDebugDesc.setBlend(true);
    _navMeshStateBlockHash =
        GFX_DEVICE.getOrCreateStateBlock(navigationDebugDesc);
}

NavMeshDebugDraw::~NavMeshDebugDraw() {
    // Allow the primitive to be deleted
    if (_primitive) _primitive->_canZombify = true;
}

void NavMeshDebugDraw::paused(bool state) {
    _paused = state;
    if (_primitive) _primitive->paused(_paused);
}

void NavMeshDebugDraw::depthMask(bool state) {
    RenderStateBlockDescriptor newDepthDesc(
        GFX_DEVICE.getStateBlockDescriptor(_navMeshStateBlockHash));
    newDepthDesc.setZReadWrite(true, state);
    _navMeshStateBlockHash = GFX_DEVICE.getOrCreateStateBlock(newDepthDesc);
}

void NavMeshDebugDraw::beginBatch() {
    if (!_primitive) {
        _dirty = true;
        _primitive = GFX_DEVICE.getOrCreatePrimitive(false);
        _primitive->stateHash(_navMeshStateBlockHash);
    }

    assert(_primitive != nullptr);

    if (_dirty) _primitive->beginBatch();
}

void NavMeshDebugDraw::endBatch() {
    if (!_dirty) return;

    if (_primitive) _primitive->endBatch();

    _dirty = false;
}

void NavMeshDebugDraw::begin(duDebugDrawPrimitives prim, F32 size) {
    if (!_dirty || !_primitive) return;

    switch (prim) {
        default:
        case DU_DRAW_TRIS:
            _primType = PrimitiveType::TRIANGLES;
            break;
        case DU_DRAW_POINTS:
            _primType = PrimitiveType::API_POINTS;
            break;
        case DU_DRAW_LINES:
            _primType = PrimitiveType::LINES;
            break;
        case DU_DRAW_QUADS: /*_primType = PrimitiveType::QUADS;*/
            assert(prim == DU_DRAW_QUADS);
    }

    _primitive->attribute4ub("inColorData", vec4<U8>(255, 255, 255, 64));
    _primitive->begin(_primType);
}

void NavMeshDebugDraw::vertex(const F32 x, const F32 y, const F32 z,
                              U32 color) {
    if (!_dirty || !_primitive) {
        return;
    }
    if (_overrideColor) {
        color = _color;
    }

    U8 colorVec[4];
    rcCol(color, colorVec[0], colorVec[1], colorVec[2], colorVec[3]);
    colorVec[3] = 64;

    _primitive->attribute4ub("inColorData", colorVec[0], colorVec[1],
                             colorVec[2], colorVec[3]);
    _primitive->vertex(x, y, z);
}

void NavMeshDebugDraw::end() {
    if (_dirty && _primitive) _primitive->end();
}

void NavMeshDebugDraw::overrideColor(U32 col) {
    _overrideColor = true;
    _color = col;
}
};  // namespace Navigation
};  // namespace AI
};  // namespace Divide

Commits for Divide-Framework/trunk/Source Code/AI/PathFinding/NavMeshes/NavMeshDebugDraw.cpp

Diff revisions: vs.
Revision Author Commited Message
365 Diff Diff IonutCava picture IonutCava Sun 08 Mar, 2015 21:26:10 +0000

[Ionut]
- More enum-related type safety changes

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)

334 Diff Diff IonutCava picture IonutCava Wed 10 Dec, 2014 17:21:22 +0000

[Ionut]
- Reorganized the Hardware project and renamed to "Platform"
- Reorganized the Server project

333 Diff Diff IonutCava picture IonutCava Tue 09 Dec, 2014 16:15:44 +0000

[Ionut]
- Removed “core.h” and moved everything to their appropriate header files
- Renamed MathClasses to MathMatrices (finally)
- Renamed “-Inl.h” files to ".inl"
- Some String wrapper refactoring
- Update “InstallLibraries.bat” so that it still offers valid options

331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

330 Diff Diff IonutCava picture IonutCava Fri 10 Oct, 2014 17:19:11 +0000

[Ionut]
- New rendering algorithm :
— Perform second pass for visible nodes gathering all render commands and uploading them to an indirect draw buffer
— Render geometry with indirect draw commands
— Removed per-node range binding of the node buffer. Instead, bind the entire buffer once and index data in shaders
— Use “baseInstance” parameter from IndirectDrawCommand as a node buffer index
— Prefer DSA extensions for updating buffer data where applicable
- Moved all rendering specific code from SceneGraphNode to a new RenderingComponent
- Optimized “toString” utility function

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

311 Diff Diff IonutCava picture IonutCava Mon 18 Aug, 2014 21:40:52 +0000

[Ionut]
- Added a basic AESOP implementation
- Moved all AI related classes under the “AI” namespace

286 Diff Diff IonutCava picture IonutCava Fri 18 Jul, 2014 16:32:03 +0000

[Ionut] [[BR]]

    • very buggy commit ** [[BR]]

- New rendering pipeline: [[BR]]
— Bumped OpenGL version to 4.4 [[BR]]
— Command based rendering. GFXDevice dispatches rendering commands to their respective buffers [[BR]]
— State changing is exclusively controlled by the GFXDevice class [[BR]]
— Material properties and transform matrices are stored in shader storage buffers that are updated after culling and uploaded once per RenderPass. Objects use drawIDs to index data in shaders [[BR]]
— Removed all custom matrices and other, per shader, bind data [[BR]]
— Removed per node light data. Light culling and shader buffers will replace the old light management system [[BR]]
— Framebuffers now use the Texture class for attachments [[BR]]
— Sampler objects now work like RenderStateBlocks. GL_API handles them and stores them in a hash indexed map [[BR]]
— Removed “prepareMaterial” calls. Pre-draw material setup is now only limited to texture binding [[BR]]
— Moved immediate mode emulation and primitive rendering from API level to GFXDevice level [[BR]]
— Framebuffer rendering must be completed with a call to end() to ensure proper MSAA resolve (asserts, otherwise) [[BR]]
- Fixed hash code generation for RenderStateBlock (and now, glSamplerObject) using boost::hash_combine [[BR]]
- Temporarily disabled XML caching for materials [[BR]]

280 IonutCava picture IonutCava Sat 28 Jun, 2014 19:11:37 +0000

[Ionut] [[BR]]
- Improve ClipPlane management (bunch equations into the matrix shader buffer) [[BR]]
- Immediate mode emulation primitives set their own state based on specified hash instead of relying on state functions to be defined [[BR]]
- updateStates() function is now called right before the actual draw call to facilitate future batching work [[BR]]
- added tracked bool values (similar to those in ShaderInfo) to SGN class to fix selection bug. [[BR]]
— will probably create a “stateTracker” class to allow multiple classes to use tracked variables without all of the code duplication [[BR]]