blob rafactor and unit tests
This commit is contained in:
parent
08d60b7d34
commit
371472e596
25 changed files with 421 additions and 241 deletions
|
@ -96,7 +96,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void serialize(Blob& serializer) override
|
virtual void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_animables.size());
|
serializer.write((int32_t)m_animables.size());
|
||||||
for (int i = 0; i < m_animables.size(); ++i)
|
for (int i = 0; i < m_animables.size(); ++i)
|
||||||
|
@ -110,7 +110,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void deserialize(Blob& serializer) override
|
virtual void deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
int32_t count;
|
int32_t count;
|
||||||
serializer.read(count);
|
serializer.read(count);
|
||||||
|
|
|
@ -3,60 +3,60 @@
|
||||||
|
|
||||||
namespace Lumix
|
namespace Lumix
|
||||||
{
|
{
|
||||||
Blob::Blob(IAllocator& allocator)
|
/* OutputBlob::OutputBlob(IAllocator& allocator)
|
||||||
: m_allocator(allocator)
|
: m_allocator(allocator)
|
||||||
, m_buffer(allocator)
|
, m_own_data(allocator)
|
||||||
{
|
{
|
||||||
m_pos = 0;
|
m_pos = 0;
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Blob::Blob(const Blob& rhs, IAllocator& allocator)
|
OutputBlob::OutputBlob(const OutputBlob& rhs, IAllocator& allocator)
|
||||||
: m_allocator(allocator)
|
: m_allocator(allocator)
|
||||||
, m_buffer(allocator)
|
, m_own_data(allocator)
|
||||||
{
|
{
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
*this = rhs;
|
*this = rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Blob::operator =(const Blob& rhs)
|
void OutputBlob::operator =(const OutputBlob& rhs)
|
||||||
{
|
{
|
||||||
m_data = rhs.m_data;
|
m_data = rhs.m_data;
|
||||||
m_pos = rhs.m_pos;
|
m_pos = rhs.m_pos;
|
||||||
m_size = rhs.m_size;
|
m_size = rhs.m_size;
|
||||||
m_buffer = rhs.m_buffer;
|
m_own_data = rhs.m_own_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Blob::rewindForRead()
|
void OutputBlob::rewindForRead()
|
||||||
{
|
{
|
||||||
m_pos = 0;
|
m_pos = 0;
|
||||||
if (!m_buffer.empty())
|
if (!m_own_data.empty())
|
||||||
{
|
{
|
||||||
m_data = &m_buffer[0];
|
m_data = &m_own_data[0];
|
||||||
m_size = m_buffer.size();
|
m_size = m_own_data.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Blob::write(const void* data, int32_t size)
|
void OutputBlob::write(const void* data, int32_t size)
|
||||||
{
|
{
|
||||||
if(m_size + (int)size > m_buffer.size())
|
if(m_size + (int)size > m_own_data.size())
|
||||||
{
|
{
|
||||||
m_buffer.resize(m_size + size);
|
m_own_data.resize(m_size + size);
|
||||||
m_data = &m_buffer[0];
|
m_data = &m_own_data[0];
|
||||||
}
|
}
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
memcpy(&m_buffer[0] + m_size, data, size);
|
memcpy(&m_own_data[0] + m_size, data, size);
|
||||||
}
|
}
|
||||||
m_size += size;
|
m_size += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Blob::read(void* data, int32_t size)
|
bool OutputBlob::read(void* data, int32_t size)
|
||||||
{
|
{
|
||||||
if(m_pos + (int)size > m_size)
|
if(m_pos + (int)size > m_size)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Blob::readString(char* out, int max_size)
|
void OutputBlob::readString(char* out, int max_size)
|
||||||
{
|
{
|
||||||
int32_t size;
|
int32_t size;
|
||||||
read(size);
|
read(size);
|
||||||
|
@ -82,11 +82,95 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Blob::writeString(const char* string)
|
void OutputBlob::writeString(const char* string)
|
||||||
|
{
|
||||||
|
int32_t size = (int32_t)strlen(string) + 1;
|
||||||
|
|
||||||
|
write(size);
|
||||||
|
write(string, size);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
OutputBlob::OutputBlob(IAllocator& allocator)
|
||||||
|
: m_data(allocator)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
OutputBlob::OutputBlob(const OutputBlob& blob, IAllocator& allocator)
|
||||||
|
: m_data(allocator)
|
||||||
|
{
|
||||||
|
m_data = blob.m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OutputBlob::operator =(const OutputBlob& rhs)
|
||||||
|
{
|
||||||
|
m_data = rhs.m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OutputBlob::OutputBlob(const OutputBlob& rhs)
|
||||||
|
: m_data(rhs.m_data)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
void OutputBlob::write(const void* data, int size)
|
||||||
|
{
|
||||||
|
if (size)
|
||||||
|
{
|
||||||
|
int pos = m_data.size();
|
||||||
|
m_data.resize(m_data.size() + size);
|
||||||
|
memcpy(&m_data[0] + pos, data, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OutputBlob::writeString(const char* string)
|
||||||
{
|
{
|
||||||
int32_t size = (int32_t)strlen(string) + 1;
|
int32_t size = (int32_t)strlen(string) + 1;
|
||||||
|
|
||||||
write(size);
|
write(size);
|
||||||
write(string, size);
|
write(string, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InputBlob::InputBlob(const void* data, int size)
|
||||||
|
: m_data((const uint8_t*)data)
|
||||||
|
, m_size(size)
|
||||||
|
, m_pos(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
InputBlob::InputBlob(const OutputBlob& blob)
|
||||||
|
: m_data((const uint8_t*)blob.getData())
|
||||||
|
, m_size(blob.getSize())
|
||||||
|
, m_pos(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
bool InputBlob::read(void* data, int size)
|
||||||
|
{
|
||||||
|
if (m_pos + (int)size > m_size)
|
||||||
|
{
|
||||||
|
for (int32_t i = 0; i < size; ++i)
|
||||||
|
((unsigned char*)data)[i] = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (size)
|
||||||
|
{
|
||||||
|
memcpy(data, ((char*)m_data) + m_pos, size);
|
||||||
|
}
|
||||||
|
m_pos += size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InputBlob::readString(char* data, int max_size)
|
||||||
|
{
|
||||||
|
int32_t size;
|
||||||
|
read(size);
|
||||||
|
ASSERT(size <= max_size);
|
||||||
|
return read(data, size < max_size ? size : max_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // !namespace Lumix
|
} // !namespace Lumix
|
||||||
|
|
|
@ -8,44 +8,46 @@
|
||||||
namespace Lumix
|
namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
class LUMIX_CORE_API Blob
|
class LUMIX_CORE_API OutputBlob
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Blob(IAllocator& allocator);
|
explicit OutputBlob(IAllocator& allocator);
|
||||||
Blob(const Blob& rhs, IAllocator& allocator);
|
OutputBlob(const OutputBlob& blob, IAllocator& allocator);
|
||||||
void operator =(const Blob& rhs);
|
void operator =(const OutputBlob& rhs);
|
||||||
|
OutputBlob(const OutputBlob& rhs);
|
||||||
|
|
||||||
void reserve(int size) { m_buffer.reserve(size); }
|
void reserve(int size) { m_data.reserve(size); }
|
||||||
void create(const void* data, int size) { m_data = data; m_size = size; m_pos = 0; }
|
const void* getData() const { return m_data.empty() ? NULL : &m_data[0]; }
|
||||||
void write(const void* data, int32_t size);
|
int getSize() const { return m_data.size(); }
|
||||||
bool read(void* data, int32_t size);
|
void write(const void* data, int size);
|
||||||
const uint8_t* getBuffer() const { return &m_buffer[0]; }
|
|
||||||
const uint8_t* getData() const { return static_cast<const uint8_t*>(m_data); }
|
|
||||||
int getBufferSize() const { return m_size; }
|
|
||||||
void flush() { m_size = 0; }
|
|
||||||
void clearBuffer() { m_buffer.clear(); m_pos = 0; m_size = 0; }
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void write(T value) { write(&value, sizeof(T)); }
|
|
||||||
void writeString(const char* string);
|
void writeString(const char* string);
|
||||||
void readString(char* out, int max_size);
|
template <class T> void write(T value) { write(&value, sizeof(T)); }
|
||||||
|
void clear() { m_data.clear(); }
|
||||||
template <class T>
|
|
||||||
void read(T& value) { read(&value, sizeof(T)); }
|
|
||||||
|
|
||||||
void rewindForRead();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Blob(const Blob& rhs);
|
Array<uint8_t> m_data;
|
||||||
void write(const char*);
|
};
|
||||||
void read(const char*);
|
|
||||||
|
|
||||||
|
class LUMIX_CORE_API InputBlob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InputBlob(const void* data, int size);
|
||||||
|
InputBlob(const OutputBlob& blob);
|
||||||
|
|
||||||
|
bool read(void* data, int size);
|
||||||
|
bool readString(char* data, int max_size);
|
||||||
|
template <class T> void read(T& value) { read(&value, sizeof(T)); }
|
||||||
|
const void* getData() const { return (const void*)m_data; }
|
||||||
|
int getSize() const { return m_size; }
|
||||||
|
void setPosition(int pos) { m_pos = pos; }
|
||||||
|
void rewind() { m_pos = 0; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IAllocator& m_allocator;
|
const uint8_t* m_data;
|
||||||
Array<uint8_t> m_buffer;
|
|
||||||
int m_pos;
|
|
||||||
int m_size;
|
int m_size;
|
||||||
const void* m_data;
|
int m_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // !namespace Lumix
|
} // !namespace Lumix
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PathManager::serialize(Blob& serializer)
|
void PathManager::serialize(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
MT::SpinLock lock(m_mutex);
|
MT::SpinLock lock(m_mutex);
|
||||||
serializer.write((int32_t)m_paths.size());
|
serializer.write((int32_t)m_paths.size());
|
||||||
|
@ -40,7 +40,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PathManager::deserialize(Blob& serializer)
|
void PathManager::deserialize(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
MT::SpinLock lock(m_mutex);
|
MT::SpinLock lock(m_mutex);
|
||||||
int32_t size;
|
int32_t size;
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
namespace Lumix
|
namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
class Blob;
|
class InputBlob;
|
||||||
|
class OutputBlob;
|
||||||
|
|
||||||
class PathInternal
|
class PathInternal
|
||||||
{
|
{
|
||||||
|
@ -27,8 +28,8 @@ namespace Lumix
|
||||||
PathManager();
|
PathManager();
|
||||||
~PathManager();
|
~PathManager();
|
||||||
|
|
||||||
void serialize(Blob& serializer);
|
void serialize(OutputBlob& serializer);
|
||||||
void deserialize(Blob& serializer);
|
void deserialize(InputBlob& serializer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PathInternal* getPath(uint32_t hash, const char* path);
|
PathInternal* getPath(uint32_t hash, const char* path);
|
||||||
|
|
|
@ -279,7 +279,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void serialize(Blob& serializer) override
|
virtual void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_template_names.size());
|
serializer.write((int32_t)m_template_names.size());
|
||||||
for (int i = 0, c = m_template_names.size(); i < c; ++i)
|
for (int i = 0, c = m_template_names.size(); i < c; ++i)
|
||||||
|
@ -300,7 +300,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void deserialize(Blob& serializer) override
|
virtual void deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
m_template_names.clear();
|
m_template_names.clear();
|
||||||
m_instances.clear();
|
m_instances.clear();
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
namespace Lumix
|
namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
class Blob;
|
class InputBlob;
|
||||||
|
class OutputBlob;
|
||||||
class WorldEditor;
|
class WorldEditor;
|
||||||
|
|
||||||
class LUMIX_ENGINE_API EntityTemplateSystem
|
class LUMIX_ENGINE_API EntityTemplateSystem
|
||||||
|
@ -20,8 +21,8 @@ namespace Lumix
|
||||||
static void destroy(EntityTemplateSystem* system);
|
static void destroy(EntityTemplateSystem* system);
|
||||||
|
|
||||||
virtual ~EntityTemplateSystem() {}
|
virtual ~EntityTemplateSystem() {}
|
||||||
virtual void serialize(Blob& serializer) = 0;
|
virtual void serialize(OutputBlob& serializer) = 0;
|
||||||
virtual void deserialize(Blob& serializer) = 0;
|
virtual void deserialize(InputBlob& serializer) = 0;
|
||||||
virtual void createTemplateFromEntity(const char* name, const Entity& entity) = 0;
|
virtual void createTemplateFromEntity(const char* name, const Entity& entity) = 0;
|
||||||
virtual uint32_t getTemplate(const Entity& entity) = 0;
|
virtual uint32_t getTemplate(const Entity& entity) = 0;
|
||||||
virtual const Array<Entity>& getInstances(uint32_t template_name_hash) = 0;
|
virtual const Array<Entity>& getInstances(uint32_t template_name_hash) = 0;
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Lumix
|
||||||
|
|
||||||
|
|
||||||
struct Vec3;
|
struct Vec3;
|
||||||
class Blob;
|
class OutputBlob;
|
||||||
|
|
||||||
|
|
||||||
class IPropertyDescriptor
|
class IPropertyDescriptor
|
||||||
|
@ -40,10 +40,10 @@ class IPropertyDescriptor
|
||||||
{ }
|
{ }
|
||||||
virtual ~IPropertyDescriptor() {}
|
virtual ~IPropertyDescriptor() {}
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const = 0;
|
virtual void set(Component cmp, InputBlob& stream) const = 0;
|
||||||
virtual void get(Component cmp, Blob& stream) const = 0;
|
virtual void get(Component cmp, OutputBlob& stream) const = 0;
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const = 0;
|
virtual void set(Component cmp, int index, InputBlob& stream) const = 0;
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const = 0;
|
virtual void get(Component cmp, int index, OutputBlob& stream) const = 0;
|
||||||
|
|
||||||
Type getType() const { return m_type; }
|
Type getType() const { return m_type; }
|
||||||
uint32_t getNameHash() const { return m_name_hash; }
|
uint32_t getNameHash() const { return m_name_hash; }
|
||||||
|
@ -99,7 +99,7 @@ class IntArrayObjectDescriptor : public IIntPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override
|
virtual void set(Component cmp, int index, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
stream.read(&i, sizeof(i));
|
stream.read(&i, sizeof(i));
|
||||||
|
@ -107,7 +107,7 @@ class IntArrayObjectDescriptor : public IIntPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
int32_t i = (static_cast<S*>(cmp.scene)->*m_integer_getter)(cmp, index);
|
int32_t i = (static_cast<S*>(cmp.scene)->*m_integer_getter)(cmp, index);
|
||||||
int len = sizeof(i);
|
int len = sizeof(i);
|
||||||
|
@ -115,8 +115,8 @@ class IntArrayObjectDescriptor : public IIntPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component, Blob&) const {};
|
virtual void set(Component, InputBlob&) const override {};
|
||||||
virtual void get(Component, Blob&) const {};
|
virtual void get(Component, OutputBlob&) const override {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IntegerGetter m_integer_getter;
|
IntegerGetter m_integer_getter;
|
||||||
|
@ -142,7 +142,7 @@ class BoolArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override
|
virtual void set(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
stream.read(&b, sizeof(b));
|
stream.read(&b, sizeof(b));
|
||||||
|
@ -150,7 +150,7 @@ class BoolArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
(static_cast<S*>(cmp.scene)->*m_getter)(cmp, index, b);
|
(static_cast<S*>(cmp.scene)->*m_getter)(cmp, index, b);
|
||||||
|
@ -158,8 +158,8 @@ class BoolArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component, Blob&) const { ASSERT(false); };
|
virtual void set(Component, OutputBlob&) const { ASSERT(false); };
|
||||||
virtual void get(Component, Blob&) const { ASSERT(false); };
|
virtual void get(Component, OutputBlob&) const { ASSERT(false); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -185,7 +185,7 @@ class DecimalArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override
|
virtual void set(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
stream.read(&f, sizeof(f));
|
stream.read(&f, sizeof(f));
|
||||||
|
@ -193,15 +193,15 @@ class DecimalArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
float f = (static_cast<S*>(cmp.scene)->*m_getter)(cmp, index);
|
float f = (static_cast<S*>(cmp.scene)->*m_getter)(cmp, index);
|
||||||
stream.write(&f, sizeof(f));
|
stream.write(&f, sizeof(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component, Blob&) const { ASSERT(false); };
|
virtual void set(Component, OutputBlob&) const { ASSERT(false); };
|
||||||
virtual void get(Component, Blob&) const { ASSERT(false); };
|
virtual void get(Component, OutputBlob&) const { ASSERT(false); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -230,7 +230,7 @@ class StringArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override
|
virtual void set(Component cmp, int index, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
char tmp[MAX_STRING_SIZE];
|
char tmp[MAX_STRING_SIZE];
|
||||||
char* c = tmp;
|
char* c = tmp;
|
||||||
|
@ -246,7 +246,7 @@ class StringArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
StackAllocator<MAX_STRING_SIZE> allocator;
|
StackAllocator<MAX_STRING_SIZE> allocator;
|
||||||
string value(allocator);
|
string value(allocator);
|
||||||
|
@ -256,8 +256,8 @@ class StringArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component, Blob&) const { ASSERT(false); };
|
virtual void set(Component, InputBlob&) const { ASSERT(false); };
|
||||||
virtual void get(Component, Blob&) const { ASSERT(false); };
|
virtual void get(Component, OutputBlob&) const { ASSERT(false); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -311,7 +311,7 @@ class Vec3ArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
Vec3ArrayObjectDescriptor(const char* name, Getter _getter, Setter _setter) { setName(name); m_vec3_getter = _getter; m_vec3_setter = _setter; m_type = VEC3; }
|
Vec3ArrayObjectDescriptor(const char* name, Getter _getter, Setter _setter) { setName(name); m_vec3_getter = _getter; m_vec3_setter = _setter; m_type = VEC3; }
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override
|
virtual void set(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
Vec3 v;
|
Vec3 v;
|
||||||
stream.read(&v, sizeof(v));
|
stream.read(&v, sizeof(v));
|
||||||
|
@ -319,7 +319,7 @@ class Vec3ArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
Vec3 v = (static_cast<S*>(cmp.scene)->*m_vec3_getter)(cmp, index);
|
Vec3 v = (static_cast<S*>(cmp.scene)->*m_vec3_getter)(cmp, index);
|
||||||
len = sizeof(v);
|
len = sizeof(v);
|
||||||
|
@ -327,8 +327,8 @@ class Vec3ArrayObjectDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component, Blob&) const {};
|
virtual void set(Component, OutputBlob&) const {};
|
||||||
virtual void get(Component, Blob&) const {};
|
virtual void get(Component, OutputBlob&) const {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -377,7 +377,7 @@ class ArrayDescriptor : public IArrayDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
stream.read(count);
|
stream.read(count);
|
||||||
|
@ -399,7 +399,7 @@ class ArrayDescriptor : public IArrayDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
int count = getCount(cmp);
|
int count = getCount(cmp);
|
||||||
stream.write(count);
|
stream.write(count);
|
||||||
|
@ -413,8 +413,8 @@ class ArrayDescriptor : public IArrayDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component, int, Blob&) const override { ASSERT(false); };
|
virtual void set(Component, int, InputBlob&) const override { ASSERT(false); };
|
||||||
virtual void get(Component, int, Blob&) const override { ASSERT(false); };
|
virtual void get(Component, int, OutputBlob&) const override { ASSERT(false); };
|
||||||
|
|
||||||
virtual int getCount(Component cmp) const override { return (static_cast<S*>(cmp.scene)->*m_counter)(cmp); }
|
virtual int getCount(Component cmp) const override { return (static_cast<S*>(cmp.scene)->*m_counter)(cmp); }
|
||||||
virtual void addArrayItem(Component cmp, int index) const override { (static_cast<S*>(cmp.scene)->*m_adder)(cmp, index); }
|
virtual void addArrayItem(Component cmp, int index) const override { (static_cast<S*>(cmp.scene)->*m_adder)(cmp, index); }
|
||||||
|
@ -439,7 +439,7 @@ class IntPropertyDescriptor : public IIntPropertyDescriptor
|
||||||
IntPropertyDescriptor(const char* name, IntegerGetter _getter, IntegerSetter _setter) { setName(name); m_integer_getter = _getter; m_integer_setter = _setter; m_type = INTEGER; }
|
IntPropertyDescriptor(const char* name, IntegerGetter _getter, IntegerSetter _setter) { setName(name); m_integer_getter = _getter; m_integer_setter = _setter; m_type = INTEGER; }
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
stream.read(&i, sizeof(i));
|
stream.read(&i, sizeof(i));
|
||||||
|
@ -447,7 +447,7 @@ class IntPropertyDescriptor : public IIntPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
int32_t i = (static_cast<S*>(cmp.scene)->*m_integer_getter)(cmp);
|
int32_t i = (static_cast<S*>(cmp.scene)->*m_integer_getter)(cmp);
|
||||||
len = sizeof(i);
|
len = sizeof(i);
|
||||||
|
@ -455,8 +455,8 @@ class IntPropertyDescriptor : public IIntPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
virtual void set(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IntegerGetter m_integer_getter;
|
IntegerGetter m_integer_getter;
|
||||||
|
@ -485,7 +485,7 @@ class StringPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
char tmp[MAX_STRING_SIZE];
|
char tmp[MAX_STRING_SIZE];
|
||||||
char* c = tmp;
|
char* c = tmp;
|
||||||
|
@ -501,7 +501,7 @@ class StringPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
StackAllocator<MAX_STRING_SIZE> allocator;
|
StackAllocator<MAX_STRING_SIZE> allocator;
|
||||||
string value(allocator);
|
string value(allocator);
|
||||||
|
@ -511,8 +511,8 @@ class StringPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
virtual void set(Component cmp, int index, InputBlob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -538,7 +538,7 @@ class BoolPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
stream.read(&b, sizeof(b));
|
stream.read(&b, sizeof(b));
|
||||||
|
@ -546,7 +546,7 @@ class BoolPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
bool b = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
bool b = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
||||||
int len = sizeof(b);
|
int len = sizeof(b);
|
||||||
|
@ -554,8 +554,8 @@ class BoolPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
virtual void set(Component cmp, int index, InputBlob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -581,7 +581,7 @@ class Vec3PropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
Vec3 v;
|
Vec3 v;
|
||||||
stream.read(&v, sizeof(v));
|
stream.read(&v, sizeof(v));
|
||||||
|
@ -589,7 +589,7 @@ class Vec3PropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
Vec3 v = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
Vec3 v = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
||||||
int len = sizeof(v);
|
int len = sizeof(v);
|
||||||
|
@ -597,8 +597,8 @@ class Vec3PropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
virtual void set(Component cmp, int index, InputBlob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -694,7 +694,7 @@ class DecimalPropertyDescriptor : public IDecimalPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
stream.read(&f, sizeof(f));
|
stream.read(&f, sizeof(f));
|
||||||
|
@ -702,7 +702,7 @@ class DecimalPropertyDescriptor : public IDecimalPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
float f = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
float f = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
||||||
int len = sizeof(f);
|
int len = sizeof(f);
|
||||||
|
@ -710,8 +710,8 @@ class DecimalPropertyDescriptor : public IDecimalPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
virtual void set(Component cmp, int index, InputBlob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(cmp, stream);};
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream);};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
@ -737,7 +737,7 @@ class ColorPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, Blob& stream) const override
|
virtual void set(Component cmp, InputBlob& stream) const override
|
||||||
{
|
{
|
||||||
Vec4 f;
|
Vec4 f;
|
||||||
stream.read(&f, sizeof(f));
|
stream.read(&f, sizeof(f));
|
||||||
|
@ -745,7 +745,7 @@ class ColorPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void get(Component cmp, Blob& stream) const override
|
virtual void get(Component cmp, OutputBlob& stream) const override
|
||||||
{
|
{
|
||||||
Vec4 f = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
Vec4 f = (static_cast<S*>(cmp.scene)->*m_getter)(cmp);
|
||||||
int len = sizeof(f);
|
int len = sizeof(f);
|
||||||
|
@ -753,8 +753,8 @@ class ColorPropertyDescriptor : public IPropertyDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void set(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
virtual void set(Component cmp, int index, InputBlob& stream) const override { ASSERT(index == -1); set(cmp, stream); };
|
||||||
virtual void get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(cmp, stream);};
|
virtual void get(Component cmp, int index, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream);};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Getter m_getter;
|
Getter m_getter;
|
||||||
|
|
|
@ -143,7 +143,7 @@ class PasteEntityCommand : public IEditorCommand
|
||||||
, m_editor(editor)
|
, m_editor(editor)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
PasteEntityCommand(WorldEditor& editor, Blob& blob)
|
PasteEntityCommand(WorldEditor& editor, OutputBlob& blob)
|
||||||
: m_blob(blob, editor.getAllocator())
|
: m_blob(blob, editor.getAllocator())
|
||||||
, m_editor(editor)
|
, m_editor(editor)
|
||||||
, m_position(editor.getCameraRaycastHit())
|
, m_position(editor.getCameraRaycastHit())
|
||||||
|
@ -160,11 +160,11 @@ class PasteEntityCommand : public IEditorCommand
|
||||||
serializer.serialize("pos_y", m_position.y);
|
serializer.serialize("pos_y", m_position.y);
|
||||||
serializer.serialize("pos_z", m_position.z);
|
serializer.serialize("pos_z", m_position.z);
|
||||||
serializer.serialize("entity", m_entity.index);
|
serializer.serialize("entity", m_entity.index);
|
||||||
serializer.serialize("size", m_blob.getBufferSize());
|
serializer.serialize("size", m_blob.getSize());
|
||||||
serializer.beginArray("data");
|
serializer.beginArray("data");
|
||||||
for (int i = 0; i < m_blob.getBufferSize(); ++i)
|
for (int i = 0; i < m_blob.getSize(); ++i)
|
||||||
{
|
{
|
||||||
serializer.serializeArrayItem((int32_t)m_blob.getBuffer()[i]);
|
serializer.serializeArrayItem((int32_t)((const uint8_t*)m_blob.getData())[i]);
|
||||||
}
|
}
|
||||||
serializer.endArray();
|
serializer.endArray();
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,8 @@ class PasteEntityCommand : public IEditorCommand
|
||||||
int size;
|
int size;
|
||||||
serializer.deserialize("size", size, 0);
|
serializer.deserialize("size", size, 0);
|
||||||
serializer.deserializeArrayBegin("data");
|
serializer.deserializeArrayBegin("data");
|
||||||
m_blob.clearBuffer();
|
m_blob.clear();
|
||||||
for (int i = 0; i < m_blob.getBufferSize(); ++i)
|
for (int i = 0; i < m_blob.getSize(); ++i)
|
||||||
{
|
{
|
||||||
int32_t data;
|
int32_t data;
|
||||||
serializer.deserializeArrayItem(data, 0);
|
serializer.deserializeArrayItem(data, 0);
|
||||||
|
@ -217,7 +217,7 @@ class PasteEntityCommand : public IEditorCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Blob m_blob;
|
OutputBlob m_blob;
|
||||||
WorldEditor& m_editor;
|
WorldEditor& m_editor;
|
||||||
Vec3 m_position;
|
Vec3 m_position;
|
||||||
Entity m_entity;
|
Entity m_entity;
|
||||||
|
@ -427,10 +427,10 @@ class RemoveArrayPropertyItemCommand : public IEditorCommand
|
||||||
virtual void undo() override
|
virtual void undo() override
|
||||||
{
|
{
|
||||||
m_descriptor->addArrayItem(m_component, m_index);
|
m_descriptor->addArrayItem(m_component, m_index);
|
||||||
m_old_values.rewindForRead();
|
InputBlob old_values(m_old_values.getData(), m_old_values.getSize());
|
||||||
for(int i = 0, c = m_descriptor->getChildren().size(); i < c; ++i)
|
for(int i = 0, c = m_descriptor->getChildren().size(); i < c; ++i)
|
||||||
{
|
{
|
||||||
m_descriptor->getChildren()[i]->set(m_component, m_index, m_old_values);
|
m_descriptor->getChildren()[i]->set(m_component, m_index, old_values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ class RemoveArrayPropertyItemCommand : public IEditorCommand
|
||||||
Component m_component;
|
Component m_component;
|
||||||
int m_index;
|
int m_index;
|
||||||
const IArrayDescriptor* m_descriptor;
|
const IArrayDescriptor* m_descriptor;
|
||||||
Blob m_old_values;
|
OutputBlob m_old_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -577,9 +577,9 @@ class SetPropertyCommand : public IEditorCommand
|
||||||
serializer.serialize("component_index", m_component.index);
|
serializer.serialize("component_index", m_component.index);
|
||||||
serializer.serialize("component_type", m_component.type);
|
serializer.serialize("component_type", m_component.type);
|
||||||
serializer.beginArray("data");
|
serializer.beginArray("data");
|
||||||
for (int i = 0; i < m_new_value.getBufferSize(); ++i)
|
for (int i = 0; i < m_new_value.getSize(); ++i)
|
||||||
{
|
{
|
||||||
serializer.serializeArrayItem((int)m_new_value.getBuffer()[i]);
|
serializer.serializeArrayItem((int)((const uint8_t*)m_new_value.getData())[i]);
|
||||||
}
|
}
|
||||||
serializer.endArray();
|
serializer.endArray();
|
||||||
serializer.serialize("property_name_hash", m_property_descriptor->getNameHash());
|
serializer.serialize("property_name_hash", m_property_descriptor->getNameHash());
|
||||||
|
@ -595,7 +595,7 @@ class SetPropertyCommand : public IEditorCommand
|
||||||
m_component.entity.universe = m_editor.getEngine().getUniverse();
|
m_component.entity.universe = m_editor.getEngine().getUniverse();
|
||||||
m_component.scene = m_editor.getEngine().getSceneByComponentType(m_component.type);
|
m_component.scene = m_editor.getEngine().getSceneByComponentType(m_component.type);
|
||||||
serializer.deserializeArrayBegin("data");
|
serializer.deserializeArrayBegin("data");
|
||||||
m_new_value.clearBuffer();
|
m_new_value.clear();
|
||||||
while (!serializer.isArrayEnd())
|
while (!serializer.isArrayEnd())
|
||||||
{
|
{
|
||||||
int data;
|
int data;
|
||||||
|
@ -611,15 +611,15 @@ class SetPropertyCommand : public IEditorCommand
|
||||||
|
|
||||||
virtual void execute() override
|
virtual void execute() override
|
||||||
{
|
{
|
||||||
m_new_value.rewindForRead();
|
InputBlob blob(m_new_value);
|
||||||
set(m_new_value);
|
set(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void undo() override
|
virtual void undo() override
|
||||||
{
|
{
|
||||||
m_old_value.rewindForRead();
|
InputBlob blob(m_old_value);
|
||||||
set(m_old_value);
|
set(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ class SetPropertyCommand : public IEditorCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void set(Blob& stream)
|
void set(InputBlob& stream)
|
||||||
{
|
{
|
||||||
uint32_t template_hash = m_editor.getEntityTemplateSystem().getTemplate(m_component.entity);
|
uint32_t template_hash = m_editor.getEntityTemplateSystem().getTemplate(m_component.entity);
|
||||||
if (template_hash)
|
if (template_hash)
|
||||||
|
@ -651,7 +651,7 @@ class SetPropertyCommand : public IEditorCommand
|
||||||
const Array<Entity>& entities = m_editor.getEntityTemplateSystem().getInstances(template_hash);
|
const Array<Entity>& entities = m_editor.getEntityTemplateSystem().getInstances(template_hash);
|
||||||
for (int i = 0, c = entities.size(); i < c; ++i)
|
for (int i = 0, c = entities.size(); i < c; ++i)
|
||||||
{
|
{
|
||||||
stream.rewindForRead();
|
stream.rewind();
|
||||||
const WorldEditor::ComponentList& cmps = m_editor.getComponents(entities[i]);
|
const WorldEditor::ComponentList& cmps = m_editor.getComponents(entities[i]);
|
||||||
for (int j = 0, cj = cmps.size(); j < cj; ++j)
|
for (int j = 0, cj = cmps.size(); j < cj; ++j)
|
||||||
{
|
{
|
||||||
|
@ -687,8 +687,8 @@ class SetPropertyCommand : public IEditorCommand
|
||||||
private:
|
private:
|
||||||
WorldEditor& m_editor;
|
WorldEditor& m_editor;
|
||||||
Component m_component;
|
Component m_component;
|
||||||
Blob m_new_value;
|
OutputBlob m_new_value;
|
||||||
Blob m_old_value;
|
OutputBlob m_old_value;
|
||||||
int m_index;
|
int m_index;
|
||||||
const IPropertyDescriptor* m_property_descriptor;
|
const IPropertyDescriptor* m_property_descriptor;
|
||||||
};
|
};
|
||||||
|
@ -887,7 +887,7 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
virtual void execute() override
|
virtual void execute() override
|
||||||
{
|
{
|
||||||
m_positons_rotations.clear();
|
m_positons_rotations.clear();
|
||||||
m_old_values.clearBuffer();
|
m_old_values.clear();
|
||||||
for (int i = 0; i < m_entities.size(); ++i)
|
for (int i = 0; i < m_entities.size(); ++i)
|
||||||
{
|
{
|
||||||
const WorldEditor::ComponentList& cmps = m_editor.getComponents(m_entities[i]);
|
const WorldEditor::ComponentList& cmps = m_editor.getComponents(m_entities[i]);
|
||||||
|
@ -925,18 +925,18 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
virtual void undo() override
|
virtual void undo() override
|
||||||
{
|
{
|
||||||
const Array<IScene*>& scenes = m_editor.getEngine().getScenes();
|
const Array<IScene*>& scenes = m_editor.getEngine().getScenes();
|
||||||
m_old_values.rewindForRead();
|
InputBlob blob(m_old_values);
|
||||||
for (int i = 0; i < m_entities.size(); ++i)
|
for (int i = 0; i < m_entities.size(); ++i)
|
||||||
{
|
{
|
||||||
Entity new_entity = m_editor.getEngine().getUniverse()->createEntity();
|
Entity new_entity = m_editor.getEngine().getUniverse()->createEntity();
|
||||||
new_entity.setPosition(m_positons_rotations[i].m_position);
|
new_entity.setPosition(m_positons_rotations[i].m_position);
|
||||||
new_entity.setRotation(m_positons_rotations[i].m_rotation);
|
new_entity.setRotation(m_positons_rotations[i].m_rotation);
|
||||||
int cmps_count;
|
int cmps_count;
|
||||||
m_old_values.read(cmps_count);
|
blob.read(cmps_count);
|
||||||
for (int j = cmps_count - 1; j >= 0; --j)
|
for (int j = cmps_count - 1; j >= 0; --j)
|
||||||
{
|
{
|
||||||
Component::Type cmp_type;
|
Component::Type cmp_type;
|
||||||
m_old_values.read(cmp_type);
|
blob.read(cmp_type);
|
||||||
Component new_component;
|
Component new_component;
|
||||||
for (int i = 0; i < scenes.size(); ++i)
|
for (int i = 0; i < scenes.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -954,7 +954,7 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
|
|
||||||
for (int k = 0; k < props.size(); ++k)
|
for (int k = 0; k < props.size(); ++k)
|
||||||
{
|
{
|
||||||
props[k]->set(new_component, m_old_values);
|
props[k]->set(new_component, blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -982,7 +982,7 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
WorldEditorImpl& m_editor;
|
WorldEditorImpl& m_editor;
|
||||||
Array<Entity> m_entities;
|
Array<Entity> m_entities;
|
||||||
Array<PositionRotation> m_positons_rotations;
|
Array<PositionRotation> m_positons_rotations;
|
||||||
Blob m_old_values;
|
OutputBlob m_old_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1039,13 +1039,13 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_old_values.rewindForRead();
|
InputBlob blob(m_old_values);
|
||||||
if (props_index >= 0)
|
if (props_index >= 0)
|
||||||
{
|
{
|
||||||
const Array<IPropertyDescriptor*>& props = m_editor.m_component_properties.at(props_index);
|
const Array<IPropertyDescriptor*>& props = m_editor.m_component_properties.at(props_index);
|
||||||
for (int i = 0; i < props.size(); ++i)
|
for (int i = 0; i < props.size(); ++i)
|
||||||
{
|
{
|
||||||
props[i]->set(m_component, m_old_values);
|
props[i]->set(m_component, blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,13 +1059,13 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
Component cmp_new = scenes[scene_index]->createComponent(m_component.type, entities[entity_index]);
|
Component cmp_new = scenes[scene_index]->createComponent(m_component.type, entities[entity_index]);
|
||||||
if (cmp_new.isValid())
|
if (cmp_new.isValid())
|
||||||
{
|
{
|
||||||
m_old_values.rewindForRead();
|
InputBlob blob(m_old_values);
|
||||||
if (props_index >= 0)
|
if (props_index >= 0)
|
||||||
{
|
{
|
||||||
const Array<IPropertyDescriptor*>& props = m_editor.m_component_properties.at(props_index);
|
const Array<IPropertyDescriptor*>& props = m_editor.m_component_properties.at(props_index);
|
||||||
for (int i = 0; i < props.size(); ++i)
|
for (int i = 0; i < props.size(); ++i)
|
||||||
{
|
{
|
||||||
props[i]->set(cmp_new, m_old_values);
|
props[i]->set(cmp_new, blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1117,7 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
private:
|
private:
|
||||||
Component m_component;
|
Component m_component;
|
||||||
WorldEditorImpl& m_editor;
|
WorldEditorImpl& m_editor;
|
||||||
Blob m_old_values;
|
OutputBlob m_old_values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1565,16 +1565,16 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
|
|
||||||
void save(FS::IFile& file)
|
void save(FS::IFile& file)
|
||||||
{
|
{
|
||||||
Blob blob(m_allocator);
|
OutputBlob blob(m_allocator);
|
||||||
blob.reserve(1 << 20);
|
blob.reserve(1 << 20);
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
blob.write(hash);
|
blob.write(hash);
|
||||||
m_engine->serialize(blob);
|
m_engine->serialize(blob);
|
||||||
m_template_system->serialize(blob);
|
m_template_system->serialize(blob);
|
||||||
hash = crc32(blob.getBuffer() + sizeof(hash), blob.getBufferSize() - sizeof(hash));
|
hash = crc32((const uint8_t*)blob.getData() + sizeof(hash), blob.getSize() - sizeof(hash));
|
||||||
(*(uint32_t*)blob.getBuffer()) = hash;
|
(*(uint32_t*)blob.getData()) = hash;
|
||||||
g_log_info.log("editor") << "universe saved";
|
g_log_info.log("editor") << "universe saved";
|
||||||
file.write(blob.getBuffer(), blob.getBufferSize());
|
file.write(blob.getData(), blob.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1827,7 +1827,7 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
if(!m_selected_entities.empty())
|
if(!m_selected_entities.empty())
|
||||||
{
|
{
|
||||||
Entity entity = m_selected_entities[0];
|
Entity entity = m_selected_entities[0];
|
||||||
m_copy_buffer.clearBuffer();
|
m_copy_buffer.clear();
|
||||||
const WorldEditor::ComponentList& cmps = getComponents(entity);
|
const WorldEditor::ComponentList& cmps = getComponents(entity);
|
||||||
int32_t count = cmps.size();
|
int32_t count = cmps.size();
|
||||||
m_copy_buffer.write(count);
|
m_copy_buffer.write(count);
|
||||||
|
@ -1868,13 +1868,13 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
const Array<IPropertyDescriptor*>& properties = getPropertyDescriptors(src.type);
|
const Array<IPropertyDescriptor*>& properties = getPropertyDescriptors(src.type);
|
||||||
Blob stream(m_allocator);
|
OutputBlob stream(m_allocator);
|
||||||
for (int i = 0; i < properties.size(); ++i)
|
for (int i = 0; i < properties.size(); ++i)
|
||||||
{
|
{
|
||||||
stream.clearBuffer();
|
stream.clear();
|
||||||
properties[i]->get(src, stream);
|
properties[i]->get(src, stream);
|
||||||
stream.rewindForRead();
|
InputBlob blob(stream.getData(), stream.getSize());
|
||||||
properties[i]->set(clone, stream);
|
properties[i]->set(clone, blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1963,11 +1963,10 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
m_components.reserve(5000);
|
m_components.reserve(5000);
|
||||||
Timer* timer = Timer::create(m_allocator);
|
Timer* timer = Timer::create(m_allocator);
|
||||||
g_log_info.log("editor") << "Parsing universe...";
|
g_log_info.log("editor") << "Parsing universe...";
|
||||||
Blob blob(m_allocator);
|
InputBlob blob(file.getBuffer(), file.size());
|
||||||
blob.create(file.getBuffer(), file.size());
|
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
blob.read(hash);
|
blob.read(hash);
|
||||||
if (crc32(blob.getData() + sizeof(hash), blob.getBufferSize() - sizeof(hash)) != hash)
|
if (crc32((const uint8_t*)blob.getData() + sizeof(hash), blob.getSize() - sizeof(hash)) != hash)
|
||||||
{
|
{
|
||||||
Timer::destroy(timer);
|
Timer::destroy(timer);
|
||||||
g_log_error.log("editor") << "Corrupted file.";
|
g_log_error.log("editor") << "Corrupted file.";
|
||||||
|
@ -2712,7 +2711,7 @@ struct WorldEditorImpl : public WorldEditor
|
||||||
Array<IEditorCommand*> m_undo_stack;
|
Array<IEditorCommand*> m_undo_stack;
|
||||||
AssociativeArray<uint32_t, EditorCommandCreator> m_editor_command_creators;
|
AssociativeArray<uint32_t, EditorCommandCreator> m_editor_command_creators;
|
||||||
int m_undo_index;
|
int m_undo_index;
|
||||||
Blob m_copy_buffer;
|
OutputBlob m_copy_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2740,20 +2739,20 @@ void WorldEditor::destroy(WorldEditor* editor)
|
||||||
|
|
||||||
void PasteEntityCommand::execute()
|
void PasteEntityCommand::execute()
|
||||||
{
|
{
|
||||||
m_blob.rewindForRead();
|
InputBlob blob(m_blob.getData(), m_blob.getSize());
|
||||||
Entity new_entity = m_editor.getEngine().getUniverse()->createEntity();
|
Entity new_entity = m_editor.getEngine().getUniverse()->createEntity();
|
||||||
new_entity.setPosition(m_position);
|
new_entity.setPosition(m_position);
|
||||||
int32_t count;
|
int32_t count;
|
||||||
m_blob.read(count);
|
blob.read(count);
|
||||||
for(int i = 0; i < count; ++i)
|
for(int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
m_blob.read(type);
|
blob.read(type);
|
||||||
Component cmp = static_cast<WorldEditorImpl&>(m_editor).createComponent(type, new_entity);
|
Component cmp = static_cast<WorldEditorImpl&>(m_editor).createComponent(type, new_entity);
|
||||||
Array<IPropertyDescriptor*>& props = m_editor.getPropertyDescriptors(type);
|
Array<IPropertyDescriptor*>& props = m_editor.getPropertyDescriptors(type);
|
||||||
for(int j = 0; j < props.size(); ++j)
|
for(int j = 0; j < props.size(); ++j)
|
||||||
{
|
{
|
||||||
props[j]->set(cmp, m_blob);
|
props[j]->set(cmp, blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_entity = new_entity;
|
m_entity = new_entity;
|
||||||
|
|
|
@ -312,7 +312,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void serialize(Blob& serializer) override
|
virtual void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
SerializedEngineHeader header;
|
SerializedEngineHeader header;
|
||||||
header.m_magic = SERIALIZED_ENGINE_MAGIC; // == '_LEN'
|
header.m_magic = SERIALIZED_ENGINE_MAGIC; // == '_LEN'
|
||||||
|
@ -331,7 +331,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool deserialize(Blob& serializer) override
|
virtual bool deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
SerializedEngineHeader header;
|
SerializedEngineHeader header;
|
||||||
serializer.read(header);
|
serializer.read(header);
|
||||||
|
|
|
@ -18,12 +18,13 @@ namespace Lumix
|
||||||
class Manager;
|
class Manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Blob;
|
class InputBlob;
|
||||||
class EditorServer;
|
class EditorServer;
|
||||||
class InputSystem;
|
class InputSystem;
|
||||||
class IPlugin;
|
class IPlugin;
|
||||||
class IScene;
|
class IScene;
|
||||||
class JsonSerializer;
|
class JsonSerializer;
|
||||||
|
class OutputBlob;
|
||||||
class PluginManager;
|
class PluginManager;
|
||||||
class Renderer;
|
class Renderer;
|
||||||
class ResourceManager;
|
class ResourceManager;
|
||||||
|
@ -60,8 +61,8 @@ namespace Lumix
|
||||||
|
|
||||||
virtual const char* getBasePath() const = 0;
|
virtual const char* getBasePath() const = 0;
|
||||||
virtual void update(bool is_game_running) = 0;
|
virtual void update(bool is_game_running) = 0;
|
||||||
virtual void serialize(Blob& serializer) = 0;
|
virtual void serialize(OutputBlob& serializer) = 0;
|
||||||
virtual bool deserialize(Blob& serializer) = 0;
|
virtual bool deserialize(InputBlob& serializer) = 0;
|
||||||
virtual float getFPS() const = 0;
|
virtual float getFPS() const = 0;
|
||||||
virtual float getLastTimeDelta() = 0;
|
virtual float getLastTimeDelta() = 0;
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
|
|
||||||
namespace Lumix
|
namespace Lumix
|
||||||
{
|
{
|
||||||
class Blob;
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
class InputBlob;
|
||||||
class IPlugin;
|
class IPlugin;
|
||||||
|
class OutputBlob;
|
||||||
class Universe;
|
class Universe;
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,8 +21,8 @@ namespace Lumix
|
||||||
|
|
||||||
virtual Component createComponent(uint32_t, const Entity&) = 0;
|
virtual Component createComponent(uint32_t, const Entity&) = 0;
|
||||||
virtual void destroyComponent(const Component& component) = 0;
|
virtual void destroyComponent(const Component& component) = 0;
|
||||||
virtual void serialize(Blob& serializer) = 0;
|
virtual void serialize(OutputBlob& serializer) = 0;
|
||||||
virtual void deserialize(Blob& serializer) = 0;
|
virtual void deserialize(InputBlob& serializer) = 0;
|
||||||
virtual IPlugin& getPlugin() const = 0;
|
virtual IPlugin& getPlugin() const = 0;
|
||||||
virtual void update(float time_delta) = 0;
|
virtual void update(float time_delta) = 0;
|
||||||
virtual bool ownComponentType(uint32_t type) const = 0;
|
virtual bool ownComponentType(uint32_t type) const = 0;
|
||||||
|
@ -35,8 +36,8 @@ namespace Lumix
|
||||||
|
|
||||||
virtual bool create() = 0;
|
virtual bool create() = 0;
|
||||||
virtual void destroy() = 0;
|
virtual void destroy() = 0;
|
||||||
virtual void serialize(Blob&) {}
|
virtual void serialize(OutputBlob&) {}
|
||||||
virtual void deserialize(Blob&) {}
|
virtual void deserialize(InputBlob&) {}
|
||||||
virtual void update(float) {}
|
virtual void update(float) {}
|
||||||
virtual const char* getName() const = 0;
|
virtual const char* getName() const = 0;
|
||||||
virtual void sendMessage(const char*) {};
|
virtual void sendMessage(const char*) {};
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PluginManager::serialize(Blob& serializer)
|
void PluginManager::serialize(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
PluginManagerImpl::PluginList& plugins = m_impl->m_plugins;
|
PluginManagerImpl::PluginList& plugins = m_impl->m_plugins;
|
||||||
for(int i = 0, c = plugins.size(); i < c; ++i)
|
for(int i = 0, c = plugins.size(); i < c; ++i)
|
||||||
|
@ -41,7 +41,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PluginManager::deserialize(Blob& serializer)
|
void PluginManager::deserialize(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
PluginManagerImpl::PluginList& plugins = m_impl->m_plugins;
|
PluginManagerImpl::PluginList& plugins = m_impl->m_plugins;
|
||||||
for(int i = 0, c = plugins.size(); i < c; ++i)
|
for(int i = 0, c = plugins.size(); i < c; ++i)
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
namespace Lumix
|
namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
class Blob;
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
class InputBlob;
|
||||||
class IPlugin;
|
class IPlugin;
|
||||||
class JsonSerializer;
|
class JsonSerializer;
|
||||||
|
class OutputBlob;
|
||||||
class Universe;
|
class Universe;
|
||||||
|
|
||||||
class LUMIX_ENGINE_API PluginManager
|
class LUMIX_ENGINE_API PluginManager
|
||||||
|
@ -24,8 +25,8 @@ namespace Lumix
|
||||||
IPlugin* load(const char* path);
|
IPlugin* load(const char* path);
|
||||||
void addPlugin(IPlugin* plugin);
|
void addPlugin(IPlugin* plugin);
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
void serialize(Blob& serializer);
|
void serialize(OutputBlob& serializer);
|
||||||
void deserialize(Blob& serializer);
|
void deserialize(InputBlob& serializer);
|
||||||
IPlugin* getPlugin(const char* name);
|
IPlugin* getPlugin(const char* name);
|
||||||
const Array<IPlugin*>& getPlugins() const;
|
const Array<IPlugin*>& getPlugins() const;
|
||||||
|
|
||||||
|
|
|
@ -439,13 +439,13 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void serializeCameras(Blob& serializer)
|
void serializeCameras(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_cameras.size());
|
serializer.write((int32_t)m_cameras.size());
|
||||||
serializer.write(&m_cameras[0], sizeof(m_cameras[0]) * m_cameras.size());
|
serializer.write(&m_cameras[0], sizeof(m_cameras[0]) * m_cameras.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void serializeLights(Blob& serializer)
|
void serializeLights(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_lights.size());
|
serializer.write((int32_t)m_lights.size());
|
||||||
if (!m_lights.empty())
|
if (!m_lights.empty())
|
||||||
|
@ -454,7 +454,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void serializeRenderables(Blob& serializer)
|
void serializeRenderables(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_renderables.size());
|
serializer.write((int32_t)m_renderables.size());
|
||||||
for (int i = 0; i < m_renderables.size(); ++i)
|
for (int i = 0; i < m_renderables.size(); ++i)
|
||||||
|
@ -468,7 +468,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void serializeTerrains(Blob& serializer)
|
void serializeTerrains(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_terrains.size());
|
serializer.write((int32_t)m_terrains.size());
|
||||||
for (int i = 0; i < m_terrains.size(); ++i)
|
for (int i = 0; i < m_terrains.size(); ++i)
|
||||||
|
@ -485,7 +485,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void serialize(Blob& serializer) override
|
virtual void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
serializeCameras(serializer);
|
serializeCameras(serializer);
|
||||||
serializeRenderables(serializer);
|
serializeRenderables(serializer);
|
||||||
|
@ -493,7 +493,7 @@ namespace Lumix
|
||||||
serializeTerrains(serializer);
|
serializeTerrains(serializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserializeCameras(Blob& serializer)
|
void deserializeCameras(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t size;
|
int32_t size;
|
||||||
serializer.read(size);
|
serializer.read(size);
|
||||||
|
@ -509,7 +509,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserializeRenderables(Blob& serializer)
|
void deserializeRenderables(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
serializer.read(size);
|
serializer.read(size);
|
||||||
|
@ -549,7 +549,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserializeLights(Blob& serializer)
|
void deserializeLights(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
serializer.read(size);
|
serializer.read(size);
|
||||||
|
@ -568,7 +568,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deserializeTerrains(Blob& serializer)
|
void deserializeTerrains(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
serializer.read(size);
|
serializer.read(size);
|
||||||
|
@ -595,7 +595,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void deserialize(Blob& serializer) override
|
virtual void deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
deserializeCameras(serializer);
|
deserializeCameras(serializer);
|
||||||
deserializeRenderables(serializer);
|
deserializeRenderables(serializer);
|
||||||
|
|
|
@ -576,7 +576,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terrain::deserialize(Blob& serializer, Universe& universe, RenderScene& scene, int index)
|
void Terrain::deserialize(InputBlob& serializer, Universe& universe, RenderScene& scene, int index)
|
||||||
{
|
{
|
||||||
serializer.read(m_entity.index);
|
serializer.read(m_entity.index);
|
||||||
m_entity.universe = &universe;
|
m_entity.universe = &universe;
|
||||||
|
@ -608,7 +608,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Terrain::serialize(Blob& serializer)
|
void Terrain::serialize(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
serializer.write(m_entity.index);
|
serializer.write(m_entity.index);
|
||||||
serializer.write(m_layer_mask);
|
serializer.write(m_layer_mask);
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Blob;
|
class OutputBlob;
|
||||||
class Material;
|
class Material;
|
||||||
class Mesh;
|
class Mesh;
|
||||||
class PipelineInstance;
|
class PipelineInstance;
|
||||||
|
@ -81,8 +81,8 @@ class Terrain
|
||||||
void render(Renderer& renderer, PipelineInstance& pipeline, const Vec3& camera_pos);
|
void render(Renderer& renderer, PipelineInstance& pipeline, const Vec3& camera_pos);
|
||||||
RayCastModelHit castRay(const Vec3& origin, const Vec3& dir);
|
RayCastModelHit castRay(const Vec3& origin, const Vec3& dir);
|
||||||
int64_t getLayerMask() const { return m_layer_mask; }
|
int64_t getLayerMask() const { return m_layer_mask; }
|
||||||
void serialize(Blob& serializer);
|
void serialize(OutputBlob& serializer);
|
||||||
void deserialize(Blob& serializer, Universe& universe, RenderScene& scene, int index);
|
void deserialize(InputBlob& serializer, Universe& universe, RenderScene& scene, int index);
|
||||||
void setXZScale(float scale) { m_xz_scale = scale; }
|
void setXZScale(float scale) { m_xz_scale = scale; }
|
||||||
float getXZScale() const { return m_xz_scale; }
|
float getXZScale() const { return m_xz_scale; }
|
||||||
void setYScale(float scale) { m_y_scale = scale; }
|
void setYScale(float scale) { m_y_scale = scale; }
|
||||||
|
|
|
@ -830,7 +830,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void serializeActor(Blob& serializer, int idx)
|
void serializeActor(OutputBlob& serializer, int idx)
|
||||||
{
|
{
|
||||||
physx::PxShape* shapes;
|
physx::PxShape* shapes;
|
||||||
if (m_actors[idx]->m_physx_actor->getNbShapes() == 1 && m_actors[idx]->m_physx_actor->getShapes(&shapes, 1))
|
if (m_actors[idx]->m_physx_actor->getNbShapes() == 1 && m_actors[idx]->m_physx_actor->getShapes(&shapes, 1))
|
||||||
|
@ -856,7 +856,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void deserializeActor(Blob& serializer, int idx)
|
void deserializeActor(InputBlob& serializer, int idx)
|
||||||
{
|
{
|
||||||
ActorType type;
|
ActorType type;
|
||||||
serializer.read((int32_t&)type);
|
serializer.read((int32_t&)type);
|
||||||
|
@ -900,7 +900,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void serialize(Blob& serializer) override
|
virtual void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_actors.size());
|
serializer.write((int32_t)m_actors.size());
|
||||||
for (int i = 0; i < m_actors.size(); ++i)
|
for (int i = 0; i < m_actors.size(); ++i)
|
||||||
|
@ -938,7 +938,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void deserializeActors(Blob& serializer)
|
void deserializeActors(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t count;
|
int32_t count;
|
||||||
m_dynamic_actors.clear();
|
m_dynamic_actors.clear();
|
||||||
|
@ -975,7 +975,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void deserializeControllers(Blob& serializer)
|
void deserializeControllers(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t count;
|
int32_t count;
|
||||||
serializer.read(count);
|
serializer.read(count);
|
||||||
|
@ -1016,7 +1016,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void deserializeTerrains(Blob& serializer)
|
void deserializeTerrains(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t count;
|
int32_t count;
|
||||||
serializer.read(count);
|
serializer.read(count);
|
||||||
|
@ -1060,7 +1060,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void deserialize(Blob& serializer) override
|
virtual void deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
deserializeActors(serializer);
|
deserializeActors(serializer);
|
||||||
deserializeControllers(serializer);
|
deserializeControllers(serializer);
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Lumix
|
||||||
virtual IPlugin& getPlugin() const;
|
virtual IPlugin& getPlugin() const;
|
||||||
|
|
||||||
|
|
||||||
void deserialize(Blob& serializer) override
|
void deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
stopAll();
|
stopAll();
|
||||||
int32_t count;
|
int32_t count;
|
||||||
|
@ -277,7 +277,7 @@ namespace Lumix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void serialize(Blob& serializer) override
|
void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_script_entities.size());
|
serializer.write((int32_t)m_script_entities.size());
|
||||||
for (int i = 0; i < m_script_entities.size(); ++i)
|
for (int i = 0; i < m_script_entities.size(); ++i)
|
||||||
|
|
|
@ -5,15 +5,103 @@
|
||||||
void UT_blob(const char* params)
|
void UT_blob(const char* params)
|
||||||
{
|
{
|
||||||
Lumix::DefaultAllocator allocator;
|
Lumix::DefaultAllocator allocator;
|
||||||
/*
|
|
||||||
Lumix::Blob blob(allocator);
|
Lumix::OutputBlob blob(allocator);
|
||||||
char data[] = "abcdef";
|
|
||||||
blob.create(data, sizeof(data));
|
LUMIX_EXPECT_EQ(blob.getSize(), 0);
|
||||||
blob.
|
bool b = false;
|
||||||
*/
|
blob.reserve(sizeof(b));
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), 0);
|
||||||
|
blob.write(b);
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), sizeof(b));
|
||||||
|
blob.reserve(sizeof(b));
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), sizeof(b));
|
||||||
|
|
||||||
// TODO refactor blob itself
|
char c = 'A';
|
||||||
ASSERT(false); // TODO
|
blob.reserve(sizeof(b) + sizeof(c));
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), sizeof(b));
|
||||||
|
blob.reserve(0);
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), sizeof(b));
|
||||||
|
blob.write(c);
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), sizeof(b) + sizeof(c));
|
||||||
|
|
||||||
|
int32_t i = 123456;
|
||||||
|
blob.write(i);
|
||||||
|
|
||||||
|
uint32_t ui = 0xABCDEF01;
|
||||||
|
blob.write(ui);
|
||||||
|
|
||||||
|
float f = Lumix::Math::PI;
|
||||||
|
blob.write(f);
|
||||||
|
|
||||||
|
blob.writeString("test string");
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
char c;
|
||||||
|
};
|
||||||
|
S s;
|
||||||
|
s.x = 1;
|
||||||
|
s.y = 2;
|
||||||
|
s.c = 'Q';
|
||||||
|
blob.write(s);
|
||||||
|
|
||||||
|
Lumix::InputBlob input(blob);
|
||||||
|
bool b2;
|
||||||
|
input.read(b2);
|
||||||
|
|
||||||
|
char c2;
|
||||||
|
input.read(c2);
|
||||||
|
|
||||||
|
int32_t i2;
|
||||||
|
input.read(i2);
|
||||||
|
|
||||||
|
uint32_t ui2;
|
||||||
|
input.read(ui2);
|
||||||
|
|
||||||
|
float f2;
|
||||||
|
input.read(f2);
|
||||||
|
|
||||||
|
char tmp[20];
|
||||||
|
input.readString(tmp, sizeof(tmp));
|
||||||
|
|
||||||
|
S s2;
|
||||||
|
input.read(s2);
|
||||||
|
LUMIX_EXPECT_EQ(b, b2);
|
||||||
|
LUMIX_EXPECT_EQ(c, c2);
|
||||||
|
LUMIX_EXPECT_EQ(i, i2);
|
||||||
|
LUMIX_EXPECT_EQ(ui, ui2);
|
||||||
|
LUMIX_EXPECT_EQ(f, f2);
|
||||||
|
LUMIX_EXPECT_EQ(strcmp(tmp, "test string"), 0);
|
||||||
|
LUMIX_EXPECT_EQ(memcmp(&s, &s2, sizeof(s)), 0);
|
||||||
|
|
||||||
|
input.rewind();
|
||||||
|
input.read(b2);
|
||||||
|
input.read(c2);
|
||||||
|
input.read(i2);
|
||||||
|
input.read(ui2);
|
||||||
|
input.read(f2);
|
||||||
|
input.readString(tmp, sizeof(tmp));
|
||||||
|
input.read(s2);
|
||||||
|
LUMIX_EXPECT_EQ(b, b2);
|
||||||
|
LUMIX_EXPECT_EQ(c, c2);
|
||||||
|
LUMIX_EXPECT_EQ(i, i2);
|
||||||
|
LUMIX_EXPECT_EQ(ui, ui2);
|
||||||
|
LUMIX_EXPECT_EQ(f, f2);
|
||||||
|
LUMIX_EXPECT_EQ(strcmp(tmp, "test string"), 0);
|
||||||
|
LUMIX_EXPECT_EQ(memcmp(&s, &s2, sizeof(s)), 0);
|
||||||
|
|
||||||
|
LUMIX_EXPECT_EQ(input.getSize(), blob.getSize());
|
||||||
|
input.setPosition(sizeof(b2) + sizeof(c2) + sizeof(i2));
|
||||||
|
input.read(ui2);
|
||||||
|
LUMIX_EXPECT_EQ(ui, ui2);
|
||||||
|
|
||||||
|
blob.clear();
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), 0);
|
||||||
|
blob.write(b);
|
||||||
|
LUMIX_EXPECT_EQ(blob.getSize(), sizeof(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TEST("unit_tests/core/blob", UT_blob, "")
|
REGISTER_TEST("unit_tests/core/blob", UT_blob, "")
|
|
@ -141,7 +141,7 @@ class HierarchyImpl : public Hierarchy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void serialize(Blob& serializer) override
|
virtual void serialize(OutputBlob& serializer) override
|
||||||
{
|
{
|
||||||
int size = m_parents.size();
|
int size = m_parents.size();
|
||||||
serializer.write((int32_t)size);
|
serializer.write((int32_t)size);
|
||||||
|
@ -155,7 +155,7 @@ class HierarchyImpl : public Hierarchy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void deserialize(Blob& serializer) override
|
virtual void deserialize(InputBlob& serializer) override
|
||||||
{
|
{
|
||||||
int32_t size;
|
int32_t size;
|
||||||
serializer.read(size);
|
serializer.read(size);
|
||||||
|
|
|
@ -9,7 +9,8 @@ namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Blob;
|
class InputBlob;
|
||||||
|
class OutputBlob;
|
||||||
|
|
||||||
|
|
||||||
class Hierarchy
|
class Hierarchy
|
||||||
|
@ -31,8 +32,8 @@ namespace Lumix
|
||||||
|
|
||||||
virtual void setParent(const Entity& child, const Entity& parent) = 0;
|
virtual void setParent(const Entity& child, const Entity& parent) = 0;
|
||||||
virtual Entity getParent(const Entity& child) = 0;
|
virtual Entity getParent(const Entity& child) = 0;
|
||||||
virtual void serialize(Blob& serializer) = 0;
|
virtual void serialize(OutputBlob& serializer) = 0;
|
||||||
virtual void deserialize(Blob& serializer) = 0;
|
virtual void deserialize(InputBlob& serializer) = 0;
|
||||||
virtual Array<Child>* getChildren(const Entity& parent) = 0;
|
virtual Array<Child>* getChildren(const Entity& parent) = 0;
|
||||||
virtual DelegateList<void (const Entity&, const Entity&)>& parentSet() = 0;
|
virtual DelegateList<void (const Entity&, const Entity&)>& parentSet() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,7 +112,7 @@ Entity Universe::getNextEntity(Entity entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Universe::serialize(Blob& serializer)
|
void Universe::serialize(OutputBlob& serializer)
|
||||||
{
|
{
|
||||||
serializer.write((int32_t)m_positions.size());
|
serializer.write((int32_t)m_positions.size());
|
||||||
serializer.write(&m_positions[0].x, sizeof(m_positions[0]) * m_positions.size());
|
serializer.write(&m_positions[0].x, sizeof(m_positions[0]) * m_positions.size());
|
||||||
|
@ -132,7 +132,7 @@ void Universe::serialize(Blob& serializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Universe::deserialize(Blob& serializer)
|
void Universe::deserialize(InputBlob& serializer)
|
||||||
{
|
{
|
||||||
int32_t count;
|
int32_t count;
|
||||||
serializer.read(count);
|
serializer.read(count);
|
||||||
|
|
|
@ -16,9 +16,10 @@ namespace Lumix
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class Blob;
|
class InputBlob;
|
||||||
class Event;
|
class Event;
|
||||||
struct Matrix;
|
struct Matrix;
|
||||||
|
class OutputBlob;
|
||||||
struct Quat;
|
struct Quat;
|
||||||
class Universe;
|
class Universe;
|
||||||
struct Vec3;
|
struct Vec3;
|
||||||
|
@ -51,8 +52,8 @@ class LUMIX_ENGINE_API Universe final
|
||||||
|
|
||||||
Delegate<void(const Component&)>& componentAdded() { return m_component_added; }
|
Delegate<void(const Component&)>& componentAdded() { return m_component_added; }
|
||||||
|
|
||||||
void serialize(Blob& serializer);
|
void serialize(OutputBlob& serializer);
|
||||||
void deserialize(Blob& serializer);
|
void deserialize(InputBlob& serializer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IAllocator& m_allocator;
|
IAllocator& m_allocator;
|
||||||
|
|
|
@ -62,23 +62,23 @@ static const uint32_t SCRIPT_HASH = crc32("script");
|
||||||
#pragma region new_props
|
#pragma region new_props
|
||||||
|
|
||||||
|
|
||||||
void createComponentPropertyEditor(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* property_item);
|
void createComponentPropertyEditor(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* property_item);
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T getPropertyValue(Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, int array_index, Lumix::Blob& stream)
|
T getPropertyValue(Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, int array_index, Lumix::OutputBlob& stream)
|
||||||
{
|
{
|
||||||
T v;
|
T v;
|
||||||
stream.clearBuffer();
|
stream.clear();
|
||||||
desc->get(cmp, array_index, stream);
|
desc->get(cmp, array_index, stream);
|
||||||
stream.rewindForRead();
|
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||||
stream.read(v);
|
blob.read(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PropertyEditor<T> createComponentPropertyEditor(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* item)
|
PropertyEditor<T> createComponentPropertyEditor(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* item)
|
||||||
{
|
{
|
||||||
return PropertyEditor<T>::create(
|
return PropertyEditor<T>::create(
|
||||||
desc->getName(),
|
desc->getName(),
|
||||||
|
@ -90,12 +90,12 @@ PropertyEditor<T> createComponentPropertyEditor(PropertyView& view, int array_in
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
PropertyEditor<const char*> createComponentPropertyEditor<const char*>(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* item)
|
PropertyEditor<const char*> createComponentPropertyEditor<const char*>(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* item)
|
||||||
{
|
{
|
||||||
stream.clearBuffer();
|
stream.clear();
|
||||||
desc->get(cmp, array_index, stream);
|
desc->get(cmp, array_index, stream);
|
||||||
stream.rewindForRead();
|
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||||
return PropertyEditor<const char*>::create(desc->getName(), item, (const char*)stream.getBuffer(), [&view, desc, cmp, array_index](const char* v) { view.getWorldEditor()->setProperty(cmp.type, array_index, *desc, v, strlen(v) + 1); });
|
return PropertyEditor<const char*>::create(desc->getName(), item, (const char*)blob.getData(), [&view, desc, cmp, array_index](const char* v) { view.getWorldEditor()->setProperty(cmp.type, array_index, *desc, v, strlen(v) + 1); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,12 +177,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void createComponentResourcePropertyEdit(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* item)
|
void createComponentResourcePropertyEdit(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* item)
|
||||||
{
|
{
|
||||||
stream.clearBuffer();
|
stream.clear();
|
||||||
desc->get(cmp, array_index, stream);
|
desc->get(cmp, array_index, stream);
|
||||||
stream.rewindForRead();
|
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||||
auto* res = view.getResource((const char*)stream.getBuffer());
|
auto* res = view.getResource((const char*)blob.getData());
|
||||||
auto editor = PropertyEditor<Lumix::Resource*>::create(view, desc->getName(), item, res, [&view, desc, cmp, array_index](const char* v) { view.getWorldEditor()->setProperty(cmp.type, array_index, *desc, v, strlen(v) + 1); });
|
auto editor = PropertyEditor<Lumix::Resource*>::create(view, desc->getName(), item, res, [&view, desc, cmp, array_index](const char* v) { view.getWorldEditor()->setProperty(cmp.type, array_index, *desc, v, strlen(v) + 1); });
|
||||||
auto file_desc = dynamic_cast<Lumix::IFilePropertyDescriptor*>(desc);
|
auto file_desc = dynamic_cast<Lumix::IFilePropertyDescriptor*>(desc);
|
||||||
auto filter = file_desc->getFileType();
|
auto filter = file_desc->getFileType();
|
||||||
|
@ -190,19 +190,19 @@ void createComponentResourcePropertyEdit(PropertyView& view, int array_index, Lu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createComponentFilePropertyEdit(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* item)
|
void createComponentFilePropertyEdit(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* item)
|
||||||
{
|
{
|
||||||
stream.clearBuffer();
|
stream.clear();
|
||||||
desc->get(cmp, array_index, stream);
|
desc->get(cmp, array_index, stream);
|
||||||
stream.rewindForRead();
|
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||||
auto editor = PropertyEditor<Lumix::Path>::create(view, desc->getName(), item, Lumix::Path((const char*)stream.getBuffer()), [&view, desc, cmp, array_index](const char* v) { view.getWorldEditor()->setProperty(cmp.type, array_index, *desc, v, strlen(v) + 1); });
|
auto editor = PropertyEditor<Lumix::Path>::create(view, desc->getName(), item, Lumix::Path((const char*)blob.getData()), [&view, desc, cmp, array_index](const char* v) { view.getWorldEditor()->setProperty(cmp.type, array_index, *desc, v, strlen(v) + 1); });
|
||||||
auto file_desc = dynamic_cast<Lumix::IFilePropertyDescriptor*>(desc);
|
auto file_desc = dynamic_cast<Lumix::IFilePropertyDescriptor*>(desc);
|
||||||
auto filter = file_desc->getFileType();
|
auto filter = file_desc->getFileType();
|
||||||
editor->setFilter(filter);
|
editor->setFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createComponentArrayPropertyEdit(PropertyView& view, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* property_item)
|
void createComponentArrayPropertyEdit(PropertyView& view, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* property_item)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* array_item = new QTreeWidgetItem();
|
QTreeWidgetItem* array_item = new QTreeWidgetItem();
|
||||||
property_item->addChild(array_item);
|
property_item->addChild(array_item);
|
||||||
|
@ -225,7 +225,7 @@ void createComponentArrayPropertyEdit(PropertyView& view, Lumix::IPropertyDescri
|
||||||
array_item->addChild(item);
|
array_item->addChild(item);
|
||||||
item->setText(0, QString::number(array_desc.getCount(cmp) - 1));
|
item->setText(0, QString::number(array_desc.getCount(cmp) - 1));
|
||||||
auto& children = array_desc.getChildren();
|
auto& children = array_desc.getChildren();
|
||||||
Lumix::Blob stream(view.getWorldEditor()->getAllocator());
|
Lumix::OutputBlob stream(view.getWorldEditor()->getAllocator());
|
||||||
for (int i = 0; i < children.size(); ++i)
|
for (int i = 0; i < children.size(); ++i)
|
||||||
{
|
{
|
||||||
createComponentPropertyEditor(view, array_desc.getCount(cmp) - 1, children[i], Lumix::Component(cmp), stream, item);
|
createComponentPropertyEditor(view, array_desc.getCount(cmp) - 1, children[i], Lumix::Component(cmp), stream, item);
|
||||||
|
@ -259,7 +259,7 @@ void createComponentArrayPropertyEdit(PropertyView& view, Lumix::IPropertyDescri
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createComponentPropertyEditor(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::Blob& stream, QTreeWidgetItem* property_item)
|
void createComponentPropertyEditor(PropertyView& view, int array_index, Lumix::IPropertyDescriptor* desc, Lumix::Component& cmp, Lumix::OutputBlob& stream, QTreeWidgetItem* property_item)
|
||||||
{
|
{
|
||||||
switch (desc->getType())
|
switch (desc->getType())
|
||||||
{
|
{
|
||||||
|
@ -332,11 +332,11 @@ public:
|
||||||
subitem->treeWidget()->setItemWidget(subitem, 1, widget);
|
subitem->treeWidget()->setItemWidget(subitem, 1, widget);
|
||||||
|
|
||||||
|
|
||||||
Lumix::Blob stream(view.getWorldEditor()->getAllocator());
|
Lumix::OutputBlob stream(view.getWorldEditor()->getAllocator());
|
||||||
auto& descriptors = view.getWorldEditor()->getPropertyDescriptors(value.type);
|
auto& descriptors = view.getWorldEditor()->getPropertyDescriptors(value.type);
|
||||||
for (int j = 0; j < descriptors.size(); ++j)
|
for (int j = 0; j < descriptors.size(); ++j)
|
||||||
{
|
{
|
||||||
stream.clearBuffer();
|
stream.clear();
|
||||||
auto desc = descriptors[j];
|
auto desc = descriptors[j];
|
||||||
|
|
||||||
createComponentPropertyEditor(view, -1, desc, value, stream, subitem);
|
createComponentPropertyEditor(view, -1, desc, value, stream, subitem);
|
||||||
|
|
Loading…
Reference in a new issue