refactor: allocator always the last as a function's argument - closes #374

This commit is contained in:
Mikulas Florek 2014-12-08 01:06:51 +01:00
parent a4f99c4dd2
commit a7e414b85c
24 changed files with 87 additions and 97 deletions

View file

@ -313,7 +313,7 @@ namespace Lumix
virtual bool create() override
{
IAllocator& allocator = m_engine.getWorldEditor()->getAllocator();
m_engine.getWorldEditor()->registerProperty("animable", allocator.newObject<FilePropertyDescriptor<AnimationSceneImpl> >(allocator, "preview", &AnimationSceneImpl::getPreview, &AnimationSceneImpl::setPreview, "Animation (*.ani)"));
m_engine.getWorldEditor()->registerProperty("animable", allocator.newObject<FilePropertyDescriptor<AnimationSceneImpl> >("preview", &AnimationSceneImpl::getPreview, &AnimationSceneImpl::setPreview, "Animation (*.ani)", allocator));
m_animation_manager.create(ResourceManager::ANIMATION, m_engine.getResourceManager());
return true;
}

View file

@ -18,7 +18,7 @@ namespace MTJD
class GenericJob : public MTJD::Job
{
public:
GenericJob(IAllocator& allocator, MTJD::Manager& manager, T function)
GenericJob(MTJD::Manager& manager, T function, IAllocator& allocator)
: MTJD::Job(true, MTJD::Priority::Normal, false, manager, allocator)
, m_function(function)
{
@ -35,9 +35,9 @@ namespace MTJD
template <class T>
MTJD::Job* makeJob(IAllocator& allocator, MTJD::Manager& manager, T function)
MTJD::Job* makeJob(MTJD::Manager& manager, T function, IAllocator& allocator)
{
return allocator.newObject<GenericJob<T> >(allocator, manager, function);
return allocator.newObject<GenericJob<T> >(manager, function, allocator);
}

View file

@ -13,7 +13,7 @@ namespace Lumix
class LUMIX_CORE_API Scheduler : public MT::Task
{
public:
explicit Scheduler(Manager& manager, IAllocator& allocator);
Scheduler(Manager& manager, IAllocator& allocator);
~Scheduler();
virtual int task() override;

View file

@ -142,26 +142,14 @@ class Array<T, false>
m_size = size;
}
template<typename P1, typename... Params>
T& emplace(const P1& p1, Params... params)
template<typename ...Params>
T& emplace(Params&& ...params)
{
if (m_size == m_capacity)
{
grow();
}
new ((char*)(m_data + m_size)) T(p1, params...);
++m_size;
return m_data[m_size - 1];
}
template<typename P1, typename... Params>
T& emplace(P1& p1, Params... params)
{
if (m_size == m_capacity)
{
grow();
}
new ((char*)(m_data + m_size)) T(p1, params...);
new ((char*)(m_data + m_size)) T(std::forward<Params>(params)...);
++m_size;
return m_data[m_size - 1];
}

View file

@ -204,7 +204,7 @@ namespace Lumix
init();
}
explicit HashMap(size_type buckets, IAllocator& allocator)
HashMap(size_type buckets, IAllocator& allocator)
: m_allocator(allocator)
{
initSentinel();

View file

@ -31,7 +31,7 @@ JsonSerializer::ErrorProxy::ErrorProxy(JsonSerializer& serializer)
}
JsonSerializer::JsonSerializer(IAllocator& allocator, FS::IFile& file, AccessMode access_mode, const char* path)
JsonSerializer::JsonSerializer(FS::IFile& file, AccessMode access_mode, const char* path, IAllocator& allocator)
: m_file(file)
, m_access_mode(access_mode)
, m_error_message(allocator)
@ -374,7 +374,7 @@ void JsonSerializer::expectToken(char expected_token)
char tmp[2];
tmp[0] = expected_token;
tmp[1] = 0;
error().log() << "Unexpected token \"" << string(m_allocator, m_token, m_token_size) << "\", expected " << tmp << ".";
error().log() << "Unexpected token \"" << string(m_token, m_token_size, m_allocator) << "\", expected " << tmp << ".";
}
}
@ -433,7 +433,7 @@ void JsonSerializer::deserializeArrayItem(char* value, int max_length, const cha
}
else
{
error().log() << "Unexpected token \"" << string(m_allocator, m_token, m_token_size) << "\", expected string.";
error().log() << "Unexpected token \"" << string(m_token, m_token_size, m_allocator) << "\", expected string.";
copyString(value, max_length, default_value);
}
}
@ -639,7 +639,7 @@ void JsonSerializer::deserializeLabel(char* label, int max_length)
}
if (!m_is_string_token)
{
error().log() << "Unexpected token \"" << string(m_allocator, m_token, m_token_size) << "\", expected string.";
error().log() << "Unexpected token \"" << string(m_token, m_token_size, m_allocator) << "\", expected string.";
}
int size = Math::minValue(max_length - 1, m_token_size);
copyString(label, size, m_token);
@ -669,16 +669,16 @@ void JsonSerializer::deserializeLabel(const char* label)
}
if (!m_is_string_token)
{
error().log() << "Unexpected token \"" << string(m_allocator, m_token, m_token_size) << "\", expected string.";
error().log() << "Unexpected token \"" << string(m_token, m_token_size, m_allocator) << "\", expected string.";
}
if (strncmp(label, m_token, m_token_size) != 0)
{
error().log() << "Unexpected label \"" << string(m_allocator, m_token, m_token_size) << "\", expected \"" << label << "\".";
error().log() << "Unexpected label \"" << string(m_token, m_token_size, m_allocator) << "\", expected \"" << label << "\".";
}
deserializeToken();
if (m_is_string_token || m_token_size != 1 || m_token[0] != ':')
{
error().log() << "Unexpected label \"" << string(m_allocator, m_token, m_token_size) << "\", expected \"" << label << "\".";
error().log() << "Unexpected label \"" << string(m_token, m_token_size, m_allocator) << "\", expected \"" << label << "\".";
}
deserializeToken();
}

