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
/*
   Copyright (c) 2014 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.

 */

#ifndef _AI_TEAM_H_
#define _AI_TEAM_H_

#include "AI/Headers/AIEntity.h"

namespace Divide {
    namespace AI {

namespace Navigation{
    class DivideDtCrowd;
    class NavigationMesh;
};

class Order {
public:
    Order(U32 id) : _id(id),
                    _locked(false)
    {
    }
    inline U32 getId() const { return _id; }
    inline  bool locked() const { return _locked; }
    virtual void lock()   { _locked = true;  }
    virtual void unlock() { _locked = false; }
protected:
    U32 _id;
    bool _locked;
};

class AITeam : public GUIDWrapper {
public:

public:
    typedef Navigation::DivideDtCrowd* CrowdPtr;
    typedef hashMapImpl<AIEntity::PresetAgentRadius, CrowdPtr, hashAlg::hash<I32> > AITeamCrowd;
    typedef hashMapImpl<AIEntity*, F32 > MemberVariable;
    typedef hashMapImpl<I64, AIEntity*> TeamMap;

    AITeam(U32 id);
    ~AITeam();

    inline CrowdPtr const getCrowd(AIEntity::PresetAgentRadius radius) const {
        ReadLock r_lock(_crowdMutex);
        AITeamCrowd::const_iterator it = _aiTeamCrowd.find(radius);
        if (it != _aiTeamCrowd.end()) {
            return it->second;
        }
        return nullptr;
    }

    bool addTeamMember(AIEntity* entity);
    bool removeTeamMember(AIEntity* entity);
    bool addEnemyTeam(U32 enemyTeamID);
    bool removeEnemyTeam(U32 enemyTeamID);

    inline void setTeamID(U32 value) { _teamID = value; }
    inline U32  getTeamID() const { return  _teamID; }
    inline I32  getEnemyTeamID(U32 index) const {
        ReadLock r_lock(_enemyTeamLock);
        if (_enemyTeams.size() <= index) {
            return -1;
        }
        return _enemyTeams[index];
    }

    inline const TeamMap&  getTeamMembers()    const {  return _team;  }
    inline MemberVariable& getMemberVariable()       { return _memberVariable; }
   
    inline void clearOrders() {
        WriteLock w_lock(_orderMutex);
        _orders.clear();
    }
    inline void addOrder(Order* const order) {
        assert(order != nullptr);
        WriteLock w_lock(_orderMutex);
        if (findOrder(order) == _orders.end()){
            _orders.push_back(order);
        }
    }

    inline void removeOrder(Order* const order) {
        assert(order != nullptr);
        WriteLock w_lock(_orderMutex);
        vectorImpl<Order* >::iterator it = findOrder(order);
        if (it != _orders.end()){
            _orders.erase(it);
        }
    }

    const vectorImpl<Order* >& requestOrders() const { return _orders; }

protected:
    friend class AIManager;
    /// Update the crowding system
    void resetCrowd();
    void processInput(const U64 deltaTime);
    void processData(const U64 deltaTime);
    void update(const U64 deltaTime);
    void init();
    void addCrowd(AIEntity::PresetAgentRadius radius, Navigation::NavigationMesh* crowd);
    void removeCrowd(AIEntity::PresetAgentRadius radius);

protected:

    inline vectorImpl<Order* >::iterator findOrder(Order* const order) {
        assert(order != nullptr);
        U32 orderId = order->getId();
        return vectorAlg::find_if(_orders.begin(), _orders.end(), 
                                  [&orderId]( Order* const order )->bool {
                                    return orderId == order->getId(); 
                                  });
    }

    inline vectorImpl<U32 >::iterator AITeam::findEnemyTeamEntry(U32 enemyTeamID) {
        ReadLock r_lock(_enemyTeamLock);
        return vectorAlg::find_if(_enemyTeams.begin(), _enemyTeams.end(),
                                  [&enemyTeamID]( U32 id )->bool {
                                    return id == enemyTeamID; 
                                  });
    }

protected:
    mutable SharedLock _orderMutex;

private:
    U32 _teamID;
    TeamMap  _team;
    /// Container with data per team member. For example a map of distances
    MemberVariable _memberVariable;
    AITeamCrowd        _aiTeamCrowd;
    mutable SharedLock _updateMutex;
    mutable SharedLock _crowdMutex;
    mutable SharedLock _enemyTeamLock;
    vectorImpl<U32 >   _enemyTeams;
    vectorImpl<Order* > _orders;
};

}; //namespace AI
}; //namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/AI/ActionInterface/Headers/AITeam.h

Diff revisions: vs.
Revision Author Commited Message
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)

325 Diff Diff IonutCava picture IonutCava Wed 17 Sep, 2014 20:06:13 +0000

[Ionut]
- Reworked transform system:
— Parent transform chain system moved from Transform class to the PhysicsComponent
— PhysicsComponent now returns all transform values needed both global and local (still needs heavy optimization and caching)

- Reworked SceneGraph node management:
— Proper ref counting of SceneNodes and proper removing of resource (ResourceCache is now empty on destruction, as it should be)
— Removed parent transform tracking as that’s the PhysicsComponent’s responsibility
— Only nodes loaded via the ResourceCache are allowed to be added to the SceneGraph (added proper loaders for Impostors, Sky, etc)

- Optimized some of the math classes (mat4, mat3)

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

320 Diff Diff IonutCava picture IonutCava Sun 31 Aug, 2014 21:45:33 +0000

[Ionut]
- More AI work (entity captures flag and returns it to base)

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)

316 Diff Diff IonutCava picture IonutCava Mon 25 Aug, 2014 22:04:03 +0000

[Ionut]
- Cleaned up AI classes
- Added basic Order <-> Goal system

313 Diff Diff IonutCava picture IonutCava Sat 23 Aug, 2014 23:46:25 +0000

[Ionut]
- Added a messageBox gui element. Simple title/message hide/show System
- Added a working memory system to the WarSceneAISceneImpl class and a few memory facts for testing
- Reworked AI sensor system

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

310 Diff Diff IonutCava picture IonutCava Sun 17 Aug, 2014 23:31:04 +0000

[Ionut]
- Some cleanups in AI related classes

255 k1ngp1n picture k1ngp1n Thu 10 Apr, 2014 16:13:23 +0000

[Ionut] [[BR]]
- Added AESOP library http://code.google.com/p/aesop-open-planner/ [[BR]]
- Performance optimizations: [[BR]]
— Update animations only for visible nodes (must handle special cases when nodes are just outside the frustum) [[BR]]
— Compile shaders only for the current stage when the material is requested (as opposed to compiling shaders for all the rendering stages when first accessing the material)[[BR]]
- Renamed Coordination to AITeam [[BR]]