Пример #1
0
	void PhysicsSystemImpl::destroy()
	{
		m_cooking->release();
		m_physics->release();
		m_foundation->release();
		LUMIX_DELETE(m_allocator, m_physx_allocator);
		LUMIX_DELETE(m_allocator, m_error_callback);
	}
Пример #2
0
	void destroyUniverse(UniverseContext& context) override
	{
		for (int i = context.m_scenes.size() - 1; i >= 0; --i)
		{
			context.m_scenes[i]->getPlugin().destroyScene(context.m_scenes[i]);
		}
		LUMIX_DELETE(m_allocator, context.m_universe);

		LUMIX_DELETE(m_allocator, &context);
		m_resource_manager.removeUnreferenced();
	}
Пример #3
0
	Process* createProcess(const char* cmd, const char* args, IAllocator& allocator)
	{
		auto* process = LUMIX_NEW(allocator, Process)(allocator);

		SECURITY_ATTRIBUTES sec_attrs;
		sec_attrs.nLength = sizeof(SECURITY_ATTRIBUTES);
		sec_attrs.bInheritHandle = TRUE;
		sec_attrs.lpSecurityDescriptor = NULL;
		if (CreatePipe(&process->output_read_pipe, &process->output_write_pipe, &sec_attrs, 0) ==
			FALSE)
		{
			LUMIX_DELETE(allocator, process);
			return nullptr;
		}
		if (SetHandleInformation(process->output_read_pipe, HANDLE_FLAG_INHERIT, 0) == FALSE)
		{
			LUMIX_DELETE(allocator, process);
			return nullptr;
		}

		STARTUPINFO suinfo;
		ZeroMemory(&suinfo, sizeof(suinfo));
		suinfo.cb = sizeof(suinfo);
		suinfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
		suinfo.wShowWindow = SW_HIDE;
		suinfo.hStdOutput = process->output_write_pipe;
		suinfo.hStdError = process->output_write_pipe;

		char rw_args[1024];
		copyString(rw_args, args);
		auto create_process_ret = CreateProcess(
			cmd,
			rw_args,
			NULL,
			NULL,
			TRUE,
			NORMAL_PRIORITY_CLASS,
			NULL,
			NULL,
			&suinfo,
			&process->process_info);
		
		if (create_process_ret == FALSE)
		{
			LUMIX_DELETE(allocator, process);
			return nullptr;
		}

		CloseHandle(process->output_write_pipe);

		return process;
	}
Пример #4
0
	void shutdown()
	{
		m_engine->destroyUniverse(*m_universe);
		Lumix::FS::FileSystem::destroy(m_file_system);
		LUMIX_DELETE(m_allocator, m_disk_file_device);
		LUMIX_DELETE(m_allocator, m_mem_file_device);
		LUMIX_DELETE(m_allocator, m_pack_file_device);
		Lumix::Pipeline::destroy(m_pipeline);
		Lumix::Engine::destroy(m_engine, m_allocator);
		m_engine = nullptr;
		m_pipeline = nullptr;
		m_universe = nullptr;
	}
void shutdown()
{
	for (int j = 0; j < g_properties->size(); ++j)
	{
		Array<IPropertyDescriptor*>& props = g_properties->at(j);
		for (auto* prop : props)
		{
			LUMIX_DELETE(*g_allocator, prop);
		}
	}

	LUMIX_DELETE(*g_allocator, g_properties);
	g_properties = nullptr;
	g_allocator = nullptr;
}
Пример #6
0
		IPlugin* load(const char* path) override
		{
			g_log_info.log("plugins") << "loading plugin " << path;
			typedef IPlugin* (*PluginCreator)(Engine&);

			auto* lib = loadLibrary(path);
			if (lib)
			{
				PluginCreator creator = (PluginCreator)getLibrarySymbol(lib, "createPlugin");
				if (creator)
				{
					IPlugin* plugin = creator(m_engine);
					if (!plugin || !plugin->create())
					{
						LUMIX_DELETE(m_engine.getAllocator(), plugin);
						ASSERT(false);
						return nullptr;
					}
					m_plugins.push(plugin);
					m_libraries.push(lib);
					m_library_loaded.invoke(lib);
					g_log_info.log("plugins") << "plugin loaded";
					return plugin;
				}
			}
			unloadLibrary(lib);
			return 0;
		}