View file

@ -34,7 +34,7 @@ namespace Lumix
};
public:
JsonSerializer(IAllocator& allocator, FS::IFile& file, AccessMode access_mode, const char* path);
JsonSerializer(FS::IFile& file, AccessMode access_mode, const char* path, IAllocator& allocator);
~JsonSerializer();
// serialize

View file

@ -41,7 +41,7 @@ class base_string
m_cstr[m_size] = 0;
}
base_string(IAllocator& allocator, const char* rhs, int32_t length)
base_string(const T* rhs, int32_t length, IAllocator& allocator)
: m_allocator(allocator)
{
m_size = length;
@ -59,7 +59,7 @@ class base_string
m_cstr[m_size] = 0;
}
explicit base_string(const T* rhs, IAllocator& allocator)
base_string(const T* rhs, IAllocator& allocator)
: m_allocator(allocator)
{
m_size = strlen(rhs);

View file

@ -88,7 +88,7 @@ class IntArrayObjectDescriptor : public IIntPropertyDescriptor
typedef void (S::*IntegerSetter)(Component, int, int);
public:
IntArrayObjectDescriptor(IAllocator& allocator, const char* name, IntegerGetter _getter, IntegerSetter _setter)
IntArrayObjectDescriptor(const char* name, IntegerGetter _getter, IntegerSetter _setter, IAllocator& allocator)
: IIntPropertyDescriptor(allocator)
{
setName(name);
@ -131,7 +131,7 @@ class BoolArrayObjectDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, int, const int&);
public:
BoolArrayObjectDescriptor(IAllocator& allocator, const char* name, Getter _getter, Setter _setter)
BoolArrayObjectDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -174,7 +174,7 @@ class DecimalArrayObjectDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, int, float);
public:
DecimalArrayObjectDescriptor(IAllocator& allocator, const char* name, Getter _getter, Setter _setter)
DecimalArrayObjectDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -219,7 +219,7 @@ class StringArrayObjectDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, int, const string&);
public:
StringArrayObjectDescriptor(IAllocator& allocator, const char* name, Getter _getter, Setter _setter)
StringArrayObjectDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -268,8 +268,8 @@ template <class S>
class FileArrayObjectDescriptor : public StringArrayObjectDescriptor<S>, public IFilePropertyDescriptor
{
public:
FileArrayObjectDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter, const char* file_type)
: StringArrayObjectDescriptor(allocator, name, getter, setter)
FileArrayObjectDescriptor(const char* name, Getter getter, Setter setter, const char* file_type, IAllocator& allocator)
: StringArrayObjectDescriptor(name, getter, setter, allocator)
, m_file_type(file_type, m_file_type_allocator)
{
m_type = IPropertyDescriptor::FILE;
@ -290,8 +290,8 @@ template <class S>
class ResourceArrayObjectDescriptor : public FileArrayObjectDescriptor<S>
{
public:
ResourceArrayObjectDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter, const char* file_type)
: FileArrayObjectDescriptor(allocator, name, getter, setter, file_type)
ResourceArrayObjectDescriptor(const char* name, Getter getter, Setter setter, const char* file_type, IAllocator& allocator)
: FileArrayObjectDescriptor(name, getter, setter, file_type, allocator)
{
m_type = IPropertyDescriptor::RESOURCE;
}
@ -357,7 +357,7 @@ class ArrayDescriptor : public IArrayDescriptor
typedef void (S::*Remover)(Component, int);
public:
ArrayDescriptor(IAllocator& allocator, const char* name, Counter counter, Adder adder, Remover remover)
ArrayDescriptor(const char* name, Counter counter, Adder adder, Remover remover, IAllocator& allocator)
: IArrayDescriptor(allocator)
, m_allocator(allocator)
{
@ -474,7 +474,7 @@ class StringPropertyDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, const string&);
public:
StringPropertyDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter)
StringPropertyDescriptor(const char* name, Getter getter, Setter setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -527,7 +527,7 @@ class BoolPropertyDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, bool);
public:
BoolPropertyDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter)
BoolPropertyDescriptor(const char* name, Getter getter, Setter setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -570,7 +570,7 @@ class Vec3PropertyDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, const Vec3&);
public:
Vec3PropertyDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter)
Vec3PropertyDescriptor(const char* name, Getter getter, Setter setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -616,8 +616,8 @@ template <class T>
class FilePropertyDescriptor : public StringPropertyDescriptor<T>, public IFilePropertyDescriptor
{
public:
FilePropertyDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter, const char* file_type)
: StringPropertyDescriptor(allocator, name, getter, setter)
FilePropertyDescriptor(const char* name, Getter getter, Setter setter, const char* file_type, IAllocator& allocator)
: StringPropertyDescriptor(name, getter, setter, allocator)
, m_file_type(file_type, m_file_type_allocator)
{
m_type = IPropertyDescriptor::FILE;
@ -638,8 +638,8 @@ template <class T>
class ResourcePropertyDescriptor : public FilePropertyDescriptor<T>
{
public:
ResourcePropertyDescriptor(IAllocator& allocator, const char* name, Getter getter, Setter setter, const char* file_type)
: FilePropertyDescriptor(allocator, name, getter, setter, file_type)
ResourcePropertyDescriptor(const char* name, Getter getter, Setter setter, const char* file_type, IAllocator& allocator)
: FilePropertyDescriptor(name, getter, setter, file_type, allocator)
{
m_type = IPropertyDescriptor::RESOURCE;
}
@ -655,7 +655,7 @@ class DecimalPropertyDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, float);
public:
DecimalPropertyDescriptor(IAllocator& allocator, const char* name, Getter _getter, Setter _setter)
DecimalPropertyDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);
@ -698,7 +698,7 @@ class ColorPropertyDescriptor : public IPropertyDescriptor
typedef void (S::*Setter)(Component, const Vec4&);
public:
ColorPropertyDescriptor(IAllocator& allocator, const char* name, Getter _getter, Setter _setter)
ColorPropertyDescriptor(const char* name, Getter _getter, Setter _setter, IAllocator& allocator)
: IPropertyDescriptor(allocator)
{
setName(name);

View file

@ -159,7 +159,7 @@ class PasteEntityCommand : public IEditorCommand
class MoveEntityCommand : public IEditorCommand
{
public:
MoveEntityCommand(IAllocator& allocator, const Array<Entity>& entities, const Array<Vec3>& new_positions, const Array<Quat>& new_rotations)
MoveEntityCommand(const Array<Entity>& entities, const Array<Vec3>& new_positions, const Array<Quat>& new_rotations, IAllocator& allocator)
: m_new_positions(allocator)
, m_new_rotations(allocator)
, m_old_positions(allocator)
@ -1332,7 +1332,7 @@ struct WorldEditorImpl : public WorldEditor
{
rots.push(entities[i].getRotation());
}
IEditorCommand* command = m_allocator.newObject<MoveEntityCommand>(m_allocator, entities, positions, rots);
IEditorCommand* command = m_allocator.newObject<MoveEntityCommand>(entities, positions, rots, m_allocator);
executeCommand(command);
}
}
@ -1342,7 +1342,7 @@ struct WorldEditorImpl : public WorldEditor
{
if (!entities.empty())
{
IEditorCommand* command = m_allocator.newObject<MoveEntityCommand>(m_allocator, entities, positions, rotations);
IEditorCommand* command = m_allocator.newObject<MoveEntityCommand>(entities, positions, rotations, m_allocator);
executeCommand(command);
}
}

View file

@ -42,8 +42,8 @@ namespace Lumix
class CullingJob : public MTJD::Job
{
public:
CullingJob(const CullingSystem::InputSpheres& spheres, const VisibilityFlags& visibility_flags, const LayerMasks& layer_masks, int64_t layer_mask,
CullingSystem::Subresults& results, int start, int end, const Frustum& frustum, MTJD::Manager& manager, IAllocator& allocator
CullingJob(const CullingSystem::InputSpheres& spheres, const VisibilityFlags& visibility_flags, const LayerMasks& layer_masks, int64_t layer_mask
, CullingSystem::Subresults& results, int start, int end, const Frustum& frustum, MTJD::Manager& manager, IAllocator& allocator
)
: Job(true, MTJD::Priority::Default, false, manager, allocator)
, m_spheres(spheres)

View file

@ -206,7 +206,7 @@ Geometry::~Geometry()
}
void Geometry::copy(IAllocator& allocator, const Geometry& source, int copy_count, IndexCallback index_callback, VertexCallback vertex_callback)
void Geometry::copy(const Geometry& source, int copy_count, IndexCallback index_callback, VertexCallback vertex_callback, IAllocator& allocator)
{
ASSERT(source.m_indices_data_size > 0);
ASSERT(m_indices_data_size == 0);

View file

@ -59,7 +59,7 @@ class Geometry
void setAttributesData(const void* data, int size);
void setIndicesData(const void* data, int size);
void bindBuffers() const;
void copy(IAllocator& allocator, const Geometry& source, int copy_count, IndexCallback index_callback, VertexCallback vertex_callback);
void copy(const Geometry& source, int copy_count, IndexCallback index_callback, VertexCallback vertex_callback, IAllocator& allocator);
void clear();
private:

View file

@ -380,7 +380,7 @@ void Material::loaded(FS::IFile* file, bool success, FS::FileSystem& fs)
PROFILE_FUNCTION();
if(success)
{
JsonSerializer serializer(m_allocator, *file, JsonSerializer::READ, m_path.c_str());
JsonSerializer serializer(*file, JsonSerializer::READ, m_path.c_str(), m_allocator);
serializer.deserializeObjectBegin();
char path[LUMIX_MAX_PATH];
char label[256];

View file

@ -355,7 +355,7 @@ bool Model::parseMeshes(FS::IFile* file)
VertexDef def;
parseVertexDef(file, &def);
m_meshes.emplace(m_allocator, def, material, attribute_array_offset, attribute_array_size, indices_offset, mesh_tri_count * 3, mesh_name);
m_meshes.emplace(def, material, attribute_array_offset, attribute_array_size, indices_offset, mesh_tri_count * 3, mesh_name, m_allocator);
addDependency(*material);
}
return true;

View file

@ -35,7 +35,7 @@ namespace FS
class Mesh
{
public:
Mesh(IAllocator& allocator, const VertexDef& def, Material* mat, int attribute_array_offset, int attribute_array_size, int indices_offset, int index_count, const char* name)
Mesh(const VertexDef& def, Material* mat, int attribute_array_offset, int attribute_array_size, int indices_offset, int index_count, const char* name, IAllocator& allocator)
: m_name(allocator)
, m_vertex_def(def)
{

View file

@ -382,7 +382,7 @@ struct PipelineImpl : public Pipeline
{
if(success)
{
JsonSerializer serializer(m_allocator, *file, JsonSerializer::READ, m_path.c_str());
JsonSerializer serializer(*file, JsonSerializer::READ, m_path.c_str(), m_allocator);
deserialize(serializer);
decrementDepCount();
}
@ -1109,7 +1109,7 @@ void DrawScreenQuadCommand::deserialize(PipelineImpl& pipeline, JsonSerializer&
char material_path[LUMIX_MAX_PATH];
serializer.deserializeArrayItem(material_path, LUMIX_MAX_PATH, "");
Material* material = static_cast<Material*>(pipeline.getResourceManager().get(ResourceManager::MATERIAL)->load(Path(material_path)));
m_mesh = m_allocator.newObject<Mesh>(m_allocator, def, material, 0, 0, sizeof(v), 6, "screen_quad");
m_mesh = m_allocator.newObject<Mesh>(def, material, 0, 0, sizeof(v), 6, "screen_quad", m_allocator);
}

View file

@ -63,7 +63,7 @@ namespace Lumix
class DebugTextsData
{
public:
DebugTextsData(IAllocator& allocator, Engine& engine)
DebugTextsData(Engine& engine, IAllocator& allocator)
: m_texts(allocator)
, m_allocator(allocator)
, m_font(NULL)
@ -202,7 +202,7 @@ namespace Lumix
m_allocator.deleteObject(m_mesh);
m_geometry.setAttributesData(&data[0], sizeof(data[0]) * data.size());
m_geometry.setIndicesData(&indices[0], sizeof(indices[0]) * indices.size());
m_mesh = m_allocator.newObject<Mesh>(m_allocator, vertex_definition, m_font->getMaterial(), 0, sizeof(data[0]) * data.size(), 0, indices.size(), "");
m_mesh = m_allocator.newObject<Mesh>(vertex_definition, m_font->getMaterial(), 0, sizeof(data[0]) * data.size(), 0, indices.size(), "debug_texts", m_allocator);
}
private:
@ -320,7 +320,7 @@ namespace Lumix
, m_temporary_infos(m_allocator)
, m_sync_point(true, m_allocator)
, m_jobs(m_allocator)
, m_debug_texts(m_allocator, engine)
, m_debug_texts(engine, m_allocator)
{
m_universe.entityMoved().bind<RenderSceneImpl, &RenderSceneImpl::onEntityMoved>(this);
m_timer = Timer::create(m_allocator);
@ -1103,7 +1103,7 @@ namespace Lumix
{
Array<RenderableInfo>& subinfos = m_temporary_infos[subresult_index];
subinfos.clear();
MTJD::Job* job = MTJD::makeJob(m_allocator, m_engine.getMTJDManager(), [&subinfos, layer_mask, this, &results, subresult_index, &frustum]()
MTJD::Job* job = MTJD::makeJob(m_engine.getMTJDManager(), [&subinfos, layer_mask, this, &results, subresult_index, &frustum]()
{
Vec3 frustum_position = frustum.getPosition();
const CullingSystem::Subresults& subresults = results[subresult_index];
@ -1123,7 +1123,9 @@ namespace Lumix
}
}
}
});
}
, m_allocator
);
job->addDependency(&m_sync_point);
m_jobs.push(job);
}

View file

@ -305,31 +305,31 @@ struct RendererImpl : public Renderer
WorldEditor& editor = *engine.getWorldEditor();
IAllocator& allocator = editor.getAllocator();
editor.registerProperty("camera", allocator.newObject<StringPropertyDescriptor<RenderScene> >(allocator, "slot", &RenderScene::getCameraSlot, &RenderScene::setCameraSlot));
editor.registerProperty("camera", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "fov", &RenderScene::getCameraFOV, &RenderScene::setCameraFOV));
editor.registerProperty("camera", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "near", &RenderScene::getCameraNearPlane, &RenderScene::setCameraNearPlane));
editor.registerProperty("camera", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "far", &RenderScene::getCameraFarPlane, &RenderScene::setCameraFarPlane));
editor.registerProperty("camera", allocator.newObject<StringPropertyDescriptor<RenderScene> >("slot", &RenderScene::getCameraSlot, &RenderScene::setCameraSlot, allocator));
editor.registerProperty("camera", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("fov", &RenderScene::getCameraFOV, &RenderScene::setCameraFOV, allocator));
editor.registerProperty("camera", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("near", &RenderScene::getCameraNearPlane, &RenderScene::setCameraNearPlane, allocator));
editor.registerProperty("camera", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("far", &RenderScene::getCameraFarPlane, &RenderScene::setCameraFarPlane, allocator));
editor.registerProperty("renderable", allocator.newObject<ResourcePropertyDescriptor<RenderScene> >(allocator, "source", &RenderScene::getRenderablePath, &RenderScene::setRenderablePath, "Mesh (*.msh)"));
editor.registerProperty("renderable", allocator.newObject<BoolPropertyDescriptor<RenderScene> >(allocator, "is_always_visible", &RenderScene::isRenderableAlwaysVisible, &RenderScene::setRenderableIsAlwaysVisible));
editor.registerProperty("renderable", allocator.newObject<ResourcePropertyDescriptor<RenderScene> >("source", &RenderScene::getRenderablePath, &RenderScene::setRenderablePath, "Mesh (*.msh)", allocator));
editor.registerProperty("renderable", allocator.newObject<BoolPropertyDescriptor<RenderScene> >("is_always_visible", &RenderScene::isRenderableAlwaysVisible, &RenderScene::setRenderableIsAlwaysVisible, allocator));
editor.registerProperty("light", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "ambient_intensity", &RenderScene::getLightAmbientIntensity, &RenderScene::setLightAmbientIntensity));
editor.registerProperty("light", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "diffuse_intensity", &RenderScene::getLightDiffuseIntensity, &RenderScene::setLightDiffuseIntensity));
editor.registerProperty("light", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "fog_density", &RenderScene::getFogDensity, &RenderScene::setFogDensity));
editor.registerProperty("light", allocator.newObject<ColorPropertyDescriptor<RenderScene> >(allocator, "ambient_color", &RenderScene::getLightAmbientColor, &RenderScene::setLightAmbientColor));
editor.registerProperty("light", allocator.newObject<ColorPropertyDescriptor<RenderScene> >(allocator, "diffuse_color", &RenderScene::getLightDiffuseColor, &RenderScene::setLightDiffuseColor));
editor.registerProperty("light", allocator.newObject<ColorPropertyDescriptor<RenderScene> >(allocator, "fog_color", &RenderScene::getFogColor, &RenderScene::setFogColor));
editor.registerProperty("light", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("ambient_intensity", &RenderScene::getLightAmbientIntensity, &RenderScene::setLightAmbientIntensity, allocator));
editor.registerProperty("light", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("diffuse_intensity", &RenderScene::getLightDiffuseIntensity, &RenderScene::setLightDiffuseIntensity, allocator));
editor.registerProperty("light", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("fog_density", &RenderScene::getFogDensity, &RenderScene::setFogDensity, allocator));
editor.registerProperty("light", allocator.newObject<ColorPropertyDescriptor<RenderScene> >("ambient_color", &RenderScene::getLightAmbientColor, &RenderScene::setLightAmbientColor, allocator));
editor.registerProperty("light", allocator.newObject<ColorPropertyDescriptor<RenderScene> >("diffuse_color", &RenderScene::getLightDiffuseColor, &RenderScene::setLightDiffuseColor, allocator));
editor.registerProperty("light", allocator.newObject<ColorPropertyDescriptor<RenderScene> >("fog_color", &RenderScene::getFogColor, &RenderScene::setFogColor, allocator));
editor.registerProperty("terrain", allocator.newObject<ResourcePropertyDescriptor<RenderScene> >(allocator, "material", &RenderScene::getTerrainMaterial, &RenderScene::setTerrainMaterial, "Material (*.mat)"));
editor.registerProperty("terrain", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "xz_scale", &RenderScene::getTerrainXZScale, &RenderScene::setTerrainXZScale));
editor.registerProperty("terrain", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >(allocator, "y_scale", &RenderScene::getTerrainYScale, &RenderScene::setTerrainYScale));
editor.registerProperty("terrain", allocator.newObject<ResourcePropertyDescriptor<RenderScene> >("material", &RenderScene::getTerrainMaterial, &RenderScene::setTerrainMaterial, "Material (*.mat)", allocator));
editor.registerProperty("terrain", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("xz_scale", &RenderScene::getTerrainXZScale, &RenderScene::setTerrainXZScale, allocator));
editor.registerProperty("terrain", allocator.newObject<DecimalPropertyDescriptor<RenderScene> >("y_scale", &RenderScene::getTerrainYScale, &RenderScene::setTerrainYScale, allocator));
auto grass = allocator.newObject<ArrayDescriptor<RenderScene> >(allocator, "grass", &RenderScene::getGrassCount, &RenderScene::addGrass, &RenderScene::removeGrass);
grass->addChild(allocator.newObject<ResourceArrayObjectDescriptor<RenderScene> >(allocator, "mesh", &RenderScene::getGrass, &RenderScene::setGrass, "Mesh (*.msh)"));
auto ground = allocator.newObject<IntArrayObjectDescriptor<RenderScene> >(allocator, "ground", &RenderScene::getGrassGround, &RenderScene::setGrassGround);
auto grass = allocator.newObject<ArrayDescriptor<RenderScene> >("grass", &RenderScene::getGrassCount, &RenderScene::addGrass, &RenderScene::removeGrass, allocator);
grass->addChild(allocator.newObject<ResourceArrayObjectDescriptor<RenderScene> >("mesh", &RenderScene::getGrass, &RenderScene::setGrass, "Mesh (*.msh)", allocator));
auto ground = allocator.newObject<IntArrayObjectDescriptor<RenderScene> >("ground", &RenderScene::getGrassGround, &RenderScene::setGrassGround, allocator);
ground->setLimit(0, 4);
grass->addChild(ground);
grass->addChild(allocator.newObject<IntArrayObjectDescriptor<RenderScene> >(allocator, "density", &RenderScene::getGrassDensity, &RenderScene::setGrassDensity));
grass->addChild(allocator.newObject<IntArrayObjectDescriptor<RenderScene> >("density", &RenderScene::getGrassDensity, &RenderScene::setGrassDensity, allocator));
editor.registerProperty("terrain", grass);
}
}

