This commit is contained in:
Mikulas Florek 2020-01-07 19:17:48 +01:00
parent 4562e3d3aa
commit 5e4c668440
35 changed files with 1333 additions and 1371 deletions

View file

@ -357,11 +357,11 @@ struct AnimationSceneImpl final : public AnimationScene
animator.resource->destroyRuntime(*animator.ctx);
animator.ctx = nullptr;
}
animator.resource->getObserverCb().unbind<AnimationSceneImpl, &AnimationSceneImpl::onControllerResourceChanged>(this);
animator.resource->getObserverCb().unbind<&AnimationSceneImpl::onControllerResourceChanged>(this);
}
animator.resource = res;
if (animator.resource != nullptr) {
animator.resource->onLoaded<AnimationSceneImpl, &AnimationSceneImpl::onControllerResourceChanged>(this);
animator.resource->onLoaded<&AnimationSceneImpl::onControllerResourceChanged>(this);
}
}

View file

@ -116,8 +116,8 @@ struct ClipManagerUI final : public StudioApp::GUIPlugin
m_filter[0] = 0;
m_is_open = false;
Action* action = LUMIX_NEW(app.getWorldEditor().getAllocator(), Action)("Clip manager", "Toggle clip manager", "clip_manager");
action->func.bind<ClipManagerUI, &ClipManagerUI::onAction>(this);
action->is_selected.bind<ClipManagerUI, &ClipManagerUI::isOpen>(this);
action->func.bind<&ClipManagerUI::onAction>(this);
action->is_selected.bind<&ClipManagerUI::isOpen>(this);
app.addWindowAction(action);
}

View file

@ -53,10 +53,10 @@ AssetBrowser::AssetBrowser(StudioApp& app)
m_back_action = LUMIX_NEW(allocator, Action)("Back", "Back in asset history", "back");
m_back_action->is_global = false;
m_back_action->func.bind<AssetBrowser, &AssetBrowser::goBack>(this);
m_back_action->func.bind<&AssetBrowser::goBack>(this);
m_forward_action = LUMIX_NEW(allocator, Action)("Forward", "Forward in asset history", "forward");
m_forward_action->is_global = false;
m_forward_action->func.bind<AssetBrowser, &AssetBrowser::goForward>(this);
m_forward_action->func.bind<&AssetBrowser::goForward>(this);
m_app.addAction(m_back_action);
m_app.addAction(m_forward_action);
}

View file

@ -96,7 +96,7 @@ struct AssetCompilerImpl : AssetCompiler
{
FileSystem& fs = app.getWorldEditor().getEngine().getFileSystem();
m_watcher = FileSystemWatcher::create(fs.getBasePath(), app.getWorldEditor().getAllocator());
m_watcher->getCallback().bind<AssetCompilerImpl, &AssetCompilerImpl::onFileChanged>(this);
m_watcher->getCallback().bind<&AssetCompilerImpl::onFileChanged>(this);
m_task.create("Asset compiler", true);
const char* base_path = m_app.getWorldEditor().getEngine().getFileSystem().getBasePath();
StaticString<MAX_PATH_LENGTH> path(base_path, ".lumix/assets");

View file

@ -64,25 +64,25 @@ struct EditorIconsImpl final : public EditorIcons
{
m_render_interface = nullptr;
m_icons.reserve(200);
editor.universeDestroyed().bind<EditorIconsImpl, &EditorIconsImpl::clear>(this);
editor.universeCreated().bind<EditorIconsImpl, &EditorIconsImpl::onUniverseCreated>(this);
editor.universeDestroyed().bind<&EditorIconsImpl::clear>(this);
editor.universeCreated().bind<&EditorIconsImpl::onUniverseCreated>(this);
if (m_editor.getUniverse()) onUniverseCreated();
}
~EditorIconsImpl()
{
m_editor.universeDestroyed().unbind<EditorIconsImpl, &EditorIconsImpl::clear>(this);
m_editor.universeCreated().unbind<EditorIconsImpl, &EditorIconsImpl::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<&EditorIconsImpl::clear>(this);
m_editor.universeCreated().unbind<&EditorIconsImpl::onUniverseCreated>(this);
setRenderInterface(nullptr);
if(m_editor.getUniverse())
{
auto& universe = *m_editor.getUniverse();
universe.entityCreated().unbind<EditorIconsImpl, &EditorIconsImpl::onEntityCreated>(this);
universe.entityDestroyed().unbind<EditorIconsImpl, &EditorIconsImpl::destroyIcon>(this);
universe.componentAdded().unbind<EditorIconsImpl, &EditorIconsImpl::refreshIcon>(this);
universe.componentDestroyed().unbind<EditorIconsImpl, &EditorIconsImpl::refreshIcon>(this);
universe.entityCreated().unbind<&EditorIconsImpl::onEntityCreated>(this);
universe.entityDestroyed().unbind<&EditorIconsImpl::destroyIcon>(this);
universe.componentAdded().unbind<&EditorIconsImpl::refreshIcon>(this);
universe.componentDestroyed().unbind<&EditorIconsImpl::refreshIcon>(this);
}
}
@ -90,10 +90,10 @@ struct EditorIconsImpl final : public EditorIcons
void onUniverseCreated()
{
auto& universe = *m_editor.getUniverse();
universe.entityCreated().bind<EditorIconsImpl, &EditorIconsImpl::onEntityCreated>(this);
universe.entityDestroyed().bind<EditorIconsImpl, &EditorIconsImpl::destroyIcon>(this);
universe.componentAdded().bind<EditorIconsImpl, &EditorIconsImpl::refreshIcon>(this);
universe.componentDestroyed().bind<EditorIconsImpl, &EditorIconsImpl::refreshIcon>(this);
universe.entityCreated().bind<&EditorIconsImpl::onEntityCreated>(this);
universe.entityDestroyed().bind<&EditorIconsImpl::destroyIcon>(this);
universe.componentAdded().bind<&EditorIconsImpl::refreshIcon>(this);
universe.componentDestroyed().bind<&EditorIconsImpl::refreshIcon>(this);
}

View file

@ -77,13 +77,13 @@ struct GizmoImpl final : public Gizmo
m_steps[int(Mode::TRANSLATE)] = 10;
m_steps[int(Mode::ROTATE)] = 45;
m_steps[int(Mode::SCALE)] = 1;
editor.universeDestroyed().bind<GizmoImpl, &GizmoImpl::onUniverseDestroyed>(this);
editor.universeDestroyed().bind<&GizmoImpl::onUniverseDestroyed>(this);
}
~GizmoImpl()
{
m_editor.universeDestroyed().unbind<GizmoImpl, &GizmoImpl::onUniverseDestroyed>(this);
m_editor.universeDestroyed().unbind<&GizmoImpl::onUniverseDestroyed>(this);
}

View file