Пример #7
0
PropertyGrid::~PropertyGrid()
{
	for (auto* i : m_plugins)
	{
		LUMIX_DELETE(m_editor.getAllocator(), i);
	}
}
Пример #8
0
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);
	}
}
Пример #9
0
void Shader::unload(void)
{
	m_combintions = {};

	for (auto& uniform : m_uniforms)
	{
		bgfx::destroyUniform(uniform.handle);
	}
	m_uniforms.clear();

	for (int i = 0; i < m_texture_slot_count; ++i)
	{
		if (bgfx::isValid(m_texture_slots[i].uniform_handle))
		{
			bgfx::destroyUniform(m_texture_slots[i].uniform_handle);
		}
		m_texture_slots[i].uniform_handle = BGFX_INVALID_HANDLE;
	}
	m_texture_slot_count = 0;

	for (auto* i : m_instances)
	{
		LUMIX_DELETE(m_allocator, i);
	}
	m_instances.clear();
}
Пример #10
0
void ParticleEmitter::deserialize(InputBlob& blob, ResourceManager& manager)
{
	blob.read(m_spawn_count);
	blob.read(m_spawn_period);
	blob.read(m_initial_life);
	blob.read(m_initial_size);
	blob.read(m_entity);
	blob.read(m_autoemit);
	blob.read(m_local_space);
	char path[MAX_PATH_LENGTH];
	blob.readString(path, lengthOf(path));
	auto material_manager = manager.get(MATERIAL_TYPE);
	auto material = static_cast<Material*>(material_manager->load(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)
	{
		ParticleEmitter::ModuleBase* module = nullptr;
		u32 hash;
		blob.read(hash);
		ComponentType type = PropertyRegister::getComponentTypeFromHash(hash);
		module = createModule(type, *this);
		if (module)
		{
			m_modules.push(module);
		}
	}
}
Пример #11
0
	~EngineImpl()
	{
		Timer::destroy(m_timer);
		Timer::destroy(m_fps_timer);
		PluginManager::destroy(m_plugin_manager);
		if (m_input_system) InputSystem::destroy(*m_input_system);
		if (m_disk_file_device)
		{
			FS::FileSystem::destroy(m_file_system);
			LUMIX_DELETE(m_allocator, m_mem_file_device);
			LUMIX_DELETE(m_allocator, m_disk_file_device);
		}

		m_resource_manager.destroy();
		MTJD::Manager::destroy(*m_mtjd_manager);
	}
Пример #12
0
void destroyProcess(Process& process)
{
	CloseHandle(process.output_read_pipe);
	CloseHandle(process.process_info.hProcess);
	CloseHandle(process.process_info.hThread);
	LUMIX_DELETE(process.allocator, &process);
}
Пример #13
0
	~ProfilerUIImpl()
	{
		m_allocation_root->clear(m_allocator);
		LUMIX_DELETE(m_allocator, m_allocation_root);
		Lumix::Profiler::getFrameListeners().unbind<ProfilerUIImpl, &ProfilerUIImpl::onFrame>(this);
		Lumix::Timer::destroy(m_timer);
	}
Пример #14
0
	~Instance()
	{
		Timer::destroy(timer);
		for (auto* i : threads)
		{
			if (i != &main_thread) LUMIX_DELETE(allocator, i);
		}
	}
Пример #15
0
		BaseEntry::~BaseEntry()
		{
#if TYPE == MULTI_THREAD

			LUMIX_DELETE(m_allocator, m_sync_event);

#endif //TYPE == MULTI_THREAD
		}
Пример #16
0
 ~FileSystemWatcherImpl()
 {
     if (task)
     {
         task->destroy();
         LUMIX_DELETE(allocator, task);
     }
 }
Пример #17
0
		BaseEntry::~BaseEntry()
		{
#if !LUMIX_SINGLE_THREAD()

			LUMIX_DELETE(m_allocator, m_sync_event);

#endif
		}
Пример #18
0
void OsFile::close()
{
	if (nullptr != m_impl)
	{
		::CloseHandle(m_impl->m_file);
		LUMIX_DELETE(m_impl->m_allocator, m_impl);
		m_impl = nullptr;
	}
}
Пример #19
0
bool Shader::generateInstances()
{
	for (int i = 0; i < m_instances.size(); ++i)
	{
		LUMIX_DELETE(m_allocator, m_instances[i]);
	}
	m_instances.clear();

	uint32 count = 1 << m_combintions.m_define_count;

	auto* binary_manager = m_resource_manager.get(ResourceManager::SHADER_BINARY);
	char basename[MAX_PATH_LENGTH];
	PathUtils::getBasename(basename, sizeof(basename), getPath().c_str());

	for (uint32 mask = 0; mask < count; ++mask)
	{
		ShaderInstance* instance = LUMIX_NEW(m_allocator, ShaderInstance)(*this);
		m_instances.push(instance);

		instance->m_define_mask = getDefineMaskFromDense(mask);

		for (int pass_idx = 0; pass_idx < m_combintions.m_pass_count; ++pass_idx)
		{
			const char* pass = m_combintions.m_passes[pass_idx];
			char path[MAX_PATH_LENGTH];
			copyString(path, "shaders/compiled/");
			catString(path, basename);
			catString(path, "_");
			catString(path, pass);
			char mask_str[10];
			int actual_mask = mask & m_combintions.m_vs_local_mask[pass_idx];
			toCString(actual_mask, mask_str, sizeof(mask_str));
			catString(path, mask_str);
			catString(path, "_vs.shb");

			Path vs_path(path);
			auto* vs_binary = static_cast<ShaderBinary*>(binary_manager->load(vs_path));
			addDependency(*vs_binary);
			instance->m_binaries[pass_idx * 2] = vs_binary;

			copyString(path, "shaders/compiled/");
			catString(path, basename);
			catString(path, "_");
			catString(path, pass);
			actual_mask = mask & m_combintions.m_fs_local_mask[pass_idx];
			toCString(actual_mask, mask_str, sizeof(mask_str));
			catString(path, mask_str);
			catString(path, "_fs.shb");

			Path fs_path(path);
			auto* fs_binary = static_cast<ShaderBinary*>(binary_manager->load(fs_path));
			addDependency(*fs_binary);
			instance->m_binaries[pass_idx * 2 + 1] = fs_binary;
		}
	}
	return true;
}
Пример #20
0
	~Block()
	{
		while (m_first_child)
		{
			Block* child = m_first_child->m_next;
			LUMIX_DELETE(allocator, m_first_child);
			m_first_child = child;
		}
	}
Пример #21
0
ParticleEmitter::~ParticleEmitter()
{
	setMaterial(nullptr);

	for (auto* module : m_modules)
	{
		LUMIX_DELETE(m_allocator, module);
	}
}
Пример #22
0
		void unload(IPlugin* plugin) override
		{
			int idx = m_plugins.indexOf(plugin);
			ASSERT(idx >= 0);
			LUMIX_DELETE(m_engine.getAllocator(), m_plugins[idx]);
			unloadLibrary(m_libraries[idx]);
			m_libraries.erase(idx);
			m_plugins.erase(idx);
		}
Пример #23
0
		IPlugin* load(const char* path) override
		{
			char path_with_ext[MAX_PATH_LENGTH];
			copyString(path_with_ext, path);
			const char* ext =
			#ifdef _WIN32
				".dll";
			#elif defined __linux__
				".so";
			#else 
				#error Unknown platform
			#endif
			if (!PathUtils::hasExtension(path, ext + 1)) catString(path_with_ext, ext);
			g_log_info.log("Core") << "loading plugin " << path_with_ext;
			typedef IPlugin* (*PluginCreator)(Engine&);
			auto* lib = loadLibrary(path_with_ext);
			if (lib)
			{
				PluginCreator creator = (PluginCreator)getLibrarySymbol(lib, "createPlugin");
				if (creator)
				{
					IPlugin* plugin = creator(m_engine);
					if (!plugin)
					{
						g_log_error.log("Core") << "createPlugin failed.";
						LUMIX_DELETE(m_engine.getAllocator(), plugin);
						ASSERT(false);
					}
					else
					{
						addPlugin(plugin);
						m_libraries.push(lib);
						m_library_loaded.invoke(lib);
						g_log_info.log("Core") << "Plugin loaded.";
						Debug::StackTree::refreshModuleList();
						return plugin;
					}
				}
				else
				{
					g_log_error.log("Core") << "No createPlugin function in plugin.";
				}
				unloadLibrary(lib);
			}
			else
			{
				auto* plugin = StaticPluginRegister::create(path, m_engine);
				if (plugin)
				{
					g_log_info.log("Core") << "Plugin loaded.";
					addPlugin(plugin);
					return plugin;
				}
				g_log_warning.log("Core") << "Failed to load plugin.";
			}
			return nullptr;
		}
Пример #24
0
		void clear(Lumix::IAllocator& allocator)
		{
			for (auto* child : m_children)
			{
				child->clear(allocator);
				LUMIX_DELETE(allocator, child);
			}
			m_children.clear();
		}
Пример #25
0
	LUMIX_RENDERER_API IPlugin* createPlugin(Engine& engine)
	{
		RendererImpl* r = LUMIX_NEW(engine.getAllocator(), RendererImpl)(engine);
		if (r->create())
		{
			return r;
		}
		LUMIX_DELETE(engine.getAllocator(), r);
		return nullptr;
	}
Пример #26
0
	InputSystem* InputSystem::create(IAllocator& allocator)
	{
		auto* system = LUMIX_NEW(allocator, InputSystemImpl)(allocator);
		if (!system->create())
		{
			LUMIX_DELETE(allocator, system);
			return nullptr;
		}
		return system;
	}
Пример #27
0
	void PathManager::decrementRefCount(PathInternal* path)
	{
		MT::SpinLock lock(m_mutex);
		--path->m_ref_count;
		if (path->m_ref_count == 0)
		{
			m_paths.erase(path->m_id);
			LUMIX_DELETE(m_allocator, path);
		}
	}
Пример #28
0
FileSystemWatcher* FileSystemWatcher::create(const char* path, Lumix::IAllocator& allocator)
{
	auto* watcher = LUMIX_NEW(allocator, FileSystemWatcherImpl)(allocator);
	if(!watcher->start(path))
    {
        LUMIX_DELETE(allocator, watcher);
        return nullptr;
    }
	return watcher;
}
Пример #29
0
 bool start(const char* path)
 {
     task = LUMIX_NEW(allocator, FileSystemWatcherTask)(path, *this, allocator);
     if (!task->create("FileSystemWatcherTask"))
     {
         LUMIX_DELETE(allocator, task);
         task = nullptr;
         return false;
     }
     return true;
 }
Пример #30
0
	void PathManager::clear()
	{
		for (int i = m_paths.size() - 1; i >= 0; --i)
		{
			if (m_paths.at(i)->m_ref_count == 0)
			{
				LUMIX_DELETE(m_allocator, m_paths.at(i));
				m_paths.eraseAt(i);
			}
		}
	}