Merge remote-tracking branch 'origin/master' into 1.7

# Conflicts:
#	Flax.flaxproj
This commit is contained in:
Wojtek Figat
2023-10-09 12:40:47 +02:00
86 changed files with 1406 additions and 686 deletions

View File

@@ -136,13 +136,11 @@ public:
public:
bool IsEnd() const
{
ASSERT(_collection);
return Index() == _collection->Count();
}
bool IsNotEnd() const
{
ASSERT(_collection);
return Index() != _collection->Count();
}
@@ -171,8 +169,6 @@ public:
public:
Iterator& operator++()
{
ASSERT(_collection);
// Check if it is not at end
const int32 end = _collection->Count();
if (Index() != end)
@@ -188,38 +184,18 @@ public:
_index = 0;
}
}
return *this;
}
Iterator operator++(int)
{
ASSERT(_collection);
Iterator temp = *this;
// Check if it is not at end
const int32 end = _collection->Count();
if (Index() != end)
{
// Move forward within chunk
_index++;
// Check if need to change chunk
if (_index == ChunkSize && _chunkIndex < _collection->_chunks.Count() - 1)
{
// Move to next chunk
_chunkIndex++;
_index = 0;
}
}
++temp;
return temp;
}
Iterator& operator--()
{
ASSERT(_collection);
// Check if it's not at beginning
if (_index != 0 || _chunkIndex != 0)
{
@@ -236,32 +212,13 @@ public:
_index--;
}
}
return *this;
}
Iterator operator--(int)
{
ASSERT(_collection);
Iterator temp = *this;
// Check if it's not at beginning
if (_index != 0 || _chunkIndex != 0)
{
// Check if need to change chunk
if (_index == 0)
{
// Move to previous chunk
_chunkIndex--;
_index = ChunkSize - 1;
}
else
{
// Move backward within chunk
_index--;
}
}
--temp;
return temp;
}
};

View File

@@ -309,7 +309,7 @@ public:
FORCE_INLINE bool operator==(const Iterator& v) const
{
return _index == v._index && &_collection == &v._collection;
return _index == v._index && _collection == v._collection;
}
FORCE_INLINE bool operator!=(const Iterator& v) const

View File

@@ -73,28 +73,22 @@ void ObjectsRemovalService::Flush(float dt, float gameDelta)
PoolLocker.Lock();
int32 itemsLeft;
do
// Update timeouts and delete objects that timed out
for (auto i = Pool.Begin(); i.IsNotEnd(); ++i)
{
// Update timeouts and delete objects that timed out
itemsLeft = Pool.Count();
for (auto i = Pool.Begin(); i.IsNotEnd(); ++i)
auto& bucket = *i;
Object* obj = bucket.Key;
const float ttl = bucket.Value - ((obj->Flags & ObjectFlags::UseGameTimeForDelete) != ObjectFlags::None ? gameDelta : dt);
if (ttl <= 0.0f)
{
Object* obj = i->Key;
const float ttl = i->Value - ((obj->Flags & ObjectFlags::UseGameTimeForDelete) != ObjectFlags::None ? gameDelta : dt);
if (ttl <= 0.0f)
{
Pool.Remove(i);
obj->OnDeleteObject();
itemsLeft--;
}
else
{
i->Value = ttl;
}
Pool.Remove(i);
obj->OnDeleteObject();
}
else
{
bucket.Value = ttl;
}
}
while (itemsLeft != Pool.Count()); // Continue removing if any new item was added during removing (eg. sub-object delete with 0 timeout)
PoolLocker.Unlock();
}