linux fixes; create default material for fbx without material; dll build fixed
This commit is contained in:
parent
0a55f34ec6
commit
a596d4f712
17 changed files with 409 additions and 495 deletions
|
@ -10,7 +10,7 @@ template <typename T> struct UniquePtr;
|
|||
struct AssetBrowser {
|
||||
static constexpr int TILE_SIZE = 96;
|
||||
|
||||
struct IPlugin {
|
||||
struct LUMIX_EDITOR_API IPlugin {
|
||||
virtual ~IPlugin() {}
|
||||
|
||||
virtual bool canCreateResource() const { return false; }
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace Lumix {
|
||||
|
||||
struct EntityFolders final {
|
||||
struct LUMIX_EDITOR_API EntityFolders final {
|
||||
using FolderID = u16;
|
||||
static constexpr FolderID INVALID_FOLDER = 0xffFF;
|
||||
|
||||
|
|
|
@ -363,13 +363,9 @@ void addSphere(UniverseView& view, const DVec3& center, float radius, Color colo
|
|||
|
||||
template <typename T> void writeToStream(OutputMemoryStream& stream, T value) { stream.write(value); }
|
||||
template <typename T> T readFromStream(InputMemoryStream& stream) { return stream.read<T>(); }
|
||||
template <> LUMIX_ENGINE_API Path readFromStream<Path>(InputMemoryStream& stream);
|
||||
template <> LUMIX_ENGINE_API void writeToStream<Path>(OutputMemoryStream& stream, Path);
|
||||
template <> LUMIX_ENGINE_API void writeToStream<const Path&>(OutputMemoryStream& stream, const Path& path);
|
||||
template <> LUMIX_ENGINE_API const char* readFromStream<const char*>(InputMemoryStream& stream);
|
||||
template <> LUMIX_ENGINE_API void writeToStream<const char*>(OutputMemoryStream& stream, const char* path);
|
||||
template <> LUMIX_EDITOR_API void writeToStream<const Path&>(OutputMemoryStream& stream, const Path& path);
|
||||
|
||||
template <> Path readFromStream<Path>(InputMemoryStream& stream)
|
||||
template <> LUMIX_EDITOR_API Path readFromStream<Path>(InputMemoryStream& stream)
|
||||
{
|
||||
const char* c_str = (const char*)stream.getData() + stream.getPosition();
|
||||
Path path(c_str);
|
||||
|
@ -378,21 +374,21 @@ template <> Path readFromStream<Path>(InputMemoryStream& stream)
|
|||
}
|
||||
|
||||
|
||||
template <> void writeToStream<const Path&>(OutputMemoryStream& stream, const Path& path)
|
||||
template <> LUMIX_EDITOR_API void writeToStream<const Path&>(OutputMemoryStream& stream, const Path& path)
|
||||
{
|
||||
const char* str = path.c_str();
|
||||
stream.write(str, stringLength(str) + 1);
|
||||
}
|
||||
|
||||
|
||||
template <> void writeToStream<Path>(OutputMemoryStream& stream, Path path)
|
||||
template <> LUMIX_EDITOR_API void writeToStream<Path>(OutputMemoryStream& stream, Path path)
|
||||
{
|
||||
const char* str = path.c_str();
|
||||
stream.write(str, stringLength(str) + 1);
|
||||
}
|
||||
|
||||
|
||||
template <> const char* readFromStream<const char*>(InputMemoryStream& stream)
|
||||
template <> LUMIX_EDITOR_API const char* readFromStream<const char*>(InputMemoryStream& stream)
|
||||
{
|
||||
const char* c_str = (const char*)stream.getData() + stream.getPosition();
|
||||
stream.skip(stringLength(c_str) + 1);
|
||||
|
@ -400,7 +396,7 @@ template <> const char* readFromStream<const char*>(InputMemoryStream& stream)
|
|||
}
|
||||
|
||||
|
||||
template <> void writeToStream<const char*>(OutputMemoryStream& stream, const char* value)
|
||||
template <> LUMIX_EDITOR_API void writeToStream<const char*>(OutputMemoryStream& stream, const char* value)
|
||||
{
|
||||
stream.write(value, stringLength(value) + 1);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ namespace Lumix
|
|||
}
|
||||
|
||||
DefaultAllocator::~DefaultAllocator() {
|
||||
os::memRelease(m_small_allocations);
|
||||
os::memRelease(m_small_allocations, PAGE_SIZE * MAX_PAGE_COUNT);
|
||||
}
|
||||
|
||||
void* DefaultAllocator::allocate(size_t n)
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Lumix {
|
|||
struct AABB;
|
||||
struct Matrix;
|
||||
|
||||
struct Sphere {
|
||||
struct LUMIX_ENGINE_API Sphere {
|
||||
Sphere();
|
||||
Sphere(float x, float y, float z, float _radius);
|
||||
Sphere(const Vec3& point, float _radius);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,7 @@ namespace LuaWrapper {
|
|||
|
||||
|
||||
#ifdef LUMIX_DEBUG
|
||||
struct DebugGuard {
|
||||
struct LUMIX_ENGINE_API DebugGuard {
|
||||
DebugGuard(lua_State* L);
|
||||
DebugGuard(lua_State* L, int offset);
|
||||
~DebugGuard();
|
||||
|
@ -27,7 +27,7 @@ namespace LuaWrapper {
|
|||
int top;
|
||||
};
|
||||
#else
|
||||
struct DebugGuard {
|
||||
struct LUMIX_ENGINE_API DebugGuard {
|
||||
DebugGuard(lua_State* L) {}
|
||||
DebugGuard(lua_State* L, int offset) {}
|
||||
};
|
||||
|
|
|
@ -336,7 +336,7 @@ struct Matrix3x4 {
|
|||
Vec4 columns[3];
|
||||
};
|
||||
|
||||
struct Matrix4x3 {
|
||||
struct LUMIX_ENGINE_API Matrix4x3 {
|
||||
Matrix4x3() {}
|
||||
explicit Matrix4x3(const Matrix& rhs);
|
||||
Matrix3x4 transposed() const;
|
||||
|
|
|
@ -164,7 +164,7 @@ LUMIX_ENGINE_API ThreadID getCurrentThreadID();
|
|||
|
||||
LUMIX_ENGINE_API void* memReserve(size_t size);
|
||||
LUMIX_ENGINE_API void memCommit(void* ptr, size_t size);
|
||||
LUMIX_ENGINE_API void memRelease(void* ptr);
|
||||
LUMIX_ENGINE_API void memRelease(void* ptr, size_t size); // size must be full size used in reserve
|
||||
LUMIX_ENGINE_API u32 getMemPageSize();
|
||||
|
||||
LUMIX_ENGINE_API FileIterator* createFileIterator(const char* path, IAllocator& allocator);
|
||||
|
@ -189,8 +189,7 @@ LUMIX_ENGINE_API u64 getLastModified(const char* file);
|
|||
LUMIX_ENGINE_API [[nodiscard]] bool makePath(const char* path);
|
||||
|
||||
LUMIX_ENGINE_API void setCursor(CursorType type);
|
||||
LUMIX_ENGINE_API void clipCursor(int screen_x, int screen_y, int w, int h);
|
||||
LUMIX_ENGINE_API void unclipCursor();
|
||||
LUMIX_ENGINE_API void grabMouse(WindowHandle win);
|
||||
|
||||
LUMIX_ENGINE_API void getDropFile(const Event& event, int idx, Span<char> out);
|
||||
LUMIX_ENGINE_API int getDropFileCount(const Event& event);
|
||||
|
|
|
@ -16,7 +16,7 @@ PageAllocator::~PageAllocator()
|
|||
while (p) {
|
||||
void* tmp = p;
|
||||
memcpy(&p, p, sizeof(p)); //-V579
|
||||
os::memRelease(tmp);
|
||||
os::memRelease(tmp, PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace reflection
|
|||
|
||||
struct Context {
|
||||
Scene* first_scene = nullptr;
|
||||
RegisteredComponent ComponentBases[ComponentType::MAX_TYPES_COUNT];
|
||||
RegisteredComponent component_bases[ComponentType::MAX_TYPES_COUNT];
|
||||
u32 components_count = 0;
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ void ComponentBase::visit(IPropertyVisitor& visitor) const {
|
|||
}
|
||||
|
||||
const ComponentBase* getComponent(ComponentType cmp_type) {
|
||||
return getContext().ComponentBases[cmp_type.index].cmp;
|
||||
return getContext().component_bases[cmp_type.index].cmp;
|
||||
}
|
||||
|
||||
const PropertyBase* getProperty(ComponentType cmp_type, const char* prop_name) {
|
||||
|
@ -71,16 +71,16 @@ builder::builder(IAllocator& allocator)
|
|||
|
||||
void builder::registerCmp(ComponentBase* cmp) {
|
||||
cmp->scene = crc32(scene->name);
|
||||
getContext().ComponentBases[cmp->component_type.index].cmp = cmp;
|
||||
getContext().ComponentBases[cmp->component_type.index].name_hash = crc32(cmp->name);
|
||||
getContext().ComponentBases[cmp->component_type.index].scene = crc32(scene->name);
|
||||
getContext().component_bases[cmp->component_type.index].cmp = cmp;
|
||||
getContext().component_bases[cmp->component_type.index].name_hash = crc32(cmp->name);
|
||||
getContext().component_bases[cmp->component_type.index].scene = crc32(scene->name);
|
||||
scene->cmps.push(cmp);
|
||||
}
|
||||
|
||||
ComponentType getComponentTypeFromHash(u32 hash)
|
||||
{
|
||||
for (u32 i = 0, c = getContext().components_count; i < c; ++i) {
|
||||
if (getContext().ComponentBases[i].name_hash == hash) {
|
||||
if (getContext().component_bases[i].name_hash == hash) {
|
||||
return {(i32)i};
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ ComponentType getComponentTypeFromHash(u32 hash)
|
|||
|
||||
u32 getComponentTypeHash(ComponentType type)
|
||||
{
|
||||
return getContext().ComponentBases[type.index].name_hash;
|
||||
return getContext().component_bases[type.index].name_hash;
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ ComponentType getComponentType(const char* name)
|
|||
Context& ctx = getContext();
|
||||
u32 name_hash = crc32(name);
|
||||
for (u32 i = 0, c = ctx.components_count; i < c; ++i) {
|
||||
if (ctx.ComponentBases[i].name_hash == name_hash) {
|
||||
if (ctx.component_bases[i].name_hash == name_hash) {
|
||||
return {(i32)i};
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ ComponentType getComponentType(const char* name)
|
|||
return INVALID_COMPONENT_TYPE;
|
||||
}
|
||||
|
||||
RegisteredComponent& type = ctx.ComponentBases[getContext().components_count];
|
||||
RegisteredComponent& type = ctx.component_bases[getContext().components_count];
|
||||
type.name_hash = name_hash;
|
||||
++ctx.components_count;
|
||||
return {i32(getContext().components_count - 1)};
|
||||
|
@ -123,7 +123,7 @@ Scene* getFirstScene() {
|
|||
void DynamicProperties::visit(IPropertyVisitor& visitor) const { visitor.visit(*this); }
|
||||
|
||||
Span<const RegisteredComponent> getComponents() {
|
||||
return Span(getContext().ComponentBases, getContext().components_count);
|
||||
return Span(getContext().component_bases, getContext().components_count);
|
||||
}
|
||||
|
||||
struct RadiansAttribute : IAttribute
|
||||
|
|
|
@ -115,7 +115,7 @@ struct StringEnumAttribute : IAttribute {
|
|||
};
|
||||
|
||||
|
||||
struct PropertyBase {
|
||||
struct LUMIX_ENGINE_API PropertyBase {
|
||||
PropertyBase(IAllocator& allocator) : attributes(allocator) {}
|
||||
Array<IAttribute*> attributes;
|
||||
|
||||
|
@ -124,7 +124,7 @@ struct PropertyBase {
|
|||
};
|
||||
|
||||
|
||||
struct DynamicProperties : PropertyBase {
|
||||
struct LUMIX_ENGINE_API DynamicProperties : PropertyBase {
|
||||
enum Type {
|
||||
I32,
|
||||
FLOAT,
|
||||
|
@ -489,7 +489,7 @@ auto& function(F func, const char* decl_code, const char* name)
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct ComponentBase {
|
||||
struct LUMIX_ENGINE_API ComponentBase {
|
||||
ComponentBase(IAllocator& allocator);
|
||||
|
||||
void visit(IPropertyVisitor& visitor) const;
|
||||
|
@ -541,7 +541,7 @@ struct Scene {
|
|||
|
||||
LUMIX_ENGINE_API Scene* getFirstScene();
|
||||
|
||||
struct builder {
|
||||
struct LUMIX_ENGINE_API builder {
|
||||
builder(IAllocator& allocator);
|
||||
|
||||
template <auto Creator, auto Destroyer>
|
||||
|
@ -729,7 +729,7 @@ struct builder {
|
|||
PropertyBase* last_prop = nullptr;
|
||||
};
|
||||
|
||||
builder build_scene(const char* scene_name);
|
||||
LUMIX_ENGINE_API builder build_scene(const char* scene_name);
|
||||
|
||||
} // namespace reflection
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ struct EventQueue {
|
|||
|
||||
static struct
|
||||
{
|
||||
WindowHandle grabbed_window = INVALID_WINDOW;
|
||||
EventQueue event_queue;
|
||||
Point relative_mode_pos = {};
|
||||
bool relative_mouse = false;
|
||||
|
@ -481,6 +482,17 @@ Point toScreen(WindowHandle win, int x, int y)
|
|||
return res;
|
||||
}
|
||||
|
||||
void updateGrabbedMouse() {
|
||||
if (G.grabbed_window == INVALID_WINDOW) {
|
||||
ClipCursor(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect((HWND)G.grabbed_window, &rect);
|
||||
ClipCursor(&rect);
|
||||
}
|
||||
|
||||
WindowHandle createWindow(const InitWindowArgs& args) {
|
||||
WCharStr<LUMIX_MAX_PATH> cls_name("lunex_window");
|
||||
static WNDCLASS wc = [&]() -> WNDCLASS {
|
||||
|
@ -495,25 +507,31 @@ WindowHandle createWindow(const InitWindowArgs& args) {
|
|||
e.win_move.x = (i16)LOWORD(lParam);
|
||||
e.win_move.y = (i16)HIWORD(lParam);
|
||||
G.event_queue.pushBack(e);
|
||||
updateGrabbedMouse();
|
||||
return 0;
|
||||
case WM_SIZE:
|
||||
e.type = Event::Type::WINDOW_SIZE;
|
||||
e.win_size.w = LOWORD(lParam);
|
||||
e.win_size.h = HIWORD(lParam);
|
||||
G.event_queue.pushBack(e);
|
||||
updateGrabbedMouse();
|
||||
return 0;
|
||||
case WM_CLOSE:
|
||||
e.type = Event::Type::WINDOW_CLOSE;
|
||||
G.event_queue.pushBack(e);
|
||||
if (hWnd == G.grabbed_window) G.grabbed_window = INVALID_WINDOW;
|
||||
updateGrabbedMouse();
|
||||
return 0;
|
||||
case WM_ACTIVATE:
|
||||
if (wParam == WA_INACTIVE) {
|
||||
showCursor(true);
|
||||
unclipCursor();
|
||||
grabMouse(INVALID_WINDOW);
|
||||
}
|
||||
|
||||
e.type = Event::Type::FOCUS;
|
||||
e.focus.gained = wParam != WA_INACTIVE;
|
||||
G.event_queue.pushBack(e);
|
||||
updateGrabbedMouse();
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||
|
@ -798,7 +816,7 @@ void memCommit(void* ptr, size_t size) {
|
|||
VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
|
||||
void memRelease(void* ptr) {
|
||||
void memRelease(void* ptr, size_t size) {
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
|
@ -1143,21 +1161,9 @@ bool makePath(const char* path)
|
|||
return error_code == ERROR_SUCCESS || error_code == ERROR_ALREADY_EXISTS;
|
||||
}
|
||||
|
||||
|
||||
void clipCursor(int x, int y, int w, int h)
|
||||
{
|
||||
RECT rect;
|
||||
rect.left = x;
|
||||
rect.right = x + w;
|
||||
rect.top = y;
|
||||
rect.bottom = y + h;
|
||||
ClipCursor(&rect);
|
||||
}
|
||||
|
||||
|
||||
void unclipCursor()
|
||||
{
|
||||
ClipCursor(NULL);
|
||||
void grabMouse(WindowHandle win) {
|
||||
G.grabbed_window = win;
|
||||
updateGrabbedMouse();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,9 +39,18 @@ static bool hasTangents(const ofbx::Geometry& geom) {
|
|||
}
|
||||
|
||||
|
||||
static void getMaterialName(const ofbx::Material* material, char (&out)[128])
|
||||
static void getMaterialName(const ofbx::Mesh* mesh, const ofbx::Material* material, char (&out)[128])
|
||||
{
|
||||
copyString(out, material ? material->name : "default");
|
||||
if (material) {
|
||||
copyString(out, material->name);
|
||||
}
|
||||
else if (mesh) {
|
||||
copyString(out, mesh->name);
|
||||
if (out[0] == '\0' && mesh->getParent()) copyString(out, mesh->getParent()->name);
|
||||
}
|
||||
else {
|
||||
copyString(out, "default");
|
||||
}
|
||||
char* iter = out;
|
||||
while (*iter)
|
||||
{
|
||||
|
@ -706,7 +715,7 @@ void FBXImporter::postprocessMeshes(const ImportConfig& cfg, const char* path)
|
|||
AABB aabb = {{FLT_MAX, FLT_MAX, FLT_MAX}, {-FLT_MAX, -FLT_MAX, -FLT_MAX}};
|
||||
float origin_radius_squared = 0;
|
||||
|
||||
int material_idx = getMaterialIndex(mesh, *import_mesh.fbx_mat);
|
||||
int material_idx = import_mesh.fbx_mat ? getMaterialIndex(mesh, *import_mesh.fbx_mat) : 0;
|
||||
ASSERT(material_idx >= 0);
|
||||
|
||||
const int* geom_materials = geom->getMaterials();
|
||||
|
@ -813,6 +822,17 @@ void FBXImporter::gatherGeometries(ofbx::IScene* scene)
|
|||
}
|
||||
}
|
||||
|
||||
static bool isSkinned(const ofbx::Geometry* geom) {
|
||||
if (geom && geom->getSkin()) {
|
||||
const ofbx::Skin* skin = geom->getSkin();
|
||||
for (int i = 0; i < skin->getClusterCount(); ++i) {
|
||||
if (skin->getCluster(i)->getIndicesCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FBXImporter::gatherMeshes(ofbx::IScene* scene)
|
||||
{
|
||||
|
@ -822,21 +842,21 @@ void FBXImporter::gatherMeshes(ofbx::IScene* scene)
|
|||
const int mat_count = fbx_mesh->getMaterialCount();
|
||||
for (int j = 0; j < mat_count; ++j) {
|
||||
ImportMesh& mesh = m_meshes.emplace(m_allocator);
|
||||
mesh.is_skinned = false;
|
||||
if (fbx_mesh->getGeometry() && fbx_mesh->getGeometry()->getSkin()) {
|
||||
const ofbx::Skin* skin = fbx_mesh->getGeometry()->getSkin();
|
||||
for (int i = 0; i < skin->getClusterCount(); ++i) {
|
||||
if (skin->getCluster(i)->getIndicesCount() > 0) {
|
||||
mesh.is_skinned = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mesh.is_skinned = isSkinned(fbx_mesh->getGeometry());
|
||||
mesh.fbx = fbx_mesh;
|
||||
mesh.fbx_mat = fbx_mesh->getMaterial(j);
|
||||
mesh.submesh = mat_count > 1 ? j : -1;
|
||||
mesh.lod = detectMeshLOD(mesh);
|
||||
}
|
||||
|
||||
if (mat_count == 0) {
|
||||
ImportMesh& mesh = m_meshes.emplace(m_allocator);
|
||||
mesh.is_skinned = isSkinned(fbx_mesh->getGeometry());
|
||||
mesh.fbx = fbx_mesh;
|
||||
mesh.fbx_mat = nullptr;
|
||||
mesh.submesh = -1;
|
||||
mesh.lod = detectMeshLOD(mesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1196,11 +1216,34 @@ void FBXImporter::writeMaterials(const char* src, const ImportConfig& cfg)
|
|||
{
|
||||
PROFILE_FUNCTION()
|
||||
const PathInfo src_info(src);
|
||||
for (const ImportMesh& mesh : m_meshes) {
|
||||
if (!mesh.fbx_mat) {
|
||||
char mat_name[128];
|
||||
getMaterialName(mesh.fbx, mesh.fbx_mat, mat_name);
|
||||
|
||||
const StaticString<LUMIX_MAX_PATH + 128> mat_src(src_info.m_dir, mat_name, ".mat");
|
||||
if (m_filesystem.fileExists(mat_src)) continue;
|
||||
|
||||
os::OutputFile f;
|
||||
if (!m_filesystem.open(mat_src, f))
|
||||
{
|
||||
logError("Failed to create ", mat_src);
|
||||
continue;
|
||||
}
|
||||
out_file.clear();
|
||||
writeString("shader \"pipelines/standard.shd\"\n");
|
||||
if (!f.write(out_file.data(), out_file.size())) {
|
||||
logError("Failed to write ", mat_src);
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
for (const ImportMaterial& material : m_materials) {
|
||||
if (!material.import) continue;
|
||||
|
||||
char mat_name[128];
|
||||
getMaterialName(material.fbx, mat_name);
|
||||
getMaterialName(nullptr, material.fbx, mat_name);
|
||||
|
||||
const StaticString<LUMIX_MAX_PATH + 128> mat_src(src_info.m_dir, mat_name, ".mat");
|
||||
if (m_filesystem.fileExists(mat_src)) continue;
|
||||
|
@ -2030,7 +2073,7 @@ void FBXImporter::writeMeshes(const char* src, int mesh_idx, const ImportConfig&
|
|||
|
||||
const ofbx::Material* material = import_mesh.fbx_mat;
|
||||
char mat[128];
|
||||
getMaterialName(material, mat);
|
||||
getMaterialName(import_mesh.fbx, material, mat);
|
||||
StaticString<LUMIX_MAX_PATH + 128> mat_id(src_info.m_dir, mat, ".mat");
|
||||
const i32 len = stringLength(mat_id.data);
|
||||
write(len);
|
||||
|
|
|
@ -118,12 +118,13 @@ void GameView::captureMouse(bool capture)
|
|||
os::showCursor(!capture || m_is_ingame_cursor);
|
||||
|
||||
if (capture) {
|
||||
os::grabMouse(ImGui::GetWindowViewport()->PlatformHandle);
|
||||
const os::Point cp = os::getMouseScreenPos();
|
||||
m_captured_mouse_x = cp.x;
|
||||
m_captured_mouse_y = cp.y;
|
||||
}
|
||||
else {
|
||||
os::unclipCursor();
|
||||
os::grabMouse(os::INVALID_WINDOW);
|
||||
os::setMouseScreenPos(m_captured_mouse_x, m_captured_mouse_y);
|
||||
}
|
||||
}
|
||||
|
@ -353,10 +354,6 @@ void GameView::onWindowGUI()
|
|||
m_pos = ImGui::GetItemRectMin();
|
||||
m_size = ImGui::GetItemRectSize();
|
||||
|
||||
if (m_is_mouse_captured) {
|
||||
os::clipCursor((int)m_pos.x, (int)m_pos.y, (int)m_size.x, (int)m_size.y);
|
||||
}
|
||||
|
||||
processInputEvents();
|
||||
controlsGUI(editor);
|
||||
}
|
||||
|
|
|
@ -1049,13 +1049,14 @@ void SceneView::captureMouse(bool capture)
|
|||
m_is_mouse_captured = capture;
|
||||
os::showCursor(!m_is_mouse_captured);
|
||||
if (capture) {
|
||||
os::grabMouse(ImGui::GetWindowViewport()->PlatformHandle);
|
||||
const os::Point p = os::getMouseScreenPos();
|
||||
m_captured_mouse_x = p.x;
|
||||
m_captured_mouse_y = p.y;
|
||||
}
|
||||
else {
|
||||
os::grabMouse(os::INVALID_WINDOW);
|
||||
os::setMouseScreenPos(m_captured_mouse_x, m_captured_mouse_y);
|
||||
os::unclipCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1476,12 +1477,6 @@ void SceneView::onWindowGUI()
|
|||
}
|
||||
}
|
||||
|
||||
if (m_is_mouse_captured) {
|
||||
const ImVec2 pos = ImGui::GetItemRectMin();
|
||||
const ImVec2 size = ImGui::GetItemRectSize();
|
||||
os::clipCursor((int)pos.x, (int)pos.y, (int)size.x, (int)size.y);
|
||||
}
|
||||
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (auto* payload = ImGui::AcceptDragDropPayload("path")) {
|
||||
const ImVec2 drop_pos = (ImGui::GetMousePos() - view_pos) / size;
|
||||
|
|
|
@ -55,6 +55,7 @@ static const char* downscale_src = R"#(
|
|||
|
||||
struct TransientBuffer {
|
||||
static constexpr u32 INIT_SIZE = 1024 * 1024;
|
||||
static constexpr u32 OVERFLOW_BUFFER_SIZE = 512 * 1024 * 1024;
|
||||
|
||||
void init() {
|
||||
m_buffer = gpu::allocBufferHandle();
|
||||
|
@ -78,7 +79,7 @@ struct TransientBuffer {
|
|||
MutexGuard lock(m_mutex);
|
||||
if (!m_overflow.buffer) {
|
||||
m_overflow.buffer = gpu::allocBufferHandle();
|
||||
m_overflow.data = (u8*)os::memReserve(512 * 1024 * 1024);
|
||||
m_overflow.data = (u8*)os::memReserve(OVERFLOW_BUFFER_SIZE);
|
||||
m_overflow.size = 0;
|
||||
m_overflow.commit = 0;
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ struct TransientBuffer {
|
|||
memcpy(mem, m_overflow.data, m_overflow.size);
|
||||
gpu::unmap(m_overflow.buffer);
|
||||
}
|
||||
os::memRelease(m_overflow.data);
|
||||
os::memRelease(m_overflow.data, OVERFLOW_BUFFER_SIZE);
|
||||
m_overflow.data = nullptr;
|
||||
m_overflow.commit = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue