本文整理汇总了C++中InputBlob类的典型用法代码示例。如果您正苦于以下问题:C++ InputBlob类的具体用法?C++ InputBlob怎么用?C++ InputBlob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InputBlob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
virtual bool deserialize(UniverseContext& ctx,
InputBlob& serializer) override
{
SerializedEngineHeader header;
serializer.read(header);
if (header.m_magic != SERIALIZED_ENGINE_MAGIC)
{
g_log_error.log("engine") << "Wrong or corrupted file";
return false;
}
if (header.m_version > SerializedEngineVersion::LATEST)
{
g_log_error.log("engine") << "Unsupported version";
return false;
}
if (!hasSerializedPlugins(serializer))
{
return false;
}
g_path_manager.deserialize(serializer);
ctx.m_universe->deserialize(serializer);
ctx.m_hierarchy->deserialize(serializer);
m_plugin_manager->deserialize(serializer);
int32_t scene_count;
serializer.read(scene_count);
for (int i = 0; i < scene_count; ++i)
{
char tmp[32];
serializer.readString(tmp, sizeof(tmp));
IScene* scene = ctx.getScene(crc32(tmp));
scene->deserialize(serializer);
}
g_path_manager.clear();
return true;
}
示例2:
void ParticleEmitter::PlaneModule::deserialize(InputBlob& blob, int)
{
blob.read(m_bounce);
blob.read(m_count);
for (int i = 0; i < m_count; ++i)
{
blob.read(m_entities[i]);
}
}
示例3: sizeof
void ParticleEmitter::SizeModule::deserialize(InputBlob& blob, int version)
{
if (version <= (int)ParticleEmitterVersion::SIZE_ALPHA_SAVE) return;
int size;
blob.read(size);
m_values.resize(size);
blob.read(&m_values[0], sizeof(m_values[0]) * m_values.size());
sample();
}
示例4: deserialize
void ParticleEmitter::deserialize(InputBlob& blob, ResourceManager& manager, bool has_version)
{
int version = (int)ParticleEmitterVersion::INVALID;
if (has_version)
{
blob.read(version);
if (version > (int)ParticleEmitterVersion::SPAWN_COUNT) blob.read(m_spawn_count);
}
blob.read(m_spawn_period);
blob.read(m_initial_life);
blob.read(m_initial_size);
blob.read(m_entity);
char path[MAX_PATH_LENGTH];
blob.readString(path, lengthOf(path));
auto material_manager = manager.get(ResourceManager::MATERIAL);
auto material = static_cast<Material*>(material_manager->load(Lumix::Path(path)));
setMaterial(material);
int size;
blob.read(size);
for (auto* module : m_modules)
{
LUMIX_DELETE(m_allocator, module);
}
m_modules.clear();
for (int i = 0; i < size; ++i)
{
uint32 type;
blob.read(type);
auto* module = createModule(type, *this);
m_modules.push(module);
module->deserialize(blob, version);
}
}
示例5: deserialize
void Universe::deserialize(InputBlob& serializer)
{
int32 count;
serializer.read(count);
m_transformations.resize(count);
serializer.read(&m_transformations[0], sizeof(m_transformations[0]) * m_transformations.size());
serializer.read(count);
m_id_to_name_map.clear();
m_name_to_id_map.clear();
for (int i = 0; i < count; ++i)
{
uint32 key;
char name[50];
serializer.read(key);
serializer.readString(name, sizeof(name));
m_id_to_name_map.insert(key, string(name, m_allocator));
m_name_to_id_map.insert(crc32(name), key);
}
serializer.read(m_first_free_slot);
serializer.read(count);
m_id_map.resize(count);
if (!m_id_map.empty())
{
serializer.read(&m_id_map[0], sizeof(m_id_map[0]) * count);
}
}
示例6: deserialize
void PathManager::deserialize(InputBlob& serializer)
{
MT::SpinLock lock(m_mutex);
int32 size;
serializer.read(size);
for (int i = 0; i < size; ++i)
{
char path[MAX_PATH_LENGTH];
serializer.readString(path, sizeof(path));
uint32 hash = crc32(path);
PathInternal* internal = getPathMultithreadUnsafe(hash, path);
--internal->m_ref_count;
}
}
示例7: deserialize
bool deserialize(UniverseContext& ctx, InputBlob& serializer) override
{
SerializedEngineHeader header;
serializer.read(header);
if (header.m_magic != SERIALIZED_ENGINE_MAGIC)
{
g_log_error.log("engine") << "Wrong or corrupted file";
return false;
}
if (header.m_version > SerializedEngineVersion::LATEST)
{
g_log_error.log("engine") << "Unsupported version";
return false;
}
if (!hasSerializedPlugins(serializer))
{
return false;
}
if (header.m_version > SerializedEngineVersion::SCENE_VERSION_CHECK &&
!hasSupportedSceneVersions(serializer, ctx))
{
return false;
}
m_path_manager.deserialize(serializer);
ctx.m_universe->deserialize(serializer);
if (header.m_version <= SerializedEngineVersion::HIERARCHY_COMPONENT)
{
ctx.getScene(HIERARCHY_HASH)->deserialize(serializer, 0);
}
m_plugin_manager->deserialize(serializer);
int32 scene_count;
serializer.read(scene_count);
for (int i = 0; i < scene_count; ++i)
{
char tmp[32];
serializer.readString(tmp, sizeof(tmp));
IScene* scene = ctx.getScene(crc32(tmp));
int scene_version = -1;
if (header.m_version > SerializedEngineVersion::SCENE_VERSION)
{
serializer.read(scene_version);
}
scene->deserialize(serializer, scene_version);
}
m_path_manager.clear();
return true;
}
示例8: hasSerializedPlugins
bool hasSerializedPlugins(InputBlob& serializer)
{
int32 count;
serializer.read(count);
for (int i = 0; i < count; ++i)
{
char tmp[32];
serializer.readString(tmp, sizeof(tmp));
if (!m_plugin_manager->getPlugin(tmp))
{
g_log_error.log("engine") << "Missing plugin " << tmp;
return false;
}
}
return true;
}
示例9: deserialize
void deserialize(InputBlob& serializer) override
{
int count;
serializer.read(count);
m_prefabs.resize(count);
if (count > 0)
serializer.read(&m_prefabs[0], m_prefabs.size() * sizeof(m_prefabs[0]));
serializer.read(count);
for (int i = 0; i < count; ++i)
{
u64 key;
Entity value;
serializer.read(key);
serializer.read(value);
m_instances.insert(key, value);
}
serializer.read(count);
auto* resource_manager = m_editor.getEngine().getResourceManager().get(PrefabResource::TYPE);
for (int i = 0; i < count; ++i)
{
char tmp[MAX_PATH_LENGTH];
serializer.readString(tmp, lengthOf(tmp));
auto* res = (PrefabResource*)resource_manager->load(Path(tmp));
m_resources.insert(res->getPath().getHash(), res);
}
}
示例10: hasSupportedSceneVersions
bool hasSupportedSceneVersions(InputBlob& serializer, UniverseContext& ctx)
{
int32 count;
serializer.read(count);
for (int i = 0; i < count; ++i)
{
uint32 hash;
serializer.read(hash);
auto* scene = ctx.getScene(hash);
int version;
serializer.read(version);
if (version > scene->getVersion())
{
g_log_error.log("engine") << "Plugin " << scene->getPlugin().getName() << " is too old";
return false;
}
}
return true;
}
示例11: deserialize
void deserialize(InputBlob& serializer) override
{
int32_t count;
serializer.read(count);
m_script_entities.resize(count);
m_paths.clear();
m_paths.reserve(count);
for (int i = 0; i < m_script_entities.size(); ++i)
{
serializer.read(m_script_entities[i]);
char path[LUMIX_MAX_PATH];
serializer.readString(path, sizeof(path));
m_paths.push(Path(path));
Entity entity(&m_universe, m_script_entities[i]);
if(m_script_entities[i] != -1)
{
m_universe.addComponent(entity, SCRIPT_HASH, this, i);
}
}
}
示例12: deserialize
void deserialize(InputBlob& serializer) override
{
m_template_names.clear();
m_instances.clear();
int32 count;
serializer.read(count);
for (int i = 0; i < count; ++i)
{
const int MAX_NAME_LENGTH = 50;
char name[MAX_NAME_LENGTH];
serializer.readString(name, MAX_NAME_LENGTH);
m_template_names.push(string(name, m_editor.getAllocator()));
}
serializer.read(count);
for (int i = 0; i < count; ++i)
{
uint32 hash;
serializer.read(hash);
int32 instances_per_template;
serializer.read(instances_per_template);
m_instances.insert(hash, Array<Entity>(m_editor.getAllocator()));
Array<Entity>& entities = m_instances.get(hash);
for (int j = 0; j < instances_per_template; ++j)
{
int32 entity_index;
serializer.read(entity_index);
entities.push(Entity(entity_index));
}
}
m_updated.invoke();
}
示例13: set
void set(ComponentUID cmp, int index, InputBlob& stream) const override
{
int value;
stream.read(&value, sizeof(value));
if (index == -1)
{
(static_cast<PhysicsScene*>(cmp.scene)->*m_single.setter)(cmp.handle, value);
}
else
{
(static_cast<PhysicsScene*>(cmp.scene)->*m_array.setter)(cmp.handle, index, value);
}
};
示例14: deserialize
void deserialize(InputBlob& serializer, int) override
{
int32 count;
serializer.read(count);
m_animables.resize(count);
for (int i = 0; i < count; ++i)
{
serializer.read(m_animables[i].m_entity);
ComponentIndex renderable =
m_render_scene->getRenderableComponent(m_animables[i].m_entity);
if (renderable >= 0)
{
m_animables[i].m_renderable = renderable;
}
serializer.read(m_animables[i].m_time);
serializer.read(m_animables[i].m_is_free);
char path[MAX_PATH_LENGTH];
serializer.readString(path, sizeof(path));
m_animables[i].m_animation = path[0] == '\0' ? nullptr : loadAnimation(path);
m_universe.addComponent(m_animables[i].m_entity, ANIMABLE_HASH, this, i);
}
}
示例15:
OutputBlob::OutputBlob(const InputBlob& blob, IAllocator& allocator)
: m_allocator(&allocator)
, m_pos(blob.getSize())
{
if (blob.getSize() > 0)
{
m_data = allocator.allocate(blob.getSize());
copyMemory(m_data, blob.getData(), blob.getSize());
m_size = blob.getSize();
}
else
{
m_data = nullptr;
m_size = 0;
}
}