general stability updates

This commit is contained in:
turanszkij
2017-11-27 16:46:39 +00:00
parent dfa25ea44f
commit efd040a1d1
9 changed files with 265 additions and 312 deletions
+26 -2
View File
@@ -1065,7 +1065,14 @@ void EditorComponent::Update(float dt)
for (auto& x : savedParents)
{
*archive << x.first->GetID();
*archive << x.second->GetID();
if (x.second == nullptr)
{
*archive << Transform::INVALID_ID;
}
else
{
*archive << x.second->GetID();
}
}
if (picked->transform != nullptr)
@@ -1117,7 +1124,14 @@ void EditorComponent::Update(float dt)
for (auto& x : savedParents)
{
*archive << x.first->GetID();
*archive << x.second->GetID();
if (x.second == nullptr)
{
*archive << Transform::INVALID_ID;
}
else
{
*archive << x.second->GetID();
}
}
}
@@ -1732,6 +1746,16 @@ void ConsumeHistoryOperation(bool undo)
decal->SetID(id);
model->Add(decal);
}
// force field
*archive >> tmp;
if (tmp)
{
ForceField* force = new ForceField;
force->Serialize(*archive);
force->SetID(id);
model->Add(force);
}
}
if (undo)
+3 -3
View File
@@ -29,11 +29,12 @@ CBUFFER(EmittedParticleCB, CBSLOT_OTHER_EMITTEDPARTICLE)
uint xEmitCount;
uint xEmitterMeshIndexCount;
uint xEmitterMeshVertexPositionStride;
float xEmitterRandomness;
float xParticleSize;
float xParticleScaling;
float xParticleRotation;
uint xParticleColor;
float xParticleRandomFactor;
float xParticleNormalFactor;
@@ -41,8 +42,7 @@ CBUFFER(EmittedParticleCB, CBSLOT_OTHER_EMITTEDPARTICLE)
float xParticleLifeSpanRandomness;
float xParticleMotionBlurAmount;
uint xParticleColor;
float2 xPadding_EmitterCB;
float3 xPadding_EmitterCB;
};
CBUFFER(SortConstants, 0)
+151 -229
View File
File diff suppressed because it is too large Load Diff
+7 -6
View File
@@ -12,6 +12,7 @@
#include <vector>
#include <map>
#include <unordered_set>
#include <list>
#include <deque>
#include <sstream>
@@ -444,7 +445,7 @@ public:
}
~Mesh() {}
void LoadFromFile(const std::string& newName, const std::string& fname
, const MaterialCollection& materialColl, const std::list<Armature*>& armatures, const std::string& identifier="");
, const MaterialCollection& materialColl, const std::unordered_set<Armature*>& armatures, const std::string& identifier="");
bool buffersComplete;
void Optimize();
// Object is needed in CreateBuffers because how else would we know if the mesh needs to be deformed?
@@ -1170,13 +1171,13 @@ struct ForceField : public Transform
struct Model : public Transform
{
std::list<Object*> objects;
std::unordered_set<Object*> objects;
MeshCollection meshes;
MaterialCollection materials;
std::list<Armature*> armatures;
std::list<Light*> lights;
std::list<Decal*> decals;
std::list<ForceField*> forces;
std::unordered_set<Armature*> armatures;
std::unordered_set<Light*> lights;
std::unordered_set<Decal*> decals;
std::unordered_set<ForceField*> forces;
Model();
virtual ~Model();
+72 -63
View File
@@ -1484,7 +1484,15 @@ Transform* wiRenderer::getTransformByName(const std::string& get)
}
Transform* wiRenderer::getTransformByID(uint64_t id)
{
return GetScene().GetWorldNode()->find(id);
for (Model* model : GetScene().models)
{
Transform* found = model->find(id);
if (found != nullptr)
{
return found;
}
}
return nullptr;
}
Armature* wiRenderer::getArmatureByName(const std::string& get)
{
@@ -2317,7 +2325,7 @@ void wiRenderer::ManageImages()
}
void wiRenderer::PutDecal(Decal* decal)
{
GetScene().GetWorldNode()->decals.push_back(decal);
GetScene().GetWorldNode()->decals.insert(decal);
}
void wiRenderer::PutWaterRipple(const std::string& image, const XMFLOAT3& pos)
{
@@ -6126,7 +6134,7 @@ void wiRenderer::LoadDefaultLighting()
Model* model = new Model;
model->name = "_WickedEngine_DefaultLight_Holder_";
model->lights.push_back(defaultLight);
model->lights.insert(defaultLight);
GetScene().models.push_back(model);
if (spTree_lights) {
@@ -6422,83 +6430,84 @@ void wiRenderer::AddRenderableBox(const XMFLOAT4X4& boxMatrix, const XMFLOAT4& c
void wiRenderer::AddModel(Model* model)
{
GetDevice()->LOCK();
GetScene().AddModel(model);
FixedUpdate();
Add(model->objects);
Add(model->lights);
// add object batch
{
vector<Cullable*> collection(model->objects.begin(), model->objects.end());
if (spTree != nullptr)
{
spTree->AddObjects(spTree->root, collection);
}
else
{
spTree = new Octree(collection);
}
}
//UpdateRenderData(nullptr);
// add light batch
{
vector<Cullable*> collection(model->lights.begin(), model->lights.end());
if (spTree_lights != nullptr)
{
spTree_lights->AddObjects(spTree_lights->root, collection);
}
else
{
spTree_lights = new Octree(collection);
}
}
SetUpCubes();
SetUpBoneLines();
GetDevice()->UNLOCK();
}
void wiRenderer::Add(Object* value)
{
list<Object*> collection(0);
GetScene().GetWorldNode()->Add(value);
if (value->parent == nullptr)
{
value->attachTo(GetScene().GetWorldNode());
}
vector<Cullable*> collection(0);
collection.push_back(value);
Add(collection);
if (spTree != nullptr)
{
spTree->AddObjects(spTree->root, collection);
}
else
{
spTree = new Octree(collection);
}
}
void wiRenderer::Add(Light* value)
{
list<Light*> collection(0);
GetScene().GetWorldNode()->Add(value);
if (value->parent == nullptr)
{
value->attachTo(GetScene().GetWorldNode());
}
vector<Cullable*> collection(0);
collection.push_back(value);
Add(collection);
if (spTree_lights != nullptr)
{
spTree_lights->AddObjects(spTree_lights->root, collection);
}
else
{
spTree_lights = new Octree(collection);
}
}
void wiRenderer::Add(ForceField* value)
{
list<ForceField*> collection(0);
collection.push_back(value);
Add(collection);
}
void wiRenderer::Add(const list<Object*>& objects)
{
for (Object* x : objects)
GetScene().GetWorldNode()->Add(value);
if (value->parent == nullptr)
{
if (x->parent == nullptr)
{
GetScene().GetWorldNode()->Add(x);
}
}
if (spTree) {
spTree->AddObjects(spTree->root, std::vector<Cullable*>(objects.begin(), objects.end()));
}
else
{
spTree = new Octree(std::vector<Cullable*>(objects.begin(), objects.end()));
}
}
void wiRenderer::Add(const list<Light*>& lights)
{
for (Light* x : lights)
{
if (x->parent == nullptr)
{
GetScene().GetWorldNode()->Add(x);
}
}
if (spTree_lights) {
spTree_lights->AddObjects(spTree_lights->root, std::vector<Cullable*>(lights.begin(), lights.end()));
}
else
{
spTree_lights = new Octree(std::vector<Cullable*>(lights.begin(), lights.end()));
}
}
void wiRenderer::Add(const list<ForceField*>& forces)
{
for (ForceField* x : forces)
{
if (x->parent == nullptr)
{
GetScene().GetWorldNode()->Add(x);
}
value->attachTo(GetScene().GetWorldNode());
}
}
@@ -6508,7 +6517,7 @@ void wiRenderer::Remove(Object* value)
{
for (auto& x : GetScene().models)
{
x->objects.remove(value);
x->objects.erase(value);
}
spTree->Remove(value);
value->detach();
@@ -6520,7 +6529,7 @@ void wiRenderer::Remove(Light* value)
{
for (auto& x : GetScene().models)
{
x->lights.remove(value);
x->lights.erase(value);
}
spTree_lights->Remove(value);
value->detach();
@@ -6532,7 +6541,7 @@ void wiRenderer::Remove(Decal* value)
{
for (auto& x : GetScene().models)
{
x->decals.remove(value);
x->decals.erase(value);
}
value->detach();
}
@@ -6551,7 +6560,7 @@ void wiRenderer::Remove(ForceField* value)
{
for (auto& x : GetScene().models)
{
x->forces.remove(value);
x->forces.erase(value);
}
value->detach();
}
-4
View File
@@ -560,16 +560,12 @@ public:
// Add model to the scene
static void AddModel(Model* value);
// Add Object Instance
static void Add(Object* value);
static void Add(const std::list<Object*>& objects);
// Add Light Instance
static void Add(Light* value);
static void Add(const std::list<Light*>& lights);
// Add Force Field Instance
static void Add(ForceField* value);
static void Add(const std::list<ForceField*>& forces);
// Remove from the scene
static void Remove(Object* value);
+2 -3
View File
@@ -3,12 +3,11 @@
#include <vector>
uint64_t Node::__Unique_ID_Counter = 0;
std::atomic<uint64_t> Node::__Unique_ID_Counter = 0;
Node::Node() {
name = "";
ID = __Unique_ID_Counter;
__Unique_ID_Counter++;
ID = __Unique_ID_Counter.fetch_add(1);
}
+3 -1
View File
@@ -2,6 +2,7 @@
#define _TRANSFORM_H_
#include "CommonInclude.h"
#include <atomic>
#include <set>
class wiArchive;
@@ -9,7 +10,7 @@ class wiArchive;
struct Node
{
private:
static uint64_t __Unique_ID_Counter;
static std::atomic<uint64_t> __Unique_ID_Counter;
uint64_t ID;
public:
std::string name;
@@ -20,6 +21,7 @@ public:
std::string GetLayerID();
uint64_t GetID() { return ID; }
void SetID(uint64_t newID) { ID = newID; }
static const uint64_t INVALID_ID = UINT64_MAX;
void Serialize(wiArchive& archive);
};
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 13;
// minor bug fixes, alterations, refactors, updates
const int revision = 91;
const int revision = 92;
long GetVersion()