View file

@ -180,7 +180,7 @@ void Shader::loaded(FS::IFile* file, bool success, FS::FileSystem& fs)
{
if(success)
{
JsonSerializer serializer(m_allocator, *file, JsonSerializer::READ, m_path.c_str());
JsonSerializer serializer(*file, JsonSerializer::READ, m_path.c_str(), m_allocator);
serializer.deserializeObjectBegin();
m_passes.clear();
m_pass_hashes.clear();

View file

@ -506,10 +506,10 @@ namespace Lumix
Geometry::IndexCallback index_callback;
vertex_callback.bind<GrassType, &GrassType::grassVertexCopyCallback>(this);
index_callback.bind<GrassType, &GrassType::grassIndexCopyCallback>(this);
m_grass_geometry->copy(allocator, m_grass_model->getGeometry(), COPY_COUNT, index_callback, vertex_callback);
m_grass_geometry->copy(m_grass_model->getGeometry(), COPY_COUNT, index_callback, vertex_callback, allocator);
Material* material = m_grass_model->getMesh(0).getMaterial();
const Mesh& src_mesh = m_grass_model->getMesh(0);
m_grass_mesh = allocator.newObject<Mesh>(allocator, src_mesh.getVertexDefinition(), material, 0, src_mesh.getAttributeArraySize(), 0, src_mesh.getIndexCount() * COPY_COUNT, "grass");
m_grass_mesh = allocator.newObject<Mesh>(src_mesh.getVertexDefinition(), material, 0, src_mesh.getAttributeArraySize(), 0, src_mesh.getIndexCount() * COPY_COUNT, "grass", allocator);
m_terrain.forceGrassUpdate();
}
}
@ -853,7 +853,7 @@ namespace Lumix
vertex_def.parse("pt", 2);
m_geometry.setAttributesData(&points[0], sizeof(points[0]) * points.size());
m_geometry.setIndicesData(&indices[0], sizeof(indices[0]) * indices.size());
m_mesh = m_allocator.newObject<Mesh>(m_allocator, vertex_def, m_material, 0, 0, points.size() * sizeof(points[0]), indices.size(), "terrain");
m_mesh = m_allocator.newObject<Mesh>(vertex_def, m_material, 0, 0, points.size() * sizeof(points[0]), indices.size(), "terrain", m_allocator);
}
TerrainQuad* Terrain::generateQuadTree(float size)

View file

@ -110,12 +110,12 @@ void PhysicsSystemImpl::registerProperties(Engine& engine)
if(editor)
{
IAllocator& allocator = editor->getAllocator();
editor->registerProperty("box_rigid_actor", allocator.newObject<BoolPropertyDescriptor<PhysicsScene> >(allocator, "dynamic", &PhysicsScene::isDynamic, &PhysicsScene::setIsDynamic));
editor->registerProperty("box_rigid_actor", allocator.newObject<Vec3PropertyDescriptor<PhysicsScene> >(allocator, "size", &PhysicsScene::getHalfExtents, &PhysicsScene::setHalfExtents));
editor->registerProperty("mesh_rigid_actor", allocator.newObject<FilePropertyDescriptor<PhysicsScene> >(allocator, "source", &PhysicsScene::getShapeSource, &PhysicsScene::setShapeSource, "Physics (*.pda)"));
editor->registerProperty("physical_heightfield", allocator.newObject<ResourcePropertyDescriptor<PhysicsScene> >(allocator, "heightmap", &PhysicsScene::getHeightmap, &PhysicsScene::setHeightmap, "Image (*.raw)"));
editor->registerProperty("physical_heightfield", allocator.newObject<DecimalPropertyDescriptor<PhysicsScene> >(allocator, "xz_scale", &PhysicsScene::getHeightmapXZScale, &PhysicsScene::setHeightmapXZScale));
editor->registerProperty("physical_heightfield", allocator.newObject<DecimalPropertyDescriptor<PhysicsScene> >(allocator, "y_scale", &PhysicsScene::getHeightmapYScale, &PhysicsScene::setHeightmapYScale));
editor->registerProperty("box_rigid_actor", allocator.newObject<BoolPropertyDescriptor<PhysicsScene> >("dynamic", &PhysicsScene::isDynamic, &PhysicsScene::setIsDynamic, allocator));
editor->registerProperty("box_rigid_actor", allocator.newObject<Vec3PropertyDescriptor<PhysicsScene> >("size", &PhysicsScene::getHalfExtents, &PhysicsScene::setHalfExtents, allocator));
editor->registerProperty("mesh_rigid_actor", allocator.newObject<FilePropertyDescriptor<PhysicsScene> >("source", &PhysicsScene::getShapeSource, &PhysicsScene::setShapeSource, "Physics (*.pda)", allocator));
editor->registerProperty("physical_heightfield", allocator.newObject<ResourcePropertyDescriptor<PhysicsScene> >("heightmap", &PhysicsScene::getHeightmap, &PhysicsScene::setHeightmap, "Image (*.raw)", allocator));
editor->registerProperty("physical_heightfield", allocator.newObject<DecimalPropertyDescriptor<PhysicsScene> >("xz_scale", &PhysicsScene::getHeightmapXZScale, &PhysicsScene::setHeightmapXZScale, allocator));
editor->registerProperty("physical_heightfield", allocator.newObject<DecimalPropertyDescriptor<PhysicsScene> >("y_scale", &PhysicsScene::getHeightmapYScale, &PhysicsScene::setHeightmapYScale, allocator));
}
}

