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
#include "Headers/AITeam.h"

#include "AI/Headers/AIEntity.h"
#include "AI/PathFinding/Headers/DivideCrowd.h"
#include "Managers/Headers/AIManager.h"
#include "Dynamics/Entities/Units/Headers/NPC.h"

namespace Divide {
using namespace AI;

AITeam::AITeam(U32 id) : GUIDWrapper(), 
                         _teamID(id)
{
    _team.clear();
    AIManager::getInstance().registerTeam(this);
}

AITeam::~AITeam()
{
	AIManager::getInstance().unregisterTeam(this);
	{
		WriteLock w1_lock(_crowdMutex);
        MemoryManager::DELETE_HASHMAP(_aiTeamCrowd);
	}
	{
		WriteLock w2_lock(_updateMutex);
		for (AITeam::TeamMap::value_type& entity : _team) {
			entity.second->setTeamPtr(nullptr);
		}
		_team.clear();
	}
    
}

void AITeam::addCrowd(AIEntity::PresetAgentRadius radius, Navigation::NavigationMesh* navMesh) {
    DIVIDE_ASSERT(_aiTeamCrowd.find(radius) == _aiTeamCrowd.end(), 
                  "AITeam error: DtCrowd already existed for new navmesh!");
    hashAlg::emplace(_aiTeamCrowd, radius, MemoryManager_NEW Navigation::DivideDtCrowd(navMesh));
}

void AITeam::removeCrowd(AIEntity::PresetAgentRadius radius) {
    AITeamCrowd::iterator it =  _aiTeamCrowd.find(radius);
    DIVIDE_ASSERT(it != _aiTeamCrowd.end(), 
                  "AITeam error: DtCrowd does not exist for specified navmesh!");
    MemoryManager::DELETE( it->second );
    _aiTeamCrowd.erase(it);
}

void AITeam::update(const U64 deltaTime) {
    // Crowds
    ReadLock r_lock(_crowdMutex);
	for (AITeamCrowd::value_type& it : _aiTeamCrowd) {
        it.second->update( deltaTime );
    }
    r_lock.unlock();
    WriteLock w_lock(_updateMutex);
	for (AITeam::TeamMap::value_type& entity : _team) {
        entity.second->update( deltaTime );
    }
}

void AITeam::processInput(const U64 deltaTime) {
    WriteLock w_lock(_updateMutex);
	for (AITeam::TeamMap::value_type& entity : _team) {
        entity.second->processInput( deltaTime );
    }
}

void AITeam::processData(const U64 deltaTime){
    WriteLock w_lock(_updateMutex);
	for (AITeam::TeamMap::value_type& entity : _team) {
        entity.second->processData( deltaTime );
    }
}

void AITeam::init() {
    WriteLock w_lock(_updateMutex);
	for (AITeam::TeamMap::value_type& entity : _team) {
        entity.second->init();
    }
}

void AITeam::resetCrowd() {
    WriteLock w_lock(_updateMutex); 
	for (AITeam::TeamMap::value_type& entity : _team) {
        entity.second->resetCrowd();
    }
}

bool AITeam::addTeamMember(AIEntity* entity) {
    UpgradableReadLock ur_lock(_updateMutex);
    if (!entity){
        return false;
    }
    /// If entity already belongs to this team, no need to do anything
    if(_team.find(entity->getGUID()) != _team.end()){
        return true;
    }
    UpgradeToWriteLock uw_lock(ur_lock);
    hashAlg::emplace(_team, entity->getGUID(), entity);
    entity->setTeamPtr(this);
    return true;
}

///Removes an entity from this list
bool AITeam::removeTeamMember(AIEntity* entity) {
    UpgradableReadLock ur_lock(_updateMutex);
    if (!entity) {
        return false;
    }
    if(_team.find(entity->getGUID()) != _team.end()){
        UpgradeToWriteLock uw_lock(ur_lock);
        _team.erase(entity->getGUID());
    }

    return true;
}

bool AITeam::addEnemyTeam(U32 enemyTeamID) {
    if (findEnemyTeamEntry(enemyTeamID) == _enemyTeams.end()) {
        WriteLock w_lock(_updateMutex); 
        _enemyTeams.push_back(enemyTeamID);
        return true;
    }
    return false;
}

bool AITeam::removeEnemyTeam(U32 enemyTeamID) {
    vectorImpl<U32>::iterator it = findEnemyTeamEntry(enemyTeamID);
    if (it != _enemyTeams.end()) {
        WriteLock w_lock(_updateMutex); 
        _enemyTeams.erase(it);
        return true;
    }
    return false;
}

}; //namespace Divide

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

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)

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

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)

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

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)

319 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 21:37:57 +0000

[Ionut]
- Performance tweaks based on profiling data

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

311 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