switched to 64-bit entity hash

This commit is contained in:
Turanszki Janos
2020-05-02 02:20:18 +01:00
parent 6236c4f9a8
commit 659d195595
18 changed files with 148 additions and 121 deletions
+2 -2
View File
@@ -1458,7 +1458,7 @@ void EditorComponent::Update(float dt)
for (size_t i = 0; i < count; ++i)
{
wiScene::PickResult picked;
picked.entity = scene.Entity_Serialize(clipboard, INVALID_ENTITY, wiRandom::getRandom(1, INT_MAX), false);
picked.entity = scene.Entity_Serialize(clipboard, INVALID_ENTITY, CreateEntity(), false);
AddSelected(picked);
}
}
@@ -1486,7 +1486,7 @@ void EditorComponent::Update(float dt)
clipboard >> count;
for (size_t i = 0; i < count; ++i)
{
Entity entity = scene.Entity_Serialize(clipboard, INVALID_ENTITY, wiRandom::getRandom(1, INT_MAX), false);
Entity entity = scene.Entity_Serialize(clipboard, INVALID_ENTITY, CreateEntity(), false);
TransformComponent* transform = scene.transforms.GetComponent(entity);
if (transform != nullptr)
{
@@ -94,8 +94,8 @@ protected:
///users can point to their objects, m_userPointer is not used by Bullet, see setUserPointer/getUserPointer
union
{
void* m_userObjectPointer;
int m_userIndex;
void* m_userObjectPointer;
long long m_userIndex;
};
///time of impact calculation
@@ -448,7 +448,7 @@ public:
return m_userObjectPointer;
}
int getUserIndex() const
long long getUserIndex() const
{
return m_userIndex;
}
@@ -459,7 +459,7 @@ public:
}
///users can point to their objects, userPointer is not used by Bullet
void setUserIndex(int index)
void setUserIndex(long long index)
{
m_userIndex = index;
}
+7 -6
View File
@@ -3,6 +3,7 @@
#include "wiArchive.h"
#include "wiRandom.h"
#include "wiHelper.h"
#include <cstdint>
#include <cassert>
@@ -11,23 +12,23 @@
namespace wiECS
{
typedef uint32_t Entity;
using Entity = uint64_t;
static const Entity INVALID_ENTITY = 0;
// Runtime can create a new entity with this
inline Entity CreateEntity()
{
return wiRandom::getRandom(1, INT_MAX);
return wiRandom::getRandom(INVALID_ENTITY + 1, ~0ull);
}
// This is the safe way to serialize an entity
// seed : ensures that entity will be unique after loading (specify seed = 0 to leave entity as-is)
inline void SerializeEntity(wiArchive& archive, Entity& entity, uint32_t seed)
// seed : ensures that entity will be unique after loading (specify seed = INVALID_ENTITY to leave entity as-is)
inline void SerializeEntity(wiArchive& archive, Entity& entity, Entity seed)
{
if (archive.IsReadMode())
{
archive >> entity;
if (entity != INVALID_ENTITY && seed > 0)
{
entity = ((entity << 1) ^ seed) >> 1;
wiHelper::hash_combine(entity, seed);
}
}
else
@@ -90,7 +91,7 @@ namespace wiECS
// Read/Write everything to an archive depending on the archive state
// seed: needed when serializing from disk which might cause discrepancy in entity uniqueness
// propagateSeedDeep: Components can have Entity references inside them, should the seed be propageted to those too?
inline void Serialize(wiArchive& archive, uint32_t seed = 0, bool propagateSeedDeep = true)
inline void Serialize(wiArchive& archive, Entity seed = INVALID_ENTITY, bool propagateSeedDeep = true)
{
if (archive.IsReadMode())
{
+1 -1
View File
@@ -731,7 +731,7 @@ void wiEmittedParticle::Initialize()
}
void wiEmittedParticle::Serialize(wiArchive& archive, uint32_t seed)
void wiEmittedParticle::Serialize(wiArchive& archive, wiECS::Entity seed)
{
if (archive.IsReadMode())
{
+1 -1
View File
@@ -120,7 +120,7 @@ public:
inline void SetSPHEnabled(bool value) { if (value) { _flags |= SPH_FLUIDSIMULATION; } else { _flags &= ~SPH_FLUIDSIMULATION; } }
inline void SetVolumeEnabled(bool value) { if (value) { _flags |= HAS_VOLUME; } else { _flags &= ~HAS_VOLUME; } }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
static void LoadShaders();
static void Initialize();
+1 -1
View File
@@ -245,7 +245,7 @@ void wiHairParticle::Draw(const CameraComponent& camera, const MaterialComponent
}
void wiHairParticle::Serialize(wiArchive& archive, uint32_t seed)
void wiHairParticle::Serialize(wiArchive& archive, wiECS::Entity seed)
{
if (archive.IsReadMode())
{
+1 -1
View File
@@ -59,7 +59,7 @@ public:
AABB aabb;
std::vector<uint32_t> indices; // it is dependent on vertex_lengths and contains triangles with non-zero lengths
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
static void LoadShaders();
static void Initialize();
+1 -1
View File
@@ -162,7 +162,7 @@ AABB AABB::Merge(const AABB& a, const AABB& b)
{
return AABB(wiMath::Min(a.getMin(), b.getMin()), wiMath::Max(a.getMax(), b.getMax()));
}
void AABB::Serialize(wiArchive& archive, uint32_t seed)
void AABB::Serialize(wiArchive& archive, wiECS::Entity seed)
{
if (archive.IsReadMode())
{
+1 -1
View File
@@ -56,7 +56,7 @@ struct AABB
return XMFLOAT3(0, 0, 0);
}
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct SPHERE
{
+3 -4
View File
@@ -171,7 +171,7 @@ namespace wiPhysicsEngine
//rbInfo.m_angularDamping = physicscomponent.damping;
btRigidBody* rigidbody = new btRigidBody(rbInfo);
rigidbody->setUserIndex(*(int*)&entity);
rigidbody->setUserIndex(entity);
if (physicscomponent.IsKinematic())
{
@@ -230,7 +230,7 @@ namespace wiPhysicsEngine
if (softbody)
{
softbody->setUserIndex(*(int*)&entity);
softbody->setUserIndex(entity);
//btSoftBody::Material* pm = softbody->appendMaterial();
btSoftBody::Material* pm = softbody->m_materials[0];
@@ -418,8 +418,7 @@ namespace wiPhysicsEngine
for (int i = 0; i < dynamicsWorld->getCollisionObjectArray().size(); ++i)
{
btCollisionObject* collisionobject = dynamicsWorld->getCollisionObjectArray()[i];
int userIndex = collisionobject->getUserIndex();
Entity entity = *(Entity*)&userIndex;
Entity entity = (Entity)collisionobject->getUserIndex();
btRigidBody* rigidbody = btRigidBody::upcast(collisionobject);
if (rigidbody != nullptr)
+20
View File
@@ -15,4 +15,24 @@ namespace wiRandom
{
return getRandom(0, maxValue);
}
uint32_t wiRandom::getRandom(uint32_t minValue, uint32_t maxValue)
{
std::uniform_int_distribution<uint32_t> distr(minValue, maxValue);
return distr(generator);
}
uint32_t wiRandom::getRandom(uint32_t maxValue)
{
return getRandom(0u, maxValue);
}
uint64_t wiRandom::getRandom(uint64_t minValue, uint64_t maxValue)
{
std::uniform_int_distribution<uint64_t> distr(minValue, maxValue);
return distr(generator);
}
uint64_t wiRandom::getRandom(uint64_t maxValue)
{
return getRandom(0ull, maxValue);
}
}
+8
View File
@@ -1,8 +1,16 @@
#pragma once
#include <cstdint>
namespace wiRandom
{
int getRandom(int minValue, int maxValue);
int getRandom(int maxValue);
uint32_t getRandom(uint32_t minValue, uint32_t maxValue);
uint32_t getRandom(uint32_t maxValue);
uint64_t getRandom(uint64_t minValue, uint64_t maxValue);
uint64_t getRandom(uint64_t maxValue);
};
+1 -1
View File
@@ -85,7 +85,7 @@ namespace wiRenderer_BindLua
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
wiRenderer::AttachCamera(entity);
}
else
+1 -2
View File
@@ -1278,8 +1278,7 @@ namespace wiScene
// Then deserialize with a unique seed:
archive.SetReadModeAndResetPos(true);
uint32_t seed = wiRandom::getRandom(1, INT_MAX);
return Entity_Serialize(archive, entity, seed, false);
return Entity_Serialize(archive, entity, CreateEntity(), false);
}
Entity Scene::Entity_CreateMaterial(
const std::string& name
+24 -24
View File
@@ -29,7 +29,7 @@ namespace wiScene
inline void operator=(std::string&& str) { name = std::move(str); }
inline bool operator==(const std::string& str) const { return name.compare(str) == 0; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct LayerComponent
@@ -38,7 +38,7 @@ namespace wiScene
inline uint32_t GetLayerMask() const { return layerMask; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct TransformComponent
@@ -83,7 +83,7 @@ namespace wiScene
void Lerp(const TransformComponent& a, const TransformComponent& b, float t);
void CatmullRom(const TransformComponent& a, const TransformComponent& b, const TransformComponent& c, const TransformComponent& d, float t);
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct PreviousFrameTransformComponent
@@ -91,7 +91,7 @@ namespace wiScene
// Non-serialized attributes:
XMFLOAT4X4 world_prev;
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct HierarchyComponent
@@ -99,7 +99,7 @@ namespace wiScene
wiECS::Entity parentID = wiECS::INVALID_ENTITY;
uint32_t layerMask_bind; // saved child layermask at the time of binding
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct MaterialComponent
@@ -240,7 +240,7 @@ namespace wiScene
ShaderMaterial CreateShaderMaterial() const;
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct MeshComponent
@@ -329,7 +329,7 @@ namespace wiScene
void RecenterToBottom();
SPHERE GetBoundingSphere() const;
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
struct Vertex_POS
@@ -468,7 +468,7 @@ namespace wiScene
inline void SetDirty(bool value = true) { if (value) { _flags |= DIRTY; } else { _flags &= ~DIRTY; } }
inline bool IsDirty() const { return _flags & DIRTY; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct ObjectComponent
@@ -555,7 +555,7 @@ namespace wiScene
void SaveLightmap();
wiGraphics::FORMAT GetLightmapFormat();
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct RigidBodyPhysicsComponent
@@ -592,7 +592,7 @@ namespace wiScene
inline bool IsDisableDeactivation() const { return _flags & DISABLE_DEACTIVATION; }
inline bool IsKinematic() const { return _flags & KINEMATIC; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct SoftBodyPhysicsComponent
@@ -625,7 +625,7 @@ namespace wiScene
// Create physics represenation of graphics mesh
void CreateFromMesh(const MeshComponent& mesh);
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct ArmatureComponent
@@ -669,7 +669,7 @@ namespace wiScene
std::vector<ShaderBoneType> boneData;
wiGraphics::GPUBuffer boneBuffer;
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct LightComponent
@@ -737,7 +737,7 @@ namespace wiScene
}
inline LightType GetType() const { return type; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct CameraComponent
@@ -787,7 +787,7 @@ namespace wiScene
inline bool IsDirty() const { return _flags & DIRTY; }
inline bool IsCustomProjectionEnabled() const { return _flags & CUSTOM_PROJECTION; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct EnvironmentProbeComponent
@@ -812,7 +812,7 @@ namespace wiScene
inline bool IsDirty() const { return _flags & DIRTY; }
inline bool IsRealTime() const { return _flags & REALTIME; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct ForceFieldComponent
@@ -834,7 +834,7 @@ namespace wiScene
inline float GetRange() const { return range_global; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct DecalComponent
@@ -859,7 +859,7 @@ namespace wiScene
inline float GetOpacity() const { return color.w; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct AnimationComponent
@@ -928,7 +928,7 @@ namespace wiScene
inline void Stop() { Pause(); timer = 0.0f; }
inline void SetLooped(bool value = true) { if (value) { _flags |= LOOPED; } else { _flags &= ~LOOPED; } }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct WeatherComponent
@@ -995,7 +995,7 @@ namespace wiScene
std::string skyMapName;
std::shared_ptr<wiResource> skyMap;
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct SoundComponent
@@ -1020,7 +1020,7 @@ namespace wiScene
inline void Stop() { _flags &= ~PLAYING; }
inline void SetLooped(bool value = true) { if (value) { _flags |= LOOPED; } else { _flags &= ~LOOPED; } }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct InverseKinematicsComponent
@@ -1039,7 +1039,7 @@ namespace wiScene
inline void SetDisabled(bool value = true) { if (value) { _flags |= DISABLED; } else { _flags &= ~DISABLED; } }
inline bool IsDisabled() const { return _flags & DISABLED; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct SpringComponent
@@ -1072,7 +1072,7 @@ namespace wiScene
inline bool IsStretchEnabled() const { return _flags & STRETCH_ENABLED; }
inline bool IsGravityEnabled() const { return _flags & GRAVITY_ENABLED; }
void Serialize(wiArchive& archive, uint32_t seed = 0);
void Serialize(wiArchive& archive, wiECS::Entity seed = wiECS::INVALID_ENTITY);
};
struct Scene
@@ -1126,10 +1126,10 @@ namespace wiScene
wiECS::Entity Entity_Duplicate(wiECS::Entity entity);
// Serializes entity and all of its components to archive:
// You can specify entity = INVALID_ENTITY when the entity needs to be created from archive
// You can specify seed = 0 when the archive is guaranteed to be storing persistent and unique entities
// You can specify seed = INVALID_ENTITY when the archive is guaranteed to be storing persistent and unique entities
// propagateDeepSeed : request that entity references inside components should be seeded as well
// Returns either the new entity that was read, or the original entity that was written
wiECS::Entity Entity_Serialize(wiArchive& archive, wiECS::Entity entity = wiECS::INVALID_ENTITY, uint32_t seed = 0, bool propagateSeedDeep = true);
wiECS::Entity Entity_Serialize(wiArchive& archive, wiECS::Entity entity = wiECS::INVALID_ENTITY, wiECS::Entity seed = wiECS::INVALID_ENTITY, bool propagateSeedDeep = true);
wiECS::Entity Entity_CreateMaterial(
const std::string& name
+47 -47
View File
@@ -17,7 +17,7 @@ namespace wiScene_BindLua
int CreateEntity_BindLua(lua_State* L)
{
Entity entity = CreateEntity();
wiLua::SSetInt(L, (int)entity);
wiLua::SSetLongLong(L, entity);
return 1;
}
@@ -52,7 +52,7 @@ int LoadModel(lua_State* L)
}
}
Entity root = wiScene::LoadModel(*custom_scene->scene, fileName, transform, true);
wiLua::SSetInt(L, int(root));
wiLua::SSetLongLong(L, root);
return 1;
}
else
@@ -79,7 +79,7 @@ int LoadModel(lua_State* L)
}
}
Entity root = wiScene::LoadModel(fileName, transform, true);
wiLua::SSetInt(L, int(root));
wiLua::SSetLongLong(L, root);
return 1;
}
}
@@ -123,7 +123,7 @@ int Pick(lua_State* L)
}
}
auto& pick = wiScene::Pick(ray->ray, renderTypeMask, layerMask, *scene);
wiLua::SSetInt(L, (int)pick.entity);
wiLua::SSetLongLong(L, pick.entity);
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal)));
wiLua::SSetFloat(L, pick.distance);
@@ -173,7 +173,7 @@ int SceneIntersectSphere(lua_State* L)
}
}
auto& pick = wiScene::SceneIntersectSphere(sphere->sphere, renderTypeMask, layerMask, *scene);
wiLua::SSetInt(L, (int)pick.entity);
wiLua::SSetLongLong(L, pick.entity);
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal)));
wiLua::SSetFloat(L, pick.depth);
@@ -223,7 +223,7 @@ int SceneIntersectCapsule(lua_State* L)
}
}
auto& pick = wiScene::SceneIntersectCapsule(capsule->capsule, renderTypeMask, layerMask, *scene);
wiLua::SSetInt(L, (int)pick.entity);
wiLua::SSetLongLong(L, pick.entity);
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position)));
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal)));
wiLua::SSetFloat(L, pick.depth);
@@ -414,7 +414,7 @@ int Scene_BindLua::Entity_FindByName(lua_State* L)
Entity entity = scene->Entity_FindByName(name);
wiLua::SSetInt(L, (int)entity);
wiLua::SSetLongLong(L, entity);
return 1;
}
else
@@ -428,7 +428,7 @@ int Scene_BindLua::Entity_Remove(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
scene->Entity_Remove(entity);
}
@@ -443,11 +443,11 @@ int Scene_BindLua::Entity_Duplicate(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
Entity clone = scene->Entity_Duplicate(entity);
wiLua::SSetInt(L, (int)clone);
wiLua::SSetLongLong(L, clone);
return 1;
}
else
@@ -462,7 +462,7 @@ int Scene_BindLua::Component_CreateName(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
NameComponent& component = scene->names.Create(entity);
Luna<NameComponent_BindLua>::push(L, new NameComponent_BindLua(&component));
@@ -479,7 +479,7 @@ int Scene_BindLua::Component_CreateLayer(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
LayerComponent& component = scene->layers.Create(entity);
Luna<LayerComponent_BindLua>::push(L, new LayerComponent_BindLua(&component));
@@ -496,7 +496,7 @@ int Scene_BindLua::Component_CreateTransform(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
TransformComponent& component = scene->transforms.Create(entity);
Luna<TransformComponent_BindLua>::push(L, new TransformComponent_BindLua(&component));
@@ -513,7 +513,7 @@ int Scene_BindLua::Component_CreateLight(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
scene->aabb_lights.Create(entity);
@@ -532,7 +532,7 @@ int Scene_BindLua::Component_CreateObject(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
scene->aabb_objects.Create(entity);
@@ -551,7 +551,7 @@ int Scene_BindLua::Component_CreateInverseKinematics(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
InverseKinematicsComponent& component = scene->inverse_kinematics.Create(entity);
Luna<InverseKinematicsComponent_BindLua>::push(L, new InverseKinematicsComponent_BindLua(&component));
@@ -568,7 +568,7 @@ int Scene_BindLua::Component_CreateSpring(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
SpringComponent& component = scene->springs.Create(entity);
Luna<SpringComponent_BindLua>::push(L, new SpringComponent_BindLua(&component));
@@ -586,7 +586,7 @@ int Scene_BindLua::Component_GetName(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
NameComponent* component = scene->names.GetComponent(entity);
if (component == nullptr)
@@ -608,7 +608,7 @@ int Scene_BindLua::Component_GetLayer(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
LayerComponent* component = scene->layers.GetComponent(entity);
if (component == nullptr)
@@ -630,7 +630,7 @@ int Scene_BindLua::Component_GetTransform(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
TransformComponent* component = scene->transforms.GetComponent(entity);
if (component == nullptr)
@@ -652,7 +652,7 @@ int Scene_BindLua::Component_GetCamera(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
CameraComponent* component = scene->cameras.GetComponent(entity);
if (component == nullptr)
@@ -674,7 +674,7 @@ int Scene_BindLua::Component_GetAnimation(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
AnimationComponent* component = scene->animations.GetComponent(entity);
if (component == nullptr)
@@ -696,7 +696,7 @@ int Scene_BindLua::Component_GetMaterial(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
MaterialComponent* component = scene->materials.GetComponent(entity);
if (component == nullptr)
@@ -718,7 +718,7 @@ int Scene_BindLua::Component_GetEmitter(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
wiEmittedParticle* component = scene->emitters.GetComponent(entity);
if (component == nullptr)
@@ -740,7 +740,7 @@ int Scene_BindLua::Component_GetLight(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
LightComponent* component = scene->lights.GetComponent(entity);
if (component == nullptr)
@@ -762,7 +762,7 @@ int Scene_BindLua::Component_GetObject(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
ObjectComponent* component = scene->objects.GetComponent(entity);
if (component == nullptr)
@@ -784,7 +784,7 @@ int Scene_BindLua::Component_GetInverseKinematics(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
InverseKinematicsComponent* component = scene->inverse_kinematics.GetComponent(entity);
if (component == nullptr)
@@ -806,7 +806,7 @@ int Scene_BindLua::Component_GetSpring(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
SpringComponent* component = scene->springs.GetComponent(entity);
if (component == nullptr)
@@ -952,7 +952,7 @@ int Scene_BindLua::Entity_GetNameArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->names.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->names.GetEntity(i));
wiLua::SSetLongLong(L, scene->names.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -963,7 +963,7 @@ int Scene_BindLua::Entity_GetLayerArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->layers.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->layers.GetEntity(i));
wiLua::SSetLongLong(L, scene->layers.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -974,7 +974,7 @@ int Scene_BindLua::Entity_GetTransformArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->transforms.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->transforms.GetEntity(i));
wiLua::SSetLongLong(L, scene->transforms.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -985,7 +985,7 @@ int Scene_BindLua::Entity_GetCameraArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->cameras.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->cameras.GetEntity(i));
wiLua::SSetLongLong(L, scene->cameras.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -996,7 +996,7 @@ int Scene_BindLua::Entity_GetAnimationArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->animations.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->animations.GetEntity(i));
wiLua::SSetLongLong(L, scene->animations.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1007,7 +1007,7 @@ int Scene_BindLua::Entity_GetMaterialArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->materials.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->materials.GetEntity(i));
wiLua::SSetLongLong(L, scene->materials.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1018,7 +1018,7 @@ int Scene_BindLua::Entity_GetEmitterArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->emitters.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->emitters.GetEntity(i));
wiLua::SSetLongLong(L, scene->emitters.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1029,7 +1029,7 @@ int Scene_BindLua::Entity_GetLightArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->lights.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->lights.GetEntity(i));
wiLua::SSetLongLong(L, scene->lights.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1040,7 +1040,7 @@ int Scene_BindLua::Entity_GetObjectArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->objects.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->objects.GetEntity(i));
wiLua::SSetLongLong(L, scene->objects.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1051,7 +1051,7 @@ int Scene_BindLua::Entity_GetInverseKinematicsArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->inverse_kinematics.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->inverse_kinematics.GetEntity(i));
wiLua::SSetLongLong(L, scene->inverse_kinematics.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1062,7 +1062,7 @@ int Scene_BindLua::Entity_GetSpringArray(lua_State* L)
int newTable = lua_gettop(L);
for (size_t i = 0; i < scene->springs.GetCount(); ++i)
{
wiLua::SSetInt(L, scene->springs.GetEntity(i));
wiLua::SSetLongLong(L, scene->springs.GetEntity(i));
lua_rawseti(L, newTable, lua_Integer(i + 1));
}
return 1;
@@ -1073,8 +1073,8 @@ int Scene_BindLua::Component_Attach(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 1)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity parent = (Entity)wiLua::SGetInt(L, 2);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
Entity parent = (Entity)wiLua::SGetLongLong(L, 2);
scene->Component_Attach(entity, parent);
}
@@ -1089,7 +1089,7 @@ int Scene_BindLua::Component_Detach(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
scene->Component_Detach(entity);
}
@@ -1104,7 +1104,7 @@ int Scene_BindLua::Component_DetachChildren(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity parent = (Entity)wiLua::SGetInt(L, 1);
Entity parent = (Entity)wiLua::SGetLongLong(L, 1);
scene->Component_DetachChildren(parent);
}
@@ -2218,7 +2218,7 @@ ObjectComponent_BindLua::~ObjectComponent_BindLua()
int ObjectComponent_BindLua::GetMeshID(lua_State* L)
{
wiLua::SSetInt(L, (int)component->meshID);
wiLua::SSetLongLong(L, component->meshID);
return 1;
}
int ObjectComponent_BindLua::GetColor(lua_State* L)
@@ -2237,7 +2237,7 @@ int ObjectComponent_BindLua::SetMeshID(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity meshID = (Entity)wiLua::SGetInt(L, 1);
Entity meshID = (Entity)wiLua::SGetLongLong(L, 1);
component->meshID = meshID;
}
else
@@ -2325,7 +2325,7 @@ int InverseKinematicsComponent_BindLua::SetTarget(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Entity entity = (Entity)wiLua::SGetInt(L, 1);
Entity entity = (Entity)wiLua::SGetLongLong(L, 1);
component->target = entity;
}
else
@@ -2378,7 +2378,7 @@ int InverseKinematicsComponent_BindLua::SetDisabled(lua_State* L)
}
int InverseKinematicsComponent_BindLua::GetTarget(lua_State* L)
{
wiLua::SSetInt(L, (int)component->target);
wiLua::SSetLongLong(L, component->target);
return 1;
}
int InverseKinematicsComponent_BindLua::GetChainLength(lua_State* L)
+24 -24
View File
@@ -9,7 +9,7 @@ using namespace wiECS;
namespace wiScene
{
void NameComponent::Serialize(wiArchive& archive, uint32_t seed)
void NameComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -20,7 +20,7 @@ namespace wiScene
archive << name;
}
}
void LayerComponent::Serialize(wiArchive& archive, uint32_t seed)
void LayerComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -31,7 +31,7 @@ namespace wiScene
archive << layerMask;
}
}
void TransformComponent::Serialize(wiArchive& archive, uint32_t seed)
void TransformComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -51,12 +51,12 @@ namespace wiScene
archive << translation_local;
}
}
void PreviousFrameTransformComponent::Serialize(wiArchive& archive, uint32_t seed)
void PreviousFrameTransformComponent::Serialize(wiArchive& archive, Entity seed)
{
// NOTHING! We just need a serialize function for this to be able serialize with ComponentManager!
// This structure has no persistent state!
}
void HierarchyComponent::Serialize(wiArchive& archive, uint32_t seed)
void HierarchyComponent::Serialize(wiArchive& archive, Entity seed)
{
SerializeEntity(archive, parentID, seed);
@@ -74,7 +74,7 @@ namespace wiScene
archive << layerMask_bind;
}
}
void MaterialComponent::Serialize(wiArchive& archive, uint32_t seed)
void MaterialComponent::Serialize(wiArchive& archive, Entity seed)
{
std::string dir = archive.GetSourceDirectory();
@@ -249,7 +249,7 @@ namespace wiScene
}
}
}
void MeshComponent::Serialize(wiArchive& archive, uint32_t seed)
void MeshComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
@@ -338,7 +338,7 @@ namespace wiScene
}
}
void ImpostorComponent::Serialize(wiArchive& archive, uint32_t seed)
void ImpostorComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -353,7 +353,7 @@ namespace wiScene
archive << swapInDistance;
}
}
void ObjectComponent::Serialize(wiArchive& archive, uint32_t seed)
void ObjectComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -394,7 +394,7 @@ namespace wiScene
}
}
}
void RigidBodyPhysicsComponent::Serialize(wiArchive& archive, uint32_t seed)
void RigidBodyPhysicsComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -415,7 +415,7 @@ namespace wiScene
archive << damping;
}
}
void SoftBodyPhysicsComponent::Serialize(wiArchive& archive, uint32_t seed)
void SoftBodyPhysicsComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -444,7 +444,7 @@ namespace wiScene
archive << weights;
}
}
void ArmatureComponent::Serialize(wiArchive& archive, uint32_t seed)
void ArmatureComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -492,7 +492,7 @@ namespace wiScene
}
}
}
void LightComponent::Serialize(wiArchive& archive, uint32_t seed)
void LightComponent::Serialize(wiArchive& archive, Entity seed)
{
std::string dir = archive.GetSourceDirectory();
@@ -563,7 +563,7 @@ namespace wiScene
archive << lensFlareNames;
}
}
void CameraComponent::Serialize(wiArchive& archive, uint32_t seed)
void CameraComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -586,7 +586,7 @@ namespace wiScene
archive << fov;
}
}
void EnvironmentProbeComponent::Serialize(wiArchive& archive, uint32_t seed)
void EnvironmentProbeComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -599,7 +599,7 @@ namespace wiScene
archive << _flags;
}
}
void ForceFieldComponent::Serialize(wiArchive& archive, uint32_t seed)
void ForceFieldComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -616,7 +616,7 @@ namespace wiScene
archive << range_local;
}
}
void DecalComponent::Serialize(wiArchive& archive, uint32_t seed)
void DecalComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -627,7 +627,7 @@ namespace wiScene
archive << _flags;
}
}
void AnimationComponent::Serialize(wiArchive& archive, uint32_t seed)
void AnimationComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -695,7 +695,7 @@ namespace wiScene
}
}
}
void WeatherComponent::Serialize(wiArchive& archive, uint32_t seed)
void WeatherComponent::Serialize(wiArchive& archive, Entity seed)
{
std::string dir = archive.GetSourceDirectory();
@@ -792,7 +792,7 @@ namespace wiScene
}
}
void SoundComponent::Serialize(wiArchive& archive, uint32_t seed)
void SoundComponent::Serialize(wiArchive& archive, Entity seed)
{
std::string dir = archive.GetSourceDirectory();
@@ -828,7 +828,7 @@ namespace wiScene
archive << soundinstance.type;
}
}
void InverseKinematicsComponent::Serialize(wiArchive& archive, uint32_t seed)
void InverseKinematicsComponent::Serialize(wiArchive& archive, Entity seed)
{
SerializeEntity(archive, target, seed);
@@ -845,7 +845,7 @@ namespace wiScene
archive << iteration_count;
}
}
void SpringComponent::Serialize(wiArchive& archive, uint32_t seed)
void SpringComponent::Serialize(wiArchive& archive, Entity seed)
{
if (archive.IsReadMode())
{
@@ -879,7 +879,7 @@ namespace wiScene
}
// With this we will ensure that serialized entities are unique and persistent across the scene:
uint32_t seed = (uint32_t)wiRandom::getRandom(1, INT_MAX);
Entity seed = CreateEntity();
names.Serialize(archive, seed);
layers.Serialize(archive, seed);
@@ -921,7 +921,7 @@ namespace wiScene
}
Entity Scene::Entity_Serialize(wiArchive& archive, Entity entity, uint32_t seed, bool propagateSeedDeep)
Entity Scene::Entity_Serialize(wiArchive& archive, Entity entity, Entity seed, bool propagateSeedDeep)
{
SerializeEntity(archive, entity, seed);
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 40;
// minor bug fixes, alterations, refactors, updates
const int revision = 4;
const int revision = 5;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);