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());
|
||||
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;
|
||||
serializer.read(count);
|
||||
|
|
|
@ -3,60 +3,60 @@
|
|||
|
||||
namespace Lumix
|
||||
{
|
||||
Blob::Blob(IAllocator& allocator)
|
||||
/* OutputBlob::OutputBlob(IAllocator& allocator)
|
||||
: m_allocator(allocator)
|
||||
, m_buffer(allocator)
|
||||
, m_own_data(allocator)
|
||||
{
|
||||
m_pos = 0;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
|
||||
Blob::Blob(const Blob& rhs, IAllocator& allocator)
|
||||
OutputBlob::OutputBlob(const OutputBlob& rhs, IAllocator& allocator)
|
||||
: m_allocator(allocator)
|
||||
, m_buffer(allocator)
|
||||
, m_own_data(allocator)
|
||||
{
|
||||
m_data = NULL;
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
|
||||
void Blob::operator =(const Blob& rhs)
|
||||
void OutputBlob::operator =(const OutputBlob& rhs)
|
||||
{
|
||||
m_data = rhs.m_data;
|
||||
m_pos = rhs.m_pos;
|
||||
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;
|
||||
if (!m_buffer.empty())
|
||||
if (!m_own_data.empty())
|
||||
{
|
||||
m_data = &m_buffer[0];
|
||||
m_size = m_buffer.size();
|
||||
m_data = &m_own_data[0];
|
||||
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_data = &m_buffer[0];
|
||||
m_own_data.resize(m_size + size);
|
||||
m_data = &m_own_data[0];
|
||||
}
|
||||
if (size)
|
||||
{
|
||||
memcpy(&m_buffer[0] + m_size, data, size);
|
||||
memcpy(&m_own_data[0] + m_size, data, 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)
|
||||
{
|
||||
|
@ -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;
|
||||
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;
|
||||
|
||||
write(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
|
||||
|
|
|
@ -8,44 +8,46 @@
|
|||
namespace Lumix
|
||||
{
|
||||
|
||||
class LUMIX_CORE_API Blob
|
||||
class LUMIX_CORE_API OutputBlob
|
||||
{
|
||||
public:
|
||||
explicit Blob(IAllocator& allocator);
|
||||
Blob(const Blob& rhs, IAllocator& allocator);
|
||||
void operator =(const Blob& rhs);
|
||||
explicit OutputBlob(IAllocator& allocator);
|
||||
OutputBlob(const OutputBlob& blob, IAllocator& allocator);
|
||||
void operator =(const OutputBlob& rhs);
|
||||
OutputBlob(const OutputBlob& rhs);
|
||||
|
||||
void reserve(int size) { m_buffer.reserve(size); }
|
||||
void create(const void* data, int size) { m_data = data; m_size = size; m_pos = 0; }
|
||||
void write(const void* data, int32_t size);
|
||||
bool read(void* data, int32_t 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 reserve(int size) { m_data.reserve(size); }
|
||||
const void* getData() const { return m_data.empty() ? NULL : &m_data[0]; }
|
||||
int getSize() const { return m_data.size(); }
|
||||
void write(const void* data, int size);
|
||||
void writeString(const char* string);
|
||||
void readString(char* out, int max_size);
|
||||
|
||||
template <class T>
|
||||
void read(T& value) { read(&value, sizeof(T)); }
|
||||
|
||||
void rewindForRead();
|
||||
template <class T> void write(T value) { write(&value, sizeof(T)); }
|
||||
void clear() { m_data.clear(); }
|
||||
|
||||
private:
|
||||
Blob(const Blob& rhs);
|
||||
void write(const char*);
|
||||
void read(const char*);
|
||||
Array<uint8_t> m_data;
|
||||
};
|
||||
|
||||
|
||||
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:
|
||||
IAllocator& m_allocator;
|
||||
Array<uint8_t> m_buffer;
|
||||
int m_pos;
|
||||
const uint8_t* m_data;
|
||||
int m_size;
|
||||
const void* m_data;
|
||||
int m_pos;
|
||||
};
|
||||
|
||||
} // !namespace Lumix
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Lumix
|
|||
}
|
||||
|
||||
|
||||
void PathManager::serialize(Blob& serializer)
|
||||
void PathManager::serialize(OutputBlob& serializer)
|
||||
{
|
||||
MT::SpinLock lock(m_mutex);
|
||||
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);
|
||||
int32_t size;
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
namespace Lumix
|
||||
{
|
||||
|
||||
class Blob;
|
||||
class InputBlob;
|
||||
class OutputBlob;
|
||||
|
||||
class PathInternal
|
||||
{
|
||||
|
@ -27,8 +28,8 @@ namespace Lumix
|
|||
PathManager();
|
||||
~PathManager();
|
||||
|
||||
void serialize(Blob& serializer);
|
||||
void deserialize(Blob& serializer);
|
||||
void serialize(OutputBlob& serializer);
|
||||
void deserialize(InputBlob& serializer);
|
||||
|
||||
private:
|
||||
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());
|
||||
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_instances.clear();
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
namespace Lumix
|
||||
{
|
||||
|
||||
class Blob;
|
||||
class InputBlob;
|
||||
class OutputBlob;
|
||||
class WorldEditor;
|
||||
|
||||
class LUMIX_ENGINE_API EntityTemplateSystem
|
||||
|
@ -20,8 +21,8 @@ namespace Lumix
|
|||
static void destroy(EntityTemplateSystem* system);
|
||||
|
||||
virtual ~EntityTemplateSystem() {}
|
||||
virtual void serialize(Blob& serializer) = 0;
|
||||
virtual void deserialize(Blob& serializer) = 0;
|
||||
virtual void serialize(OutputBlob& serializer) = 0;
|
||||
virtual void deserialize(InputBlob& serializer) = 0;
|
||||
virtual void createTemplateFromEntity(const char* name, const Entity& entity) = 0;
|
||||
virtual uint32_t getTemplate(const Entity& entity) = 0;
|
||||
virtual const Array<Entity>& getInstances(uint32_t template_name_hash) = 0;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Lumix
|
|||
|
||||
|
||||
struct Vec3;
|
||||
class Blob;
|
||||
class OutputBlob;
|
||||
|
||||
|
||||
class IPropertyDescriptor
|
||||
|
@ -40,10 +40,10 @@ class IPropertyDescriptor
|
|||
{ }
|
||||
virtual ~IPropertyDescriptor() {}
|
||||
|
||||
virtual void set(Component cmp, Blob& stream) const = 0;
|
||||
virtual void get(Component cmp, Blob& stream) const = 0;
|
||||
virtual void set(Component cmp, int index, Blob& stream) const = 0;
|
||||
virtual void get(Component cmp, int index, Blob& stream) const = 0;
|
||||
virtual void set(Component cmp, InputBlob& stream) const = 0;
|
||||
virtual void get(Component cmp, OutputBlob& stream) const = 0;
|
||||
virtual void set(Component cmp, int index, InputBlob& stream) const = 0;
|
||||
virtual void get(Component cmp, int index, OutputBlob& stream) const = 0;
|
||||
|
||||
Type getType() const { return m_type; }
|
||||
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;
|
||||
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);
|
||||
int len = sizeof(i);
|
||||
|
@ -115,8 +115,8 @@ class IntArrayObjectDescriptor : public IIntPropertyDescriptor
|
|||
}
|
||||
|
||||
|
||||
virtual void set(Component, Blob&) const {};
|
||||
virtual void get(Component, Blob&) const {};
|
||||
virtual void set(Component, InputBlob&) const override {};
|
||||
virtual void get(Component, OutputBlob&) const override {};
|
||||
|
||||
private:
|
||||
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;
|
||||
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;
|
||||
(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 get(Component, Blob&) const { ASSERT(false); };
|
||||
virtual void set(Component, OutputBlob&) const { ASSERT(false); };
|
||||
virtual void get(Component, OutputBlob&) const { ASSERT(false); };
|
||||
|
||||
private:
|
||||
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;
|
||||
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);
|
||||
stream.write(&f, sizeof(f));
|
||||
}
|
||||
|
||||
|
||||
virtual void set(Component, Blob&) const { ASSERT(false); };
|
||||
virtual void get(Component, Blob&) const { ASSERT(false); };
|
||||
virtual void set(Component, OutputBlob&) const { ASSERT(false); };
|
||||
virtual void get(Component, OutputBlob&) const { ASSERT(false); };
|
||||
|
||||
private:
|
||||
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* 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;
|
||||
string value(allocator);
|
||||
|
@ -256,8 +256,8 @@ class StringArrayObjectDescriptor : public IPropertyDescriptor
|
|||
}
|
||||
|
||||
|
||||
virtual void set(Component, Blob&) const { ASSERT(false); };
|
||||
virtual void get(Component, Blob&) const { ASSERT(false); };
|
||||
virtual void set(Component, InputBlob&) const { ASSERT(false); };
|
||||
virtual void get(Component, OutputBlob&) const { ASSERT(false); };
|
||||
|
||||
private:
|
||||
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; }
|
||||
|
||||
|
||||
virtual void set(Component cmp, int index, Blob& stream) const override
|
||||
virtual void set(Component cmp, int index, OutputBlob& stream) const override
|
||||
{
|
||||
Vec3 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);
|
||||
len = sizeof(v);
|
||||
|
@ -327,8 +327,8 @@ class Vec3ArrayObjectDescriptor : public IPropertyDescriptor
|
|||
}
|
||||
|
||||
|
||||
virtual void set(Component, Blob&) const {};
|
||||
virtual void get(Component, Blob&) const {};
|
||||
virtual void set(Component, OutputBlob&) const {};
|
||||
virtual void get(Component, OutputBlob&) const {};
|
||||
|
||||
private:
|
||||
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;
|
||||
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);
|
||||
stream.write(count);
|
||||
|
@ -413,8 +413,8 @@ class ArrayDescriptor : public IArrayDescriptor
|
|||
}
|
||||
|
||||
|
||||
virtual void set(Component, int, Blob&) const override { ASSERT(false); };
|
||||
virtual void get(Component, int, Blob&) const override { ASSERT(false); };
|
||||
virtual void set(Component, int, InputBlob&) 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 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; }
|
||||
|
||||
|
||||
virtual void set(Component cmp, Blob& stream) const override
|
||||
virtual void set(Component cmp, OutputBlob& stream) const override
|
||||
{
|
||||
int32_t 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);
|
||||
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 get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(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, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||
|
||||
private:
|
||||
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* 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;
|
||||
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 get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(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, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||
|
||||
private:
|
||||
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;
|
||||
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);
|
||||
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 get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(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, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||
|
||||
private:
|
||||
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;
|
||||
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);
|
||||
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 get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(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, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream); };
|
||||
|
||||
private:
|
||||
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;
|
||||
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);
|
||||
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 get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(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, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream);};
|
||||
|
||||
private:
|
||||
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;
|
||||
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);
|
||||
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 get(Component cmp, int index, Blob& stream) const override { ASSERT(index == -1); get(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, OutputBlob& stream) const override { ASSERT(index == -1); get(cmp, stream);};
|
||||
|
||||
private:
|
||||
Getter m_getter;
|
||||
|
|
|
@ -143,7 +143,7 @@ class PasteEntityCommand : public IEditorCommand
|
|||
, m_editor(editor)
|
||||
{}
|
||||
|
||||
PasteEntityCommand(WorldEditor& editor, Blob& blob)
|
||||
PasteEntityCommand(WorldEditor& editor, OutputBlob& blob)
|
||||
: m_blob(blob, editor.getAllocator())
|
||||
, m_editor(editor)
|
||||
, m_position(editor.getCameraRaycastHit())
|
||||
|
@ -160,11 +160,11 @@ class PasteEntityCommand : public IEditorCommand
|
|||
serializer.serialize("pos_y", m_position.y);
|
||||
serializer.serialize("pos_z", m_position.z);
|
||||
serializer.serialize("entity", m_entity.index);
|
||||
serializer.serialize("size", m_blob.getBufferSize());
|
||||
serializer.serialize("size", m_blob.getSize());
|
||||
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();
|
||||
}
|
||||
|
@ -180,8 +180,8 @@ class PasteEntityCommand : public IEditorCommand
|
|||
int size;
|
||||
serializer.deserialize("size", size, 0);
|
||||
serializer.deserializeArrayBegin("data");
|
||||
m_blob.clearBuffer();
|
||||
for (int i = 0; i < m_blob.getBufferSize(); ++i)
|
||||
m_blob.clear();
|
||||
for (int i = 0; i < m_blob.getSize(); ++i)
|
||||
{
|
||||
int32_t data;
|
||||
serializer.deserializeArrayItem(data, 0);
|
||||
|
@ -217,7 +217,7 @@ class PasteEntityCommand : public IEditorCommand
|
|||
}
|
||||
|
||||
private:
|
||||
Blob m_blob;
|
||||
OutputBlob m_blob;
|
||||
WorldEditor& m_editor;
|
||||
Vec3 m_position;
|
||||
Entity m_entity;
|
||||
|
@ -427,10 +427,10 @@ class RemoveArrayPropertyItemCommand : public IEditorCommand
|
|||
virtual void undo() override
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
int m_index;
|
||||
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_type", m_component.type);
|
||||
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.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.scene = m_editor.getEngine().getSceneByComponentType(m_component.type);
|
||||
serializer.deserializeArrayBegin("data");
|
||||
m_new_value.clearBuffer();
|
||||
m_new_value.clear();
|
||||
while (!serializer.isArrayEnd())
|
||||
{
|
||||
int data;
|
||||
|
@ -611,15 +611,15 @@ class SetPropertyCommand : public IEditorCommand
|
|||
|
||||
virtual void execute() override
|
||||
{
|
||||
m_new_value.rewindForRead();
|
||||
set(m_new_value);
|
||||
InputBlob blob(m_new_value);
|
||||
set(blob);
|
||||
}
|
||||
|
||||
|
||||
virtual void undo() override
|
||||
{
|
||||
m_old_value.rewindForRead();
|
||||
set(m_old_value);
|
||||
InputBlob blob(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);
|
||||
if (template_hash)
|
||||
|
@ -651,7 +651,7 @@ class SetPropertyCommand : public IEditorCommand
|
|||
const Array<Entity>& entities = m_editor.getEntityTemplateSystem().getInstances(template_hash);
|
||||
for (int i = 0, c = entities.size(); i < c; ++i)
|
||||
{
|
||||
stream.rewindForRead();
|
||||
stream.rewind();
|
||||
const WorldEditor::ComponentList& cmps = m_editor.getComponents(entities[i]);
|
||||
for (int j = 0, cj = cmps.size(); j < cj; ++j)
|
||||
{
|
||||
|
@ -687,8 +687,8 @@ class SetPropertyCommand : public IEditorCommand
|
|||
private:
|
||||
WorldEditor& m_editor;
|
||||
Component m_component;
|
||||
Blob m_new_value;
|
||||
Blob m_old_value;
|
||||
OutputBlob m_new_value;
|
||||
OutputBlob m_old_value;
|
||||
int m_index;
|
||||
const IPropertyDescriptor* m_property_descriptor;
|
||||
};
|
||||
|
@ -887,7 +887,7 @@ struct WorldEditorImpl : public WorldEditor
|
|||
virtual void execute() override
|
||||
{
|
||||
m_positons_rotations.clear();
|
||||
m_old_values.clearBuffer();
|
||||
m_old_values.clear();
|
||||
for (int i = 0; i < m_entities.size(); ++i)
|
||||
{
|
||||
const WorldEditor::ComponentList& cmps = m_editor.getComponents(m_entities[i]);
|
||||
|
@ -925,18 +925,18 @@ struct WorldEditorImpl : public WorldEditor
|
|||
virtual void undo() override
|
||||
{
|
||||
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)
|
||||
{
|
||||
Entity new_entity = m_editor.getEngine().getUniverse()->createEntity();
|
||||
new_entity.setPosition(m_positons_rotations[i].m_position);
|
||||
new_entity.setRotation(m_positons_rotations[i].m_rotation);
|
||||
int cmps_count;
|
||||
m_old_values.read(cmps_count);
|
||||
blob.read(cmps_count);
|
||||
for (int j = cmps_count - 1; j >= 0; --j)
|
||||
{
|
||||
Component::Type cmp_type;
|
||||
m_old_values.read(cmp_type);
|
||||
blob.read(cmp_type);
|
||||
Component new_component;
|
||||
for (int i = 0; i < scenes.size(); ++i)
|
||||
{
|
||||
|
@ -954,7 +954,7 @@ struct WorldEditorImpl : public WorldEditor
|
|||
|
||||
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;
|
||||
Array<Entity> m_entities;
|
||||
Array<PositionRotation> m_positons_rotations;
|
||||
Blob m_old_values;
|
||||
OutputBlob m_old_values;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1039,13 +1039,13 @@ struct WorldEditorImpl : public WorldEditor
|
|||
break;
|
||||
}
|
||||
}
|
||||
m_old_values.rewindForRead();
|
||||
InputBlob blob(m_old_values);
|
||||
if (props_index >= 0)
|
||||
{
|
||||
const Array<IPropertyDescriptor*>& props = m_editor.m_component_properties.at(props_index);
|
||||
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]);
|
||||
if (cmp_new.isValid())
|
||||
{
|
||||
m_old_values.rewindForRead();
|
||||
InputBlob blob(m_old_values);
|
||||
if (props_index >= 0)
|
||||
{
|
||||
const Array<IPropertyDescriptor*>& props = m_editor.m_component_properties.at(props_index);
|
||||
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:
|
||||
Component m_component;
|
||||
WorldEditorImpl& m_editor;
|
||||
Blob m_old_values;
|
||||
OutputBlob m_old_values;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1565,16 +1565,16 @@ struct WorldEditorImpl : public WorldEditor
|
|||
|
||||
void save(FS::IFile& file)
|
||||
{
|
||||
Blob blob(m_allocator);
|
||||
OutputBlob blob(m_allocator);
|
||||
blob.reserve(1 << 20);
|
||||
uint32_t hash = 0;
|
||||
blob.write(hash);
|
||||
m_engine->serialize(blob);
|
||||
m_template_system->serialize(blob);
|
||||
hash = crc32(blob.getBuffer() + sizeof(hash), blob.getBufferSize() - sizeof(hash));
|
||||
(*(uint32_t*)blob.getBuffer()) = hash;
|
||||
hash = crc32((const uint8_t*)blob.getData() + sizeof(hash), blob.getSize() - sizeof(hash));
|
||||
(*(uint32_t*)blob.getData()) = hash;
|
||||
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())
|
||||
{
|
||||
Entity entity = m_selected_entities[0];
|
||||
m_copy_buffer.clearBuffer();
|
||||
m_copy_buffer.clear();
|
||||
const WorldEditor::ComponentList& cmps = getComponents(entity);
|
||||
int32_t count = cmps.size();
|
||||
m_copy_buffer.write(count);
|
||||
|
@ -1868,13 +1868,13 @@ struct WorldEditorImpl : public WorldEditor
|
|||
}
|
||||
|
||||
const Array<IPropertyDescriptor*>& properties = getPropertyDescriptors(src.type);
|
||||
Blob stream(m_allocator);
|
||||
OutputBlob stream(m_allocator);
|
||||
for (int i = 0; i < properties.size(); ++i)
|
||||
{
|
||||
stream.clearBuffer();
|
||||
stream.clear();
|
||||
properties[i]->get(src, stream);
|
||||
stream.rewindForRead();
|
||||
properties[i]->set(clone, stream);
|
||||
InputBlob blob(stream.getData(), stream.getSize());
|
||||
properties[i]->set(clone, blob);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1963,11 +1963,10 @@ struct WorldEditorImpl : public WorldEditor
|
|||
m_components.reserve(5000);
|
||||
Timer* timer = Timer::create(m_allocator);
|
||||
g_log_info.log("editor") << "Parsing universe...";
|
||||
Blob blob(m_allocator);
|
||||
blob.create(file.getBuffer(), file.size());
|
||||
InputBlob blob(file.getBuffer(), file.size());
|
||||
uint32_t hash = 0;
|
||||
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);
|
||||
g_log_error.log("editor") << "Corrupted file.";
|
||||
|
@ -2712,7 +2711,7 @@ struct WorldEditorImpl : public WorldEditor
|
|||
Array<IEditorCommand*> m_undo_stack;
|
||||
AssociativeArray<uint32_t, EditorCommandCreator> m_editor_command_creators;
|
||||
int m_undo_index;
|
||||
Blob m_copy_buffer;
|
||||
OutputBlob m_copy_buffer;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2740,20 +2739,20 @@ void WorldEditor::destroy(WorldEditor* editor)
|
|||
|
||||
void PasteEntityCommand::execute()
|
||||
{
|
||||
m_blob.rewindForRead();
|
||||
InputBlob blob(m_blob.getData(), m_blob.getSize());
|
||||
Entity new_entity = m_editor.getEngine().getUniverse()->createEntity();
|
||||
new_entity.setPosition(m_position);
|
||||
int32_t count;
|
||||
m_blob.read(count);
|
||||
blob.read(count);
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
uint32_t type;
|
||||
m_blob.read(type);
|
||||
blob.read(type);
|
||||
Component cmp = static_cast<WorldEditorImpl&>(m_editor).createComponent(type, new_entity);
|
||||
Array<IPropertyDescriptor*>& props = m_editor.getPropertyDescriptors(type);
|
||||
for(int j = 0; j < props.size(); ++j)
|
||||
{
|
||||
props[j]->set(cmp, m_blob);
|
||||
props[j]->set(cmp, blob);
|
||||
}
|
||||
}
|
||||
m_entity = new_entity;
|
||||
|
|
|
@ -312,7 +312,7 @@ namespace Lumix
|
|||
}
|
||||
|
||||
|
||||
virtual void serialize(Blob& serializer) override
|
||||
virtual void serialize(OutputBlob& serializer) override
|
||||
{
|
||||
SerializedEngineHeader header;
|
||||
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;
|
||||
serializer.read(header);
|
||||
|
|
|
@ -18,12 +18,13 @@ namespace Lumix
|
|||
class Manager;
|
||||
}
|
||||
|
||||
class Blob;
|
||||
class InputBlob;
|
||||
class EditorServer;
|
||||
class InputSystem;
|
||||
class IPlugin;
|
||||
class IScene;
|
||||
class JsonSerializer;
|
||||
class OutputBlob;
|
||||
class PluginManager;
|
||||
class Renderer;
|
||||
class ResourceManager;
|
||||
|
@ -60,8 +61,8 @@ namespace Lumix
|
|||
|
||||
virtual const char* getBasePath() const = 0;
|
||||
virtual void update(bool is_game_running) = 0;
|
||||
virtual void serialize(Blob& serializer) = 0;
|
||||
virtual bool deserialize(Blob& serializer) = 0;
|
||||
virtual void serialize(OutputBlob& serializer) = 0;
|
||||
virtual bool deserialize(InputBlob& serializer) = 0;
|
||||
virtual float getFPS() const = 0;
|
||||
virtual float getLastTimeDelta() = 0;
|
||||
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
|
||||
namespace Lumix
|
||||
{
|
||||
class Blob;
|
||||
class Engine;
|
||||
class InputBlob;
|
||||
class IPlugin;
|
||||
class OutputBlob;
|
||||
class Universe;
|
||||
|
||||
|
||||
|
@ -20,8 +21,8 @@ namespace Lumix
|
|||
|
||||
virtual Component createComponent(uint32_t, const Entity&) = 0;
|
||||
virtual void destroyComponent(const Component& component) = 0;
|
||||
virtual void serialize(Blob& serializer) = 0;
|
||||
virtual void deserialize(Blob& serializer) = 0;
|
||||
virtual void serialize(OutputBlob& serializer) = 0;
|
||||
virtual void deserialize(InputBlob& serializer) = 0;
|
||||
virtual IPlugin& getPlugin() const = 0;
|
||||
virtual void update(float time_delta) = 0;
|
||||
virtual bool ownComponentType(uint32_t type) const = 0;
|
||||
|
@ -35,8 +36,8 @@ namespace Lumix
|
|||
|
||||
virtual bool create() = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void serialize(Blob&) {}
|
||||
virtual void deserialize(Blob&) {}
|
||||
virtual void serialize(OutputBlob&) {}
|
||||
virtual void deserialize(InputBlob&) {}
|
||||
virtual void update(float) {}
|
||||
virtual const char* getName() const = 0;
|
||||
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;
|
||||
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;
|
||||
for(int i = 0, c = plugins.size(); i < c; ++i)
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
namespace Lumix
|
||||
{
|
||||
|
||||
class Blob;
|
||||
class Engine;
|
||||
class InputBlob;
|
||||
class IPlugin;
|
||||
class JsonSerializer;
|
||||
class OutputBlob;
|
||||
class Universe;
|
||||
|
||||
class LUMIX_ENGINE_API PluginManager
|
||||
|
@ -24,8 +25,8 @@ namespace Lumix
|
|||
IPlugin* load(const char* path);
|
||||
void addPlugin(IPlugin* plugin);
|
||||
void update(float dt);
|
||||
void serialize(Blob& serializer);
|
||||
void deserialize(Blob& serializer);
|
||||
void serialize(OutputBlob& serializer);
|
||||
void deserialize(InputBlob& serializer);
|
||||
IPlugin* getPlugin(const char* name);
|
||||
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(&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());
|
||||
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());
|
||||
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());
|
||||
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);
|
||||
serializeRenderables(serializer);
|
||||
|
@ -493,7 +493,7 @@ namespace Lumix
|
|||
serializeTerrains(serializer);
|
||||
}
|
||||
|
||||
void deserializeCameras(Blob& serializer)
|
||||
void deserializeCameras(InputBlob& serializer)
|
||||
{
|
||||
int32_t size;
|
||||
serializer.read(size);
|
||||
|
@ -509,7 +509,7 @@ namespace Lumix
|
|||
}
|
||||
}
|
||||
|
||||
void deserializeRenderables(Blob& serializer)
|
||||
void deserializeRenderables(InputBlob& serializer)
|
||||
{
|
||||
int32_t size = 0;
|
||||
serializer.read(size);
|
||||
|
@ -549,7 +549,7 @@ namespace Lumix
|
|||
}
|
||||
}
|
||||
|
||||
void deserializeLights(Blob& serializer)
|
||||
void deserializeLights(InputBlob& serializer)
|
||||
{
|
||||
int32_t size = 0;
|
||||
serializer.read(size);
|
||||
|
@ -568,7 +568,7 @@ namespace Lumix
|
|||
}
|
||||
}
|
||||
|
||||
void deserializeTerrains(Blob& serializer)
|
||||
void deserializeTerrains(InputBlob& serializer)
|
||||
{
|
||||
int32_t size = 0;
|
||||
serializer.read(size);
|
||||
|
@ -595,7 +595,7 @@ namespace Lumix
|
|||
}
|
||||
}
|
||||
|
||||
virtual void deserialize(Blob& serializer) override
|
||||
virtual void deserialize(InputBlob& serializer) override
|
||||
{
|
||||
deserializeCameras(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);
|
||||
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_layer_mask);
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Lumix
|
|||
{
|
||||
|
||||
|
||||
class Blob;
|
||||
class OutputBlob;
|
||||
class Material;
|
||||
class Mesh;
|
||||
class PipelineInstance;
|
||||
|
@ -81,8 +81,8 @@ class Terrain
|
|||
void render(Renderer& renderer, PipelineInstance& pipeline, const Vec3& camera_pos);
|
||||
RayCastModelHit castRay(const Vec3& origin, const Vec3& dir);
|
||||
int64_t getLayerMask() const { return m_layer_mask; }
|
||||
void serialize(Blob& serializer);
|
||||
void deserialize(Blob& serializer, Universe& universe, RenderScene& scene, int index);
|
||||
void serialize(OutputBlob& serializer);
|
||||
void deserialize(InputBlob& serializer, Universe& universe, RenderScene& scene, int index);
|
||||
void setXZScale(float scale) { m_xz_scale = scale; }
|
||||
float getXZScale() const { return m_xz_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;
|
||||
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;
|
||||
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());
|
||||
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;
|
||||
m_dynamic_actors.clear();
|
||||
|
@ -975,7 +975,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void deserializeControllers(Blob& serializer)
|
||||
void deserializeControllers(InputBlob& serializer)
|
||||
{
|
||||
int32_t count;
|
||||
serializer.read(count);
|
||||
|
@ -1016,7 +1016,7 @@ struct PhysicsSceneImpl : public PhysicsScene
|
|||
}
|
||||
|
||||
|
||||
void deserializeTerrains(Blob& serializer)
|
||||
void deserializeTerrains(InputBlob& serializer)
|
||||
{
|
||||
int32_t 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);
|
||||
deserializeControllers(serializer);
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Lumix
|
|||
virtual IPlugin& getPlugin() const;
|
||||
|
||||
|
||||
void deserialize(Blob& serializer) override
|
||||
void deserialize(InputBlob& serializer) override
|
||||
{
|
||||
stopAll();
|
||||
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());
|
||||
for (int i = 0; i < m_script_entities.size(); ++i)
|
||||
|
|
|
@ -5,15 +5,103 @@
|
|||
void UT_blob(const char* params)
|
||||
{
|
||||
Lumix::DefaultAllocator allocator;
|
||||
/*
|
||||
Lumix::Blob blob(allocator);
|
||||
char data[] = "abcdef";
|
||||
blob.create(data, sizeof(data));
|
||||
blob.
|
||||
*/
|
||||
|
||||
Lumix::OutputBlob blob(allocator);
|
||||
|
||||
LUMIX_EXPECT_EQ(blob.getSize(), 0);
|
||||
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
|
||||
ASSERT(false); // TODO
|
||||
char c = 'A';
|
||||
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, "")
|
|
@ -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();
|
||||
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;
|
||||
serializer.read(size);
|
||||
|
|
|
@ -9,7 +9,8 @@ namespace Lumix
|
|||
{
|
||||
|
||||
|
||||
class Blob;
|
||||
class InputBlob;
|
||||
class OutputBlob;
|
||||
|
||||
|
||||
class Hierarchy
|
||||
|
@ -31,8 +32,8 @@ namespace Lumix
|
|||
|
||||
virtual void setParent(const Entity& child, const Entity& parent) = 0;
|
||||
virtual Entity getParent(const Entity& child) = 0;
|
||||
virtual void serialize(Blob& serializer) = 0;
|
||||
virtual void deserialize(Blob& serializer) = 0;
|
||||
virtual void serialize(OutputBlob& serializer) = 0;
|
||||
virtual void deserialize(InputBlob& serializer) = 0;
|
||||
virtual Array<Child>* getChildren(const Entity& parent) = 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(&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;
|
||||
serializer.read(count);
|
||||
|
|
|
@ -16,9 +16,10 @@ namespace Lumix
|
|||
{
|
||||
|
||||
|
||||
class Blob;
|
||||
class InputBlob;
|
||||
class Event;
|
||||
struct Matrix;
|
||||
class OutputBlob;
|
||||
struct Quat;
|
||||
class Universe;
|
||||
struct Vec3;
|
||||
|
@ -51,8 +52,8 @@ class LUMIX_ENGINE_API Universe final
|
|||
|
||||
Delegate<void(const Component&)>& componentAdded() { return m_component_added; }
|
||||
|
||||
void serialize(Blob& serializer);
|
||||
void deserialize(Blob& serializer);
|
||||
void serialize(OutputBlob& serializer);
|
||||
void deserialize(InputBlob& serializer);
|
||||
|
||||
private:
|
||||
IAllocator& m_allocator;
|
||||
|
|
|
@ -62,23 +62,23 @@ static const uint32_t SCRIPT_HASH = crc32("script");
|
|||
#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>
|
||||
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;
|
||||
stream.clearBuffer();
|
||||
stream.clear();
|
||||
desc->get(cmp, array_index, stream);
|
||||
stream.rewindForRead();
|
||||
stream.read(v);
|
||||
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||
blob.read(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
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(
|
||||
desc->getName(),
|
||||
|
@ -90,12 +90,12 @@ PropertyEditor<T> createComponentPropertyEditor(PropertyView& view, int array_in
|
|||
|
||||
|
||||
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);
|
||||
stream.rewindForRead();
|
||||
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); });
|
||||
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||
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);
|
||||
stream.rewindForRead();
|
||||
auto* res = view.getResource((const char*)stream.getBuffer());
|
||||
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||
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 file_desc = dynamic_cast<Lumix::IFilePropertyDescriptor*>(desc);
|
||||
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);
|
||||
stream.rewindForRead();
|
||||
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); });
|
||||
Lumix::InputBlob blob(stream.getData(), stream.getSize());
|
||||
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 filter = file_desc->getFileType();
|
||||
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();
|
||||
property_item->addChild(array_item);
|
||||
|
@ -225,7 +225,7 @@ void createComponentArrayPropertyEdit(PropertyView& view, Lumix::IPropertyDescri
|
|||
array_item->addChild(item);
|
||||
item->setText(0, QString::number(array_desc.getCount(cmp) - 1));
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
@ -332,11 +332,11 @@ public:
|
|||
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);
|
||||
for (int j = 0; j < descriptors.size(); ++j)
|
||||
{
|
||||
stream.clearBuffer();
|
||||
stream.clear();
|
||||
auto desc = descriptors[j];
|
||||
|
||||
createComponentPropertyEditor(view, -1, desc, value, stream, subitem);
|
||||
|
|
Loading…
Reference in a new issue