@ -20,7 +20,7 @@ LogUI::LogUI(IAllocator& allocator)
, m_are_notifications_hovered(false)
, m_move_notifications_to_front(false)
{
getLogCallback().bind<LogUI, &LogUI::onLog>(this);
getLogCallback().bind<&LogUI::onLog>(this);
for (int i = 0; i < (int)LogLevel::COUNT; ++i)
{
@ -31,7 +31,7 @@ LogUI::LogUI(IAllocator& allocator)
LogUI::~LogUI()
{
getLogCallback().unbind<LogUI, &LogUI::onLog>(this);
getLogCallback().unbind<&LogUI::onLog>(this);
}

View file

@ -172,18 +172,16 @@ public:
, m_prefabs(editor.getAllocator())
, m_deferred_instances(editor.getAllocator())
{
editor.universeCreated().bind<PrefabSystemImpl, &PrefabSystemImpl::onUniverseCreated>(this);
editor.universeDestroyed().bind<PrefabSystemImpl, &PrefabSystemImpl::onUniverseDestroyed>(this);
editor.universeCreated().bind<&PrefabSystemImpl::onUniverseCreated>(this);
editor.universeDestroyed().bind<&PrefabSystemImpl::onUniverseDestroyed>(this);
setUniverse(editor.getUniverse());
}
~PrefabSystemImpl()
{
m_editor.universeCreated()
.unbind<PrefabSystemImpl, &PrefabSystemImpl::onUniverseCreated>(this);
m_editor.universeDestroyed()
.unbind<PrefabSystemImpl, &PrefabSystemImpl::onUniverseDestroyed>(this);
m_editor.universeCreated().unbind<&PrefabSystemImpl::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<&PrefabSystemImpl::onUniverseDestroyed>(this);
setUniverse(nullptr);
}
@ -195,15 +193,12 @@ public:
{
if (m_universe)
{
m_universe->entityDestroyed()
.unbind<PrefabSystemImpl, &PrefabSystemImpl::onEntityDestroyed>(
this);
m_universe->entityDestroyed().unbind<&PrefabSystemImpl::onEntityDestroyed>(this);
}
m_universe = universe;
if (m_universe)
{
m_universe->entityDestroyed()
.bind<PrefabSystemImpl, &PrefabSystemImpl::onEntityDestroyed>(this);
m_universe->entityDestroyed().bind<&PrefabSystemImpl::onEntityDestroyed>(this);
}
}
@ -580,7 +575,7 @@ public:
m_editor.destroyEntities(&entities[0], entities.size());
auto* res = m_editor.getEngine().getResourceManager().load<PrefabResource>(path);
FileSystem& fs = m_editor.getEngine().getFileSystem();
while (fs.hasWork()) fs.updateAsyncTransactions();
while (fs.hasWork()) fs.processCallbacks();
instantiatePrefab(*res, tr.pos, tr.rot, tr.scale);
m_editor.endCommandGroup();

View file

@ -111,7 +111,7 @@ struct ProfilerUIImpl final : public ProfilerUI
{
while (m_engine.getFileSystem().hasWork())
{
m_engine.getFileSystem().updateAsyncTransactions();
m_engine.getFileSystem().processCallbacks();
}
m_allocation_root->clear(m_allocator);

View file

@ -106,7 +106,7 @@ struct LuaPlugin : public StudioApp::GUIPlugin
lua_pop(L, 2); // []
Action* action = LUMIX_NEW(editor.getAllocator(), Action)(name, name, name);
action->func.bind<LuaPlugin, &LuaPlugin::onAction>(this);
action->func.bind<&LuaPlugin::onAction>(this);
app.addWindowAction(action);
m_is_open = false;
@ -292,14 +292,14 @@ public:
update();
if (m_sleep_when_inactive && !isFocused()) {
const float frame_time = m_fps_timer.tick();
const float frame_time = m_inactive_fps_timer.tick();
const float wanted_fps = 5.0f;
if (frame_time < 1 / wanted_fps) {
PROFILE_BLOCK("sleep");
MT::sleep(u32(1000 / wanted_fps - frame_time * 1000));
}
m_fps_timer.tick();
m_inactive_fps_timer.tick();
}
Profiler::frame();
@ -445,7 +445,7 @@ public:
while (m_editor->getEngine().getFileSystem().hasWork())
{
m_editor->getEngine().getFileSystem().updateAsyncTransactions();
m_editor->getEngine().getFileSystem().processCallbacks();
}
m_editor->newUniverse();
@ -848,6 +848,13 @@ public:
m_editor->update();
m_engine->update(*m_editor->getUniverse());
++m_fps_frame;
if (m_fps_timer.getTimeSinceTick() > 1.0f)
{
m_fps = m_fps_frame / m_fps_timer.tick();
m_fps_frame = 0;
}
if (m_deferred_game_mode_exit)
{
m_deferred_game_mode_exit = false;
@ -1296,7 +1303,7 @@ public:
Action& addAction(const char* label_short, const char* label_long, const char* name)
{
auto* a = LUMIX_NEW(m_editor->getAllocator(), Action)(label_short, label_long, name);
a->func.bind<StudioAppImpl, Func>(this);
a->func.bind<Func>(this);
addAction(a);
return *a;
}
@ -1312,7 +1319,7 @@ public:
{
auto* a =
LUMIX_NEW(m_editor->getAllocator(), Action)(label_short, label_long, name, shortcut0, shortcut1, shortcut2);
a->func.bind<StudioAppImpl, Func>(this);
a->func.bind<Func>(this);
addAction(a);
}
@ -1560,7 +1567,7 @@ public:
StaticString<200> stats("");
if (m_engine->getFileSystem().hasWork()) stats << "Loading... | ";
stats << "FPS: ";
stats << (u32)(m_engine->getFPS() + 0.5f);
stats << (u32)(m_fps + 0.5f);
if (!isFocused()) stats << " - inactive window";
auto stats_size = ImGui::CalcTextSize(stats);
ImGui::SameLine(ImGui::GetContentRegionMax().x - stats_size.x);
@ -2013,24 +2020,24 @@ public:
addAction<&StudioAppImpl::duplicate>(
ICON_FA_FILES_O "Duplicate", "Duplicate entity", "duplicate", OS::Keycode::LCTRL, OS::Keycode::D, OS::Keycode::INVALID);
addAction<&StudioAppImpl::toggleOrbitCamera>(NO_ICON "Orbit camera", "Orbit camera", "orbitCamera")
.is_selected.bind<StudioAppImpl, &StudioAppImpl::isOrbitCamera>(this);
.is_selected.bind<&StudioAppImpl::isOrbitCamera>(this);
addAction<&StudioAppImpl::setTranslateGizmoMode>(ICON_FA_ARROWS "Translate", "Set translate mode", "setTranslateGizmoMode")
.is_selected.bind<Gizmo, &Gizmo::isTranslateMode>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isTranslateMode>(&m_editor->getGizmo());
addAction<&StudioAppImpl::setRotateGizmoMode>(ICON_FA_REPEAT "Rotate", "Set rotate mode", "setRotateGizmoMode")
.is_selected.bind<Gizmo, &Gizmo::isRotateMode>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isRotateMode>(&m_editor->getGizmo());
addAction<&StudioAppImpl::setScaleGizmoMode>(NO_ICON "Scale", "Set scale mode", "setScaleGizmoMode")
.is_selected.bind<Gizmo, &Gizmo::isScaleMode>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isScaleMode>(&m_editor->getGizmo());
addAction<&StudioAppImpl::setTopView>(NO_ICON "Top", "Set top camera view", "viewTop");
addAction<&StudioAppImpl::setFrontView>(NO_ICON "Front", "Set front camera view", "viewFront");
addAction<&StudioAppImpl::setSideView>(NO_ICON "Side", "Set side camera view", "viewSide");
addAction<&StudioAppImpl::setLocalCoordSystem>(NO_ICON "Local", "Set local transform system", "setLocalCoordSystem")
.is_selected.bind<Gizmo, &Gizmo::isLocalCoordSystem>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isLocalCoordSystem>(&m_editor->getGizmo());
addAction<&StudioAppImpl::setGlobalCoordSystem>(ICON_FA_GLOBE "Global", "Set global transform system", "setGlobalCoordSystem")
.is_selected.bind<Gizmo, &Gizmo::isGlobalCoordSystem>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isGlobalCoordSystem>(&m_editor->getGizmo());
addAction<&StudioAppImpl::setPivotCenter>(ICON_FA_ALIGN_CENTER "Center", "Set center transform system", "setPivotCenter")
.is_selected.bind<Gizmo, &Gizmo::isPivotCenter>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isPivotCenter>(&m_editor->getGizmo());
addAction<&StudioAppImpl::setPivotOrigin>(NO_ICON "Pivot", "Set pivot transform system", "setPivotOrigin")
.is_selected.bind<Gizmo, &Gizmo::isPivotOrigin>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isPivotOrigin>(&m_editor->getGizmo());
addAction<&StudioAppImpl::addEntity>(ICON_FA_PLUS_SQUARE_O "Create empty", "Create empty entity", "createEntity");
addAction<&StudioAppImpl::destroySelectedEntity>(ICON_FA_MINUS_SQUARE_O "Destroy",
@ -2044,21 +2051,21 @@ public:
addAction<&StudioAppImpl::unparent>(ICON_FA_OBJECT_UNGROUP "Unparent", "Unparent entity", "unparent");
addAction<&StudioAppImpl::toggleGameMode>(ICON_FA_PLAY "Game Mode", "Toggle game mode", "toggleGameMode")
.is_selected.bind<WorldEditor, &WorldEditor::isGameMode>(m_editor);
.is_selected.bind<&WorldEditor::isGameMode>(m_editor);
addAction<&StudioAppImpl::toggleMeasure>(NO_ICON "Toggle measure", "Toggle measure mode", "toggleMeasure")
.is_selected.bind<WorldEditor, &WorldEditor::isMeasureToolActive>(m_editor);
.is_selected.bind<&WorldEditor::isMeasureToolActive>(m_editor);
addAction<&StudioAppImpl::autosnapDown>(NO_ICON "Autosnap down", "Toggle autosnap down", "autosnapDown")
.is_selected.bind<Gizmo, &Gizmo::isAutosnapDown>(&m_editor->getGizmo());
.is_selected.bind<&Gizmo::isAutosnapDown>(&m_editor->getGizmo());
addAction<&StudioAppImpl::snapDown>(NO_ICON "Snap down", "Snap entities down", "snapDown");
addAction<&StudioAppImpl::setEditCamTransform>(NO_ICON "Camera transform", "Set camera transformation", "setEditCamTransform");
addAction<&StudioAppImpl::copyViewTransform>(NO_ICON "Copy view transform", "Copy view transform", "copyViewTransform");
addAction<&StudioAppImpl::lookAtSelected>(NO_ICON "Look at selected", "Look at selected entity", "lookAtSelected");
addAction<&StudioAppImpl::toggleAssetBrowser>(ICON_FA_CUBES "Asset Browser", "Toggle asset browser", "assetBrowser")
.is_selected.bind<StudioAppImpl, &StudioAppImpl::isAssetBrowserOpen>(this);
.is_selected.bind<&StudioAppImpl::isAssetBrowserOpen>(this);
addAction<&StudioAppImpl::toggleEntityList>(ICON_FA_LIST "Entity List", "Toggle entity list", "entityList")
.is_selected.bind<StudioAppImpl, &StudioAppImpl::isEntityListOpen>(this);
.is_selected.bind<&StudioAppImpl::isEntityListOpen>(this);
addAction<&StudioAppImpl::toggleSettings>(ICON_FA_COGS "Settings", "Toggle settings UI", "settings")
.is_selected.bind<StudioAppImpl, &StudioAppImpl::areSettingsOpen>(this);
.is_selected.bind<&StudioAppImpl::areSettingsOpen>(this);
addAction<&StudioAppImpl::showPackDataDialog>(ICON_FA_FILE_ARCHIVE_O "Pack data", "Pack data", "pack_data");
}
@ -2138,7 +2145,7 @@ public:
m_watched_plugin.basename = basename;
PathUtils::getDir(Span(dir), src);
m_watched_plugin.watcher = FileSystemWatcher::create(dir, m_allocator);
m_watched_plugin.watcher->getCallback().bind<StudioAppImpl, &StudioAppImpl::onPluginChanged>(this);
m_watched_plugin.watcher->getCallback().bind<&StudioAppImpl::onPluginChanged>(this);
m_watched_plugin.dir = dir;
m_watched_plugin.plugin = loaded_plugin;
}
@ -3134,10 +3141,13 @@ public:
Settings m_settings;
Array<OS::Event> m_events;
Vec2 m_mouse_move;
OS::Timer m_fps_timer;
char m_template_name[100];
char m_open_filter[64];
char m_component_filter[32];
float m_fps = 0;
OS::Timer m_fps_timer;
OS::Timer m_inactive_fps_timer;
u32 m_fps_frame = 0;
struct PackConfig
{

View file

@ -2074,7 +2074,7 @@ public:
void save(IOutputStream& file)
{
while (m_engine.getFileSystem().hasWork()) m_engine.getFileSystem().updateAsyncTransactions();
while (m_engine.getFileSystem().hasWork()) m_engine.getFileSystem().processCallbacks();
ASSERT(m_universe);
@ -2563,7 +2563,7 @@ public:
m_universe = &m_engine.createUniverse(true);
m_universe_created.invoke();
m_universe->setName(name);
m_universe->entityDestroyed().bind<WorldEditorImpl, &WorldEditorImpl::onEntityDestroyed>(this);
m_universe->entityDestroyed().bind<&WorldEditorImpl::onEntityDestroyed>(this);
m_selected_entities.clear();
InputMemoryStream file(m_game_mode_file);
load(file);
@ -3097,7 +3097,7 @@ public:
m_universe = &m_engine.createUniverse(true);
Universe* universe = m_universe;
universe->entityDestroyed().bind<WorldEditorImpl, &WorldEditorImpl::onEntityDestroyed>(this);
universe->entityDestroyed().bind<&WorldEditorImpl::onEntityDestroyed>(this);
m_is_orbit = false;
m_selected_entities.clear();

View file

@ -22,19 +22,19 @@ private:
InternalFunction second;
};
template <R (*Function)(Args...)> static LUMIX_FORCE_INLINE R FunctionStub(InstancePtr, Args... args)
template <R (*Function)(Args...)> static R FunctionStub(InstancePtr, Args... args)
{
return (Function)(args...);
}
template <class C, R(C::*Function)(Args...)>
static LUMIX_FORCE_INLINE R ClassMethodStub(InstancePtr instance, Args... args)
static R ClassMethodStub(InstancePtr instance, Args... args)
{
return (static_cast<C*>(instance)->*Function)(args...);
}
template <class C, R(C::*Function)(Args...) const>
static LUMIX_FORCE_INLINE R ClassMethodStub(InstancePtr instance, Args... args)
static R ClassMethodStub(InstancePtr instance, Args... args)
{
return (static_cast<C*>(instance)->*Function)(args...);
}
@ -54,16 +54,10 @@ public:
m_stub.second = &FunctionStub<Function>;
}
template <class C, R (C::*Function)(Args...)> void bind(C* instance)
template <auto F, class C> void bind(C* instance)
{
m_stub.first = instance;
m_stub.second = &ClassMethodStub<C, Function>;
}
template <class C, R(C::*Function)(Args...) const> void bind(C* instance)
{
m_stub.first = instance;
m_stub.second = &ClassMethodStub<C, Function>;
m_stub.second = &ClassMethodStub<C, F>;
}
R invoke(Args... args) const

View file

@ -17,10 +17,10 @@ public:
{
}
template <typename C, R (C::*Function)(Args...)> void bind(C* instance)
template <auto Function, typename C> void bind(C* instance)
{
Delegate<R(Args...)> cb;
cb.template bind<C, Function>(instance);
cb.template bind<Function>(instance);
m_delegates.push(cb);
}
@ -31,10 +31,24 @@ public:
m_delegates.push(cb);
}
template <typename C, R (C::*Function)(Args...)> void unbind(C* instance)
template <R (*Function)(Args...)> void unbind()
{
Delegate<R(Args...)> cb;
cb.template bind<C, Function>(instance);
cb.template bind<Function>();
for (int i = 0; i < m_delegates.size(); ++i)
{
if (m_delegates[i] == cb)
{
m_delegates.swapAndPop(i);
break;
}
}
}
template <auto Function, typename C> void unbind(C* instance)
{
Delegate<R(Args...)> cb;
cb.template bind<Function>(instance);
for (int i = 0; i < m_delegates.size(); ++i)
{
if (m_delegates[i] == cb)

File diff suppressed because it is too large Load diff

View file

@ -1,38 +1,27 @@
#pragma once
#include "engine/lumix.h"
struct lua_State;
namespace Lumix
{
struct ComponentUID;
class FileSystem;
struct IAllocator;
class InputMemoryStream;
class InputSystem;
class OutputMemoryStream;
class PageAllocator;
class Path;
struct PathManager;
class PluginManager;
class ResourceManagerHub;
class Universe;
template <typename T> class Array;
class LUMIX_ENGINE_API Engine
{
public:
struct PlatformData
{
struct PlatformData {
void* window_handle = nullptr;
};
using LuaResourceHandle = u32;
public:
virtual ~Engine() {}
@ -44,12 +33,13 @@ public:
virtual void setPlatformData(const PlatformData& data) = 0;
virtual const PlatformData& getPlatformData() = 0;
virtual FileSystem& getFileSystem() = 0;
virtual InputSystem& getInputSystem() = 0;
virtual PluginManager& getPluginManager() = 0;
virtual ResourceManagerHub& getResourceManager() = 0;
virtual struct PathManager& getPathManager() = 0;
virtual class FileSystem& getFileSystem() = 0;
virtual class InputSystem& getInputSystem() = 0;
virtual class PluginManager& getPluginManager() = 0;
virtual class ResourceManagerHub& getResourceManager() = 0;
virtual class PageAllocator& getPageAllocator() = 0;
virtual IAllocator& getAllocator() = 0;
virtual PageAllocator& getPageAllocator() = 0;
virtual void startGame(Universe& context) = 0;
virtual void stopGame(Universe& context) = 0;
@ -57,19 +47,15 @@ public:
virtual void update(Universe& context) = 0;
virtual u32 serialize(Universe& ctx, OutputMemoryStream& serializer) = 0;
virtual bool deserialize(Universe& ctx, InputMemoryStream& serializer) = 0;
virtual float getFPS() const = 0;
virtual double getTime() const = 0;
virtual float getLastTimeDelta() const = 0;
virtual void setTimeMultiplier(float multiplier) = 0;
virtual void pause(bool pause) = 0;
virtual void nextFrame() = 0;
virtual PathManager& getPathManager() = 0;
virtual lua_State* getState() = 0;
virtual void runScript(const char* src, int src_length, const char* path) = 0;
virtual ComponentUID createComponent(Universe& universe, EntityRef entity, ComponentType type) = 0;
virtual class Resource* getLuaResource(int idx) const = 0;
virtual int addLuaResource(const Path& path, struct ResourceType type) = 0;
virtual void unloadLuaResource(int resource_idx) = 0;
virtual class Resource* getLuaResource(LuaResourceHandle idx) const = 0;
virtual LuaResourceHandle addLuaResource(const Path& path, struct ResourceType type) = 0;
virtual void unloadLuaResource(LuaResourceHandle resource_idx) = 0;
protected:
Engine() {}

View file

@ -216,7 +216,7 @@ struct FileSystemImpl final : public FileSystem
}
void updateAsyncTransactions() override
void processCallbacks() override
{
PROFILE_FUNCTION();

View file

@ -44,7 +44,7 @@ public:
virtual void setBasePath(const char* path) = 0;
virtual const char* getBasePath() const = 0;
virtual void updateAsyncTransactions() = 0;
virtual void processCallbacks() = 0;
virtual bool hasWork() = 0;
virtual bool getContentSync(const Path& file, Ref<Array<u8>> content) = 0;

1114
src/engine/lua_api.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -143,7 +143,7 @@ void Resource::doLoad()
FileSystem& fs = m_resource_manager.getOwner().getFileSystem();
FileSystem::ContentCallback cb;
cb.bind<Resource, &Resource::fileLoaded>(this);
cb.bind<&Resource::fileLoaded>(this);
const u32 hash = m_path.getHash();
const StaticString<MAX_PATH_LENGTH> res_path(".lumix/assets/", hash, ".res");
@ -156,7 +156,7 @@ void Resource::addDependency(Resource& dependent_resource)
{
ASSERT(m_desired_state != State::EMPTY);
dependent_resource.m_cb.bind<Resource, &Resource::onStateChanged>(this);
dependent_resource.m_cb.bind<&Resource::onStateChanged>(this);
if (dependent_resource.isEmpty()) ++m_empty_dep_count;
if (dependent_resource.isFailure()) {
++m_failed_dep_count;
@ -168,7 +168,7 @@ void Resource::addDependency(Resource& dependent_resource)
void Resource::removeDependency(Resource& dependent_resource)
{
dependent_resource.m_cb.unbind<Resource, &Resource::onStateChanged>(this);
dependent_resource.m_cb.unbind<&Resource::onStateChanged>(this);
if (dependent_resource.isEmpty())
{
ASSERT(m_empty_dep_count > 0);

View file

@ -56,9 +56,9 @@ public:
const Path& getPath() const { return m_path; }
ResourceManager& getResourceManager() { return m_resource_manager; }
template <typename C, void (C::*Function)(State, State, Resource&)> void onLoaded(C* instance)
template <auto Function, typename C> void onLoaded(C* instance)
{
m_cb.bind<C, Function>(instance);
m_cb.bind<Function>(instance);
if (isReady())
{
(instance->*Function)(State::READY, State::READY, *this);

View file

@ -228,8 +228,8 @@ public:
IAllocator& allocator = app.getWorldEditor().getAllocator();
Action* action = LUMIX_NEW(allocator, Action)("GUI Editor", "Toggle gui editor", "gui_editor");
action->func.bind<GUIEditor, &GUIEditor::onAction>(this);
action->is_selected.bind<GUIEditor, &GUIEditor::isOpen>(this);
action->func.bind<&GUIEditor::onAction>(this);
action->is_selected.bind<&GUIEditor::isOpen>(this);
app.addWindowAction(action);
m_editor = &app.getWorldEditor();
@ -237,15 +237,15 @@ public:
PipelineResource* pres = m_editor->getEngine().getResourceManager().load<PipelineResource>(Path("pipelines/gui_editor.pln"));
m_pipeline = Pipeline::create(renderer, pres, "", allocator);
m_editor->universeCreated().bind<GUIEditor, &GUIEditor::onUniverseChanged>(this);
m_editor->universeDestroyed().bind<GUIEditor, &GUIEditor::onUniverseChanged>(this);
m_editor->universeCreated().bind<&GUIEditor::onUniverseChanged>(this);
m_editor->universeDestroyed().bind<&GUIEditor::onUniverseChanged>(this);
}
~GUIEditor()
{
m_editor->universeCreated().unbind<GUIEditor, &GUIEditor::onUniverseChanged>(this);
m_editor->universeDestroyed().unbind<GUIEditor, &GUIEditor::onUniverseChanged>(this);
m_editor->universeCreated().unbind<&GUIEditor::onUniverseChanged>(this);
m_editor->universeDestroyed().unbind<&GUIEditor::onUniverseChanged>(this);
Pipeline::destroy(m_pipeline);
}

View file

@ -47,11 +47,11 @@ struct GUIText
m_font_resource->removeRef(*m_font);
m_font = nullptr;
}
m_font_resource->getObserverCb().unbind<GUIText, &GUIText::onFontLoaded>(this);
m_font_resource->getObserverCb().unbind<&GUIText::onFontLoaded>(this);
m_font_resource->getResourceManager().unload(*m_font_resource);
}
m_font_resource = res;
if (res) res->onLoaded<GUIText, &GUIText::onFontLoaded>(this);
if (res) res->onLoaded<&GUIText::onFontLoaded>(this);
}

View file

@ -196,7 +196,7 @@ struct GUISystemImpl final : public GUISystem
auto* pipeline = m_interface->getPipeline();
pipeline->addCustomCommandHandler("renderIngameGUI")
.callback.bind<GUISystemImpl, &GUISystemImpl::pipelineCallback>(this);
.callback.bind<&GUISystemImpl::pipelineCallback>(this);
}

View file

@ -528,8 +528,8 @@ struct ConsolePlugin final : public StudioApp::GUIPlugin
, autocomplete(_app.getWorldEditor().getAllocator())
{
Action* action = LUMIX_NEW(app.getWorldEditor().getAllocator(), Action)("Script Console", "Toggle script console", "script_console");
action->func.bind<ConsolePlugin, &ConsolePlugin::toggleOpen>(this);
action->is_selected.bind<ConsolePlugin, &ConsolePlugin::isOpen>(this);
action->func.bind<&ConsolePlugin::toggleOpen>(this);
action->is_selected.bind<&ConsolePlugin::isOpen>(this);
app.addWindowAction(action);
buf[0] = '\0';
}

View file

@ -1095,14 +1095,14 @@ namespace Lumix
if (inst.m_state) destroyInstance(cmp, inst);
inst.m_properties.clear();
auto& cb = inst.m_script->getObserverCb();
cb.unbind<ScriptComponent, &ScriptComponent::onScriptLoaded>(&cmp);
cb.unbind<&ScriptComponent::onScriptLoaded>(&cmp);
inst.m_script->getResourceManager().unload(*inst.m_script);
}
ResourceManagerHub& rm = m_system.m_engine.getResourceManager();
inst.m_script = path.isValid() ? rm.load<LuaScript>(path) : nullptr;
if (inst.m_script)
{
inst.m_script->onLoaded<ScriptComponent, &ScriptComponent::onScriptLoaded>(&cmp);
inst.m_script->onLoaded<&ScriptComponent::onScriptLoaded>(&cmp);
}
}
@ -1183,9 +1183,9 @@ namespace Lumix
m_gui_scene = (GUIScene*)m_universe.getScene(crc32("gui"));
if (m_gui_scene)
{
m_gui_scene->buttonClicked().bind<LuaScriptSceneImpl, &LuaScriptSceneImpl::onButtonClicked>(this);
m_gui_scene->rectHovered().bind<LuaScriptSceneImpl, &LuaScriptSceneImpl::onRectHovered>(this);
m_gui_scene->rectHoveredOut().bind<LuaScriptSceneImpl, &LuaScriptSceneImpl::onRectHoveredOut>(this);
m_gui_scene->buttonClicked().bind<&LuaScriptSceneImpl::onButtonClicked>(this);
m_gui_scene->rectHovered().bind<&LuaScriptSceneImpl::onRectHovered>(this);
m_gui_scene->rectHoveredOut().bind<&LuaScriptSceneImpl::onRectHoveredOut>(this);
}
}
@ -1194,9 +1194,9 @@ namespace Lumix
{
if (m_gui_scene)
{
m_gui_scene->buttonClicked().unbind<LuaScriptSceneImpl, &LuaScriptSceneImpl::onButtonClicked>(this);
m_gui_scene->rectHovered().unbind<LuaScriptSceneImpl, &LuaScriptSceneImpl::onRectHovered>(this);
m_gui_scene->rectHoveredOut().unbind<LuaScriptSceneImpl, &LuaScriptSceneImpl::onRectHoveredOut>(this);
m_gui_scene->buttonClicked().unbind<&LuaScriptSceneImpl::onButtonClicked>(this);
m_gui_scene->rectHovered().unbind<&LuaScriptSceneImpl::onRectHovered>(this);
m_gui_scene->rectHoveredOut().unbind<&LuaScriptSceneImpl::onRectHoveredOut>(this);
}
m_gui_scene = nullptr;
m_scripts_start_called = false;
@ -1226,7 +1226,7 @@ namespace Lumix
if (scr.m_script)
{
auto& cb = scr.m_script->getObserverCb();
cb.unbind<ScriptComponent, &ScriptComponent::onScriptLoaded>(script);
cb.unbind<&ScriptComponent::onScriptLoaded>(script);
m_system.getScriptManager().unload(*scr.m_script);
}
}

View file

@ -97,7 +97,7 @@ struct NavigationSceneImpl final : public NavigationScene
, m_on_update(m_allocator)
{
setGeneratorParams(0.3f, 0.1f, 0.3f, 2.0f, 60.0f, 0.3f);
m_universe.entityTransformed().bind<NavigationSceneImpl, &NavigationSceneImpl::onEntityMoved>(this);
m_universe.entityTransformed().bind<&NavigationSceneImpl::onEntityMoved>(this);
universe.registerComponentType(NAVMESH_AGENT_TYPE
, this
, &NavigationSceneImpl::createAgent
@ -115,7 +115,7 @@ struct NavigationSceneImpl final : public NavigationScene
~NavigationSceneImpl()
{
m_universe.entityTransformed().unbind<NavigationSceneImpl, &NavigationSceneImpl::onEntityMoved>(this);
m_universe.entityTransformed().unbind<&NavigationSceneImpl::onEntityMoved>(this);
for(RecastZone& zone : m_zones) {
clearNavmesh(zone);
}
@ -699,7 +699,7 @@ struct NavigationSceneImpl final : public NavigationScene
LoadCallback* lcb = LUMIX_NEW(m_allocator, LoadCallback)(*this, zone_entity);
FileSystem::ContentCallback cb;
cb.bind<LoadCallback, &LoadCallback::fileLoaded>(lcb);
cb.bind<&LoadCallback::fileLoaded>(lcb);
FileSystem& fs = m_engine.getFileSystem();
return fs.getContent(Path(path), cb).isValid();
}

View file

@ -357,8 +357,8 @@ struct PhysicsUIPlugin final : public StudioApp::GUIPlugin
, m_is_window_open(false)
{
Action* action = LUMIX_NEW(m_editor.getAllocator(), Action)("Physics", "Toggle physics UI", "physics");
action->func.bind<PhysicsUIPlugin, &PhysicsUIPlugin::onAction>(this);
action->is_selected.bind<PhysicsUIPlugin, &PhysicsUIPlugin::isOpen>(this);
action->func.bind<&PhysicsUIPlugin::onAction>(this);
action->is_selected.bind<&PhysicsUIPlugin::isOpen>(this);
app.addWindowAction(action);
}

View file

@ -1451,14 +1451,14 @@ struct PhysicsSceneImpl final : public PhysicsScene
{
old_hm->getResourceManager().unload(*old_hm);
auto& cb = old_hm->getObserverCb();
cb.unbind<Heightfield, &Heightfield::heightmapLoaded>(&terrain);
cb.unbind<&Heightfield::heightmapLoaded>(&terrain);
}
if (str.isValid())
{
auto* new_hm = resource_manager.load<Texture>(str);
terrain.m_heightmap = new_hm;
new_hm->onLoaded<Heightfield, &Heightfield::heightmapLoaded>(&terrain);
new_hm->onLoaded<&Heightfield::heightmapLoaded>(&terrain);
new_hm->addDataReference();
}
else
@ -5055,8 +5055,8 @@ struct PhysicsSceneImpl final : public PhysicsScene
PhysicsScene* PhysicsScene::create(PhysicsSystem& system, Universe& context, Engine& engine, IAllocator& allocator)
{
PhysicsSceneImpl* impl = LUMIX_NEW(allocator, PhysicsSceneImpl)(context, allocator);
impl->m_universe.entityTransformed().bind<PhysicsSceneImpl, &PhysicsSceneImpl::onEntityMoved>(impl);
impl->m_universe.entityDestroyed().bind<PhysicsSceneImpl, &PhysicsSceneImpl::onEntityDestroyed>(impl);
impl->m_universe.entityTransformed().bind<&PhysicsSceneImpl::onEntityMoved>(impl);
impl->m_universe.entityDestroyed().bind<&PhysicsSceneImpl::onEntityDestroyed>(impl);
impl->m_engine = &engine;
PxSceneDesc sceneDesc(system.getPhysics()->getTolerancesScale());
sceneDesc.gravity = PxVec3(0.0f, -9.8f, 0.0f);
@ -5151,13 +5151,13 @@ void PhysicsSceneImpl::RigidActor::setResource(PhysicsGeometry* _resource)
{
if (resource)
{
resource->getObserverCb().unbind<RigidActor, &RigidActor::onStateChanged>(this);
resource->getObserverCb().unbind<&RigidActor::onStateChanged>(this);
resource->getResourceManager().unload(*resource);
}
resource = _resource;
if (resource)
{
resource->onLoaded<RigidActor, &RigidActor::onStateChanged>(this);
resource->onLoaded<&RigidActor::onStateChanged>(this);
}
}
@ -5178,7 +5178,7 @@ Heightfield::~Heightfield()
if (m_heightmap)
{
m_heightmap->getResourceManager().unload(*m_heightmap);
m_heightmap->getObserverCb().unbind<Heightfield, &Heightfield::heightmapLoaded>(this);
m_heightmap->getObserverCb().unbind<&Heightfield::heightmapLoaded>(this);
}
}

View file

@ -68,20 +68,20 @@ GameView::GameView(StudioApp& app)
WorldEditor& editor = app.getWorldEditor();
Action* action = LUMIX_NEW(editor.getAllocator(), Action)("Game View", "Toggle game view", "game_view");
action->func.bind<GameView, &GameView::onAction>(this);
action->is_selected.bind<GameView, &GameView::isOpen>(this);
action->func.bind<&GameView::onAction>(this);
action->is_selected.bind<&GameView::isOpen>(this);
app.addWindowAction(action);
Action* fullscreen_action = LUMIX_NEW(editor.getAllocator(), Action)("Game View fullscreen", "Game View fullscreen", "game_view_fullscreen");
fullscreen_action->func.bind<GameView, &GameView::toggleFullscreen>(this);
fullscreen_action->func.bind<&GameView::toggleFullscreen>(this);
app.addAction(fullscreen_action);
auto* renderer = (Renderer*)engine.getPluginManager().getPlugin("renderer");
PipelineResource* pres = engine.getResourceManager().load<PipelineResource>(Path("pipelines/main.pln"));
m_pipeline = Pipeline::create(*renderer, pres, "GAME_VIEW", engine.getAllocator());
editor.universeCreated().bind<GameView, &GameView::onUniverseCreated>(this);
editor.universeDestroyed().bind<GameView, &GameView::onUniverseDestroyed>(this);
editor.universeCreated().bind<&GameView::onUniverseCreated>(this);
editor.universeDestroyed().bind<&GameView::onUniverseDestroyed>(this);
if (editor.getUniverse()) onUniverseCreated();
auto* gui = static_cast<GUISystem*>(engine.getPluginManager().getPlugin("gui"));
@ -95,8 +95,8 @@ GameView::GameView(StudioApp& app)
GameView::~GameView()
{
m_editor.universeCreated().unbind<GameView, &GameView::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<GameView, &GameView::onUniverseDestroyed>(this);
m_editor.universeCreated().unbind<&GameView::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<&GameView::onUniverseDestroyed>(this);
auto* gui = static_cast<GUISystem*>(m_editor.getEngine().getPluginManager().getPlugin("gui"));
if (gui)
{

View file

@ -1279,7 +1279,7 @@ struct ModelPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin
m_tile.path_hash = prefab->getPath().getHash();
prefab->getResourceManager().unload(*prefab);
m_tile.entity = mesh_entity;
model->onLoaded<ModelPlugin, &ModelPlugin::renderPrefabSecondStage>(this);
model->onLoaded<&ModelPlugin::renderPrefabSecondStage>(this);
}
@ -3045,8 +3045,8 @@ struct RenderInterfaceImpl final : public RenderInterfaceBase
m_font_res = rm.load<FontResource>(font_path);
m_font = m_font_res->addRef(16);
editor.universeCreated().bind<RenderInterfaceImpl, &RenderInterfaceImpl::onUniverseCreated>(this);
editor.universeDestroyed().bind<RenderInterfaceImpl, &RenderInterfaceImpl::onUniverseDestroyed>(this);
editor.universeCreated().bind<&RenderInterfaceImpl::onUniverseCreated>(this);
editor.universeDestroyed().bind<&RenderInterfaceImpl::onUniverseDestroyed>(this);
}
@ -3055,8 +3055,8 @@ struct RenderInterfaceImpl final : public RenderInterfaceBase
m_shader->getResourceManager().unload(*m_shader);
m_font_res->getResourceManager().unload(*m_font_res);
m_editor.universeCreated().unbind<RenderInterfaceImpl, &RenderInterfaceImpl::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<RenderInterfaceImpl, &RenderInterfaceImpl::onUniverseDestroyed>(this);
m_editor.universeCreated().unbind<&RenderInterfaceImpl::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<&RenderInterfaceImpl::onUniverseDestroyed>(this);
}

View file

@ -55,15 +55,15 @@ SceneView::SceneView(StudioApp& app)
auto* renderer = static_cast<Renderer*>(engine.getPluginManager().getPlugin("renderer"));
PipelineResource* pres = engine.getResourceManager().load<PipelineResource>(Path("pipelines/main.pln"));
m_pipeline = Pipeline::create(*renderer, pres, "SCENE_VIEW", engine.getAllocator());
m_pipeline->addCustomCommandHandler("renderSelection").callback.bind<SceneView, &SceneView::renderSelection>(this);
m_pipeline->addCustomCommandHandler("renderGizmos").callback.bind<SceneView, &SceneView::renderGizmos>(this);
m_pipeline->addCustomCommandHandler("renderIcons").callback.bind<SceneView, &SceneView::renderIcons>(this);
m_pipeline->addCustomCommandHandler("renderSelection").callback.bind<&SceneView::renderSelection>(this);
m_pipeline->addCustomCommandHandler("renderGizmos").callback.bind<&SceneView::renderGizmos>(this);
m_pipeline->addCustomCommandHandler("renderIcons").callback.bind<&SceneView::renderIcons>(this);
ResourceManagerHub& rm = engine.getResourceManager();
m_debug_shape_shader = rm.load<Shader>(Path("pipelines/debug_shape.shd"));
m_editor.universeCreated().bind<SceneView, &SceneView::onUniverseCreated>(this);
m_editor.universeDestroyed().bind<SceneView, &SceneView::onUniverseDestroyed>(this);
m_editor.universeCreated().bind<&SceneView::onUniverseCreated>(this);
m_editor.universeDestroyed().bind<&SceneView::onUniverseDestroyed>(this);
m_toggle_gizmo_step_action =
LUMIX_NEW(allocator, Action)("Enable/disable gizmo step", "Enable/disable gizmo step", "toggleGizmoStep");
@ -96,7 +96,7 @@ SceneView::SceneView(StudioApp& app)
m_camera_speed_action = LUMIX_NEW(allocator, Action)("Camera speed", "Reset camera speed", "cameraSpeed");
m_camera_speed_action->is_global = false;
m_camera_speed_action->func.bind<SceneView, &SceneView::resetCameraSpeed>(this);
m_camera_speed_action->func.bind<&SceneView::resetCameraSpeed>(this);
m_app.addAction(m_camera_speed_action);
const ResourceType pipeline_type("pipeline");
@ -112,8 +112,8 @@ void SceneView::resetCameraSpeed()
SceneView::~SceneView()
{
m_editor.universeCreated().unbind<SceneView, &SceneView::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<SceneView, &SceneView::onUniverseDestroyed>(this);
m_editor.universeCreated().unbind<&SceneView::onUniverseCreated>(this);
m_editor.universeDestroyed().unbind<&SceneView::onUniverseDestroyed>(this);
Pipeline::destroy(m_pipeline);
m_debug_shape_shader->getResourceManager().unload(*m_debug_shape_shader);
m_pipeline = nullptr;

View file

@ -609,7 +609,7 @@ private:
TerrainEditor::~TerrainEditor()
{
m_world_editor.universeDestroyed().unbind<TerrainEditor, &TerrainEditor::onUniverseDestroyed>(this);
m_world_editor.universeDestroyed().unbind<&TerrainEditor::onUniverseDestroyed>(this);
if (m_brush_texture)
{
m_brush_texture->destroy();
@ -642,9 +642,9 @@ TerrainEditor::TerrainEditor(WorldEditor& editor, StudioApp& app)
{
m_increase_brush_size = LUMIX_NEW(editor.getAllocator(), Action)("Increase brush size", "Terrain editor - Increase brush size", "increaseBrushSize");
m_increase_brush_size->is_global = false;
m_increase_brush_size->func.bind<TerrainEditor, &TerrainEditor::increaseBrushSize>(this);
m_increase_brush_size->func.bind<&TerrainEditor::increaseBrushSize>(this);
m_decrease_brush_size = LUMIX_NEW(editor.getAllocator(), Action)("Decrease brush size", "Terrain editor - decrease brush size", "decreaseBrushSize");
m_decrease_brush_size->func.bind<TerrainEditor, &TerrainEditor::decreaseBrushSize>(this);
m_decrease_brush_size->func.bind<&TerrainEditor::decreaseBrushSize>(this);
m_decrease_brush_size->is_global = false;
app.addAction(m_increase_brush_size);
app.addAction(m_decrease_brush_size);
@ -679,7 +679,7 @@ TerrainEditor::TerrainEditor(WorldEditor& editor, StudioApp& app)
m_is_rotate_z = false;
m_rotate_x_spread = m_rotate_y_spread = m_rotate_z_spread = Vec2(0, PI * 2);
editor.universeDestroyed().bind<TerrainEditor, &TerrainEditor::onUniverseDestroyed>(this);
editor.universeDestroyed().bind<&TerrainEditor::onUniverseDestroyed>(this);
}
@ -1199,13 +1199,21 @@ void TerrainEditor::onGUI()
switch (m_current_brush)
{
case HEIGHT:
if (ImGui::Button("Save heightmap"))
if (getMaterial()
&& getMaterial()->getTextureByName(HEIGHTMAP_SLOT_NAME)
&&ImGui::Button("Save heightmap"))
{
getMaterial()->getTextureByName(HEIGHTMAP_SLOT_NAME)->save();
}
break;
case GRASS:
case LAYER:
if (ImGui::Button("Save layermap and grassmap"))
if (getMaterial()
&& getMaterial()->getTextureByName(SPLATMAP_SLOT_NAME)
&& ImGui::Button("Save layermap and grassmap"))
{
getMaterial()->getTextureByName(SPLATMAP_SLOT_NAME)->save();
}
break;
case ENTITY: break;
}

View file

@ -298,7 +298,7 @@ struct PipelineImpl final : Pipeline
const Renderer::MemRef ib_mem = m_renderer.copy(cube_indices, sizeof(cube_indices));
m_cube_ib = m_renderer.createBuffer(ib_mem, (u32)gpu::BufferFlags::IMMUTABLE);
m_resource->onLoaded<PipelineImpl, &PipelineImpl::onStateChanged>(this);
m_resource->onLoaded<&PipelineImpl::onStateChanged>(this);
GlobalState global_state;
const Renderer::MemRef global_state_mem = m_renderer.copy(&global_state, sizeof(global_state));

View file

@ -96,11 +96,11 @@ struct TextMesh
m_font_resource->removeRef(*m_font);
m_font = nullptr;
}
m_font_resource->getObserverCb().unbind<TextMesh, &TextMesh::onFontLoaded>(this);
m_font_resource->getObserverCb().unbind<&TextMesh::onFontLoaded>(this);
m_font_resource->getResourceManager().unload(*m_font_resource);
}
m_font_resource = res;
if (res) res->onLoaded<TextMesh, &TextMesh::onFontLoaded>(this);
if (res) res->onLoaded<&TextMesh::onFontLoaded>(this);
}
void onFontLoaded(Resource::State, Resource::State new_state, Resource&)
@ -160,8 +160,8 @@ public:
~RenderSceneImpl()
{
m_universe.entityTransformed().unbind<RenderSceneImpl, &RenderSceneImpl::onEntityMoved>(this);
m_universe.entityDestroyed().unbind<RenderSceneImpl, &RenderSceneImpl::onEntityDestroyed>(this);
m_universe.entityTransformed().unbind<&RenderSceneImpl::onEntityMoved>(this);
m_universe.entityDestroyed().unbind<&RenderSceneImpl::onEntityDestroyed>(this);
CullingSystem::destroy(*m_culling_system);
}
@ -251,13 +251,13 @@ public:
m_model_instances.clear();
for(auto iter = m_model_entity_map.begin(), end = m_model_entity_map.end(); iter != end; ++iter) {
Model* model = iter.key();
model->getObserverCb().unbind<RenderSceneImpl, &RenderSceneImpl::modelStateChanged>(this);
model->getObserverCb().unbind<&RenderSceneImpl::modelStateChanged>(this);
}
m_model_entity_map.clear();
for(auto iter = m_material_decal_map.begin(), end = m_material_decal_map.end(); iter != end; ++iter) {
Material* mat = iter.key();
mat->getObserverCb().unbind<RenderSceneImpl, &RenderSceneImpl::decalMaterialStateChanged>(this);
mat->getObserverCb().unbind<&RenderSceneImpl::decalMaterialStateChanged>(this);
}
m_material_decal_map.clear();
@ -3135,7 +3135,7 @@ public:
else {
d.next_decal = INVALID_ENTITY;
m_material_decal_map.insert(material, entity);
material->getObserverCb().bind<RenderSceneImpl, &RenderSceneImpl::decalMaterialStateChanged>(this);
material->getObserverCb().bind<&RenderSceneImpl::decalMaterialStateChanged>(this);
}
}
@ -3152,7 +3152,7 @@ public:
else {
r.next_model = INVALID_ENTITY;
m_model_entity_map.insert(model, entity);
model->getObserverCb().bind<RenderSceneImpl, &RenderSceneImpl::modelStateChanged>(this);
model->getObserverCb().bind<&RenderSceneImpl::modelStateChanged>(this);
}
}
@ -3173,7 +3173,7 @@ public:
}
else {
m_model_entity_map.erase(model);
model->getObserverCb().unbind<RenderSceneImpl, &RenderSceneImpl::modelStateChanged>(this);
model->getObserverCb().unbind<&RenderSceneImpl::modelStateChanged>(this);
}
}
}
@ -3195,7 +3195,7 @@ public:
}
else {
m_material_decal_map.erase(material);
material->getObserverCb().unbind<RenderSceneImpl, &RenderSceneImpl::decalMaterialStateChanged>(this);
material->getObserverCb().unbind<&RenderSceneImpl::decalMaterialStateChanged>(this);
}
}
}
@ -3489,8 +3489,8 @@ RenderSceneImpl::RenderSceneImpl(Renderer& renderer,
, m_light_probe_grids(m_allocator)
{
m_universe.entityTransformed().bind<RenderSceneImpl, &RenderSceneImpl::onEntityMoved>(this);
m_universe.entityDestroyed().bind<RenderSceneImpl, &RenderSceneImpl::onEntityDestroyed>(this);
m_universe.entityTransformed().bind<&RenderSceneImpl::onEntityMoved>(this);
m_universe.entityDestroyed().bind<&RenderSceneImpl::onEntityDestroyed>(this);
m_culling_system = CullingSystem::create(m_allocator, engine.getPageAllocator());
m_model_instances.reserve(5000);
m_mesh_sort_data.reserve(5000);

View file

@ -56,7 +56,7 @@ Terrain::GrassType::~GrassType()
{
if (m_grass_model)
{
m_grass_model->getObserverCb().unbind<Terrain, &Terrain::grassLoaded>(&m_terrain);
m_grass_model->getObserverCb().unbind<&Terrain::grassLoaded>(&m_terrain);
m_grass_model->getResourceManager().unload(*m_grass_model);
}
}
@ -184,13 +184,13 @@ void Terrain::setGrassTypePath(int index, const Path& path)
if (type.m_grass_model)
{
type.m_grass_model->getResourceManager().unload(*type.m_grass_model);
type.m_grass_model->getObserverCb().unbind<Terrain, &Terrain::grassLoaded>(this);
type.m_grass_model->getObserverCb().unbind<&Terrain::grassLoaded>(this);
type.m_grass_model = nullptr;
}
if (path.isValid())
{
type.m_grass_model = m_scene.getEngine().getResourceManager().load<Model>(path);
type.m_grass_model->onLoaded<Terrain, &Terrain::grassLoaded>(this);
type.m_grass_model->onLoaded<&Terrain::grassLoaded>(this);
}
}
@ -392,11 +392,11 @@ void Terrain::setMaterial(Material* material)
if (material != m_material) {
if (m_material) {
m_material->getResourceManager().unload(*m_material);
m_material->getObserverCb().unbind<Terrain, &Terrain::onMaterialLoaded>(this);
m_material->getObserverCb().unbind<&Terrain::onMaterialLoaded>(this);
}
m_material = material;
if (m_material) {
m_material->onLoaded<Terrain, &Terrain::onMaterialLoaded>(this);
m_material->onLoaded<&Terrain::onMaterialLoaded>(this);
}
}
else if(material) {