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
// 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(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 = TRIANGLES;  break;
            case DU_DRAW_POINTS: _primType = API_POINTS; break;
            case DU_DRAW_LINES:  _primType = LINES;      break;
            case DU_DRAW_QUADS:  /*_primType = 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
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 Diff Diff 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]]

273 Diff Diff IonutCava picture IonutCava Wed 11 Jun, 2014 20:34:00 +0000

[Ionut] [[BR]]
- Improved batching part2: [[BR]]
— Moved all bone transformation matrices upload from uniform functions in SceneNode to Shader Storage Buffers in AnimationController class with updates controlled by SceneGraphNode’s AnimationComponent [[BR]]
-— No double-buffering or efficient mapping of data yet. Just raw buffer updates [[BR]]
— Replaced all RenderStateBlock* pointers with I64 hash values [[BR]]
-— Will be used later in draw commands as per-shader state hash [[BR]]
— Moved getShaderProgram from Material to Material::ShaderInfo [[BR]]
-— Improved redundant uniform checks [[BR]]
— Improved texture unit changing in case of redundant texture bind case (i.e. skip changing the texture unit) [[BR]]
[[BR]]
- Improved float and double comparison functions using algorithms described in http://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/ [[BR]]
- Added a new utility function, DIVIDE_ASSERT, to more easily bind an assert check with a specific message [[BR]]
- Added missing files from Forward+ renderer’s initial code [[BR]]

267 k1ngp1n picture k1ngp1n Wed 28 May, 2014 11:08:12 +0000

[Ionut] [[BR]]
- Improved texture handling: [[BR]]
— No more texture unbind (except when clearing the frame state) [[BR]]
— Moved texture bind checking to the GL_API class [[BR]]
- Fixed a crash related to vegetation loading due to compiler optimizations [[BR]]
- removed all “releaseMaterial” functions as they are no longer needed [[BR]]