View file

@ -351,7 +351,7 @@ namespace Lumix
if (m_engine.getWorldEditor())
{
IAllocator& allocator = m_engine.getWorldEditor()->getAllocator();
m_engine.getWorldEditor()->registerProperty("script", allocator.newObject<FilePropertyDescriptor<ScriptSceneImpl> >(allocator, "source", &ScriptSceneImpl::getScriptPath, &ScriptSceneImpl::setScriptPath, "Script (*.cpp)"));
m_engine.getWorldEditor()->registerProperty("script", allocator.newObject<FilePropertyDescriptor<ScriptSceneImpl> >("source", &ScriptSceneImpl::getScriptPath, &ScriptSceneImpl::setScriptPath, "Script (*.cpp)", allocator));
}
return true;
}

View file

@ -975,7 +975,7 @@ void createEditor(PropertyView& view, QTreeWidgetItem* item, InstanceObject<Lumi
if(file)
{
Lumix::DefaultAllocator allocator;
Lumix::JsonSerializer serializer(allocator, *file, Lumix::JsonSerializer::AccessMode::WRITE, material->getValue()->getPath().c_str());
Lumix::JsonSerializer serializer(*file, Lumix::JsonSerializer::AccessMode::WRITE, material->getValue()->getPath().c_str(), allocator);
material->getValue()->save(serializer);
fs.close(file);