upgraded to stb image resize 2; fixed some issues when compiling with clang on windows
This commit is contained in:
parent
fe87e5a347
commit
3d5d805846
1
external/imgui/imgui_user.inl
vendored
1
external/imgui/imgui_user.inl
vendored
|
@ -1299,7 +1299,6 @@ namespace ImGuiEx {
|
|||
bool changed = false;
|
||||
SetNextItemWidth(width);
|
||||
BeginGroup();
|
||||
float w = CalcItemWidth();
|
||||
SetNextItemWidth(width - CalcTextSize(ICON_FA_TIMES).x - 1);
|
||||
SetNextItemAllowOverlap();
|
||||
if (set_keyboard_focus) SetKeyboardFocusHere();
|
||||
|
|
2634
external/stb/stb_image_resize.h
vendored
2634
external/stb/stb_image_resize.h
vendored
File diff suppressed because it is too large
Load diff
10303
external/stb/stb_image_resize2.h
vendored
Normal file
10303
external/stb/stb_image_resize2.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -57,7 +57,7 @@ struct AnimationSampler {
|
|||
if (anim.m_max_accessed_bone_index >= pose.count) return; // can happen if skeletons do not match
|
||||
const Model& model = *ctx.model;
|
||||
const Time time = ctx.time;
|
||||
const BoneMask* mask = ctx.mask;
|
||||
//const BoneMask* mask = ctx.mask;
|
||||
const float weight = ctx.weight;
|
||||
|
||||
ASSERT(!pose.is_absolute);
|
||||
|
|
|
@ -52,9 +52,6 @@ struct AnimationAssetBrowserPlugin : AssetBrowser::IPlugin {
|
|||
{
|
||||
m_resource = app.getEngine().getResourceManager().load<Animation>(path);
|
||||
|
||||
Engine& engine = m_app.getEngine();
|
||||
|
||||
|
||||
m_viewer.m_world->createComponent(ANIMABLE_TYPE, *m_viewer.m_mesh);
|
||||
|
||||
auto* anim_module = static_cast<AnimationModule*>(m_viewer.m_world->getModule(ANIMABLE_TYPE));
|
||||
|
@ -212,8 +209,6 @@ struct AnimationAssetBrowserPlugin : AssetBrowser::IPlugin {
|
|||
|
||||
if ((!rotations.empty() || !const_rotations.empty()) && ImGui::TreeNode("Rotations")) {
|
||||
for (const Animation::RotationTrack& track : rotations) {
|
||||
u32 track_idx = u32(&track - rotations.begin());
|
||||
|
||||
const Model::Bone& bone = m_model->getBone(track.bone_index);
|
||||
ImGuiTreeNodeFlags flags = m_selected_bone == track.bone_index ? ImGuiTreeNodeFlags_Selected : 0;
|
||||
flags |= ImGuiTreeNodeFlags_OpenOnArrow;
|
||||
|
|
|
@ -236,8 +236,7 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
{
|
||||
FileSystem& fs = m_app.getEngine().getFileSystem();
|
||||
OutputMemoryStream data(m_allocator);
|
||||
ResourceManagerHub& rm = m_app.getEngine().getResourceManager();
|
||||
if (fs.getContentSync(Path(path), data)) {
|
||||
if (fs.getContentSync(path, data)) {
|
||||
InputMemoryStream str(data);
|
||||
if (m_controller.deserialize(str)) {
|
||||
checkSkeleton();
|
||||
|
@ -329,7 +328,6 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) ImGui::CloseCurrentPopup();
|
||||
if (ImGui::IsWindowAppearing()) m_node_filter_selection = 0;
|
||||
if (m_node_filter.gui("Filter", 150, ImGui::IsWindowAppearing())) m_node_filter_selection = 0;
|
||||
Node* n = nullptr;
|
||||
if (m_node_filter.isActive()) {
|
||||
struct : INodeTypeVisitor {
|
||||
bool beginCategory(const char* _category) override {
|
||||
|
@ -346,7 +344,7 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
|
||||
StaticString<128> label(category, _label);
|
||||
if (shortcut) label.append(" (LMB + ", shortcut, ")");
|
||||
if (ImGui::Selectable(label, selected) || insert_enter && selected) {
|
||||
if (ImGui::Selectable(label, selected) || (insert_enter && selected)) {
|
||||
n = creator.create(*win);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
@ -588,7 +586,7 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
float weight = blob.read<float>();
|
||||
Time time = blob.read<Time>();
|
||||
bool looped = blob.read<bool>();
|
||||
ImGui::Text("slot = %d, weight = %f, time = %f", slot, weight, time.seconds());
|
||||
ImGui::Text("slot = %d, weight = %f, time = %f, looped = %s", slot, weight, time.seconds(), looped ? "true" : "false");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -836,7 +834,6 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
StringView subres = Path::getSubresource(path);
|
||||
if (Path::hasExtension(subres, "ani")) {
|
||||
Controller::AnimationEntry& entry = m_controller.m_animation_entries.emplace();
|
||||
ResourceManagerHub& res_manager = m_app.getEngine().getResourceManager();
|
||||
entry.animation = path;
|
||||
entry.set = 0;
|
||||
entry.slot = m_controller.m_animation_slots.size();
|
||||
|
@ -852,7 +849,6 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
StringView subres = Path::getSubresource(path);
|
||||
if (Path::hasExtension(subres, "ani")) {
|
||||
Controller::AnimationEntry& entry = m_controller.m_animation_entries.emplace();
|
||||
ResourceManagerHub& res_manager = m_app.getEngine().getResourceManager();
|
||||
entry.animation = path;
|
||||
entry.set = 0;
|
||||
entry.slot = m_controller.m_animation_slots.size();
|
||||
|
@ -1020,8 +1016,6 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
}
|
||||
|
||||
void windowGUI() override {
|
||||
const CommonActions& actions = m_app.getCommonActions();
|
||||
|
||||
if (!m_to_fix_skeleton.empty()) {
|
||||
ImGui::OpenPopup(ICON_FA_EXCLAMATION_TRIANGLE " Fix skeleton");
|
||||
}
|
||||
|
@ -1184,7 +1178,6 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetComp
|
|||
}
|
||||
|
||||
void createResource(OutputMemoryStream& blob) override {
|
||||
ResourceManager* rm = m_app.getEngine().getResourceManager().get(anim::Controller::TYPE);
|
||||
anim_editor::Controller controller(Path("new controller"), m_app.getAllocator());
|
||||
controller.serialize(blob);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ void Blend2DNode::dataChanged() {
|
|||
u32 a, b;
|
||||
bool valid = true;
|
||||
bool operator ==(const Edge& rhs) {
|
||||
return a == rhs.a && b == rhs.b || a == rhs.b && b == rhs.a;
|
||||
return (a == rhs.a && b == rhs.b) || (a == rhs.b && b == rhs.a);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -368,7 +368,6 @@ bool Blend1DNode::propertiesGUI(Model& skeleton) {
|
|||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
static i32 selected = -1;
|
||||
res = editSlot(m_controller, "##anim", &child.slot) || res;
|
||||
|
||||
ImGui::PopID();
|
||||
|
@ -431,7 +430,6 @@ anim::Node* AnimationNode::compile(anim::Controller& controller) {
|
|||
|
||||
bool AnimationNode::propertiesGUI(Model& skeleton) {
|
||||
ImGuiEx::Label("Slot");
|
||||
static i32 selected = -1;
|
||||
bool res = editSlot(m_controller, "##slot", &m_slot);
|
||||
ImGuiEx::Label("Looping");
|
||||
bool loop = m_flags & Flags::LOOPED;
|
||||
|
|
|
@ -746,8 +746,6 @@ struct AssetCompilerImpl : AssetCompiler {
|
|||
}
|
||||
}
|
||||
else {
|
||||
StringView ext = Path::getExtension(path_obj);
|
||||
|
||||
auto dep_iter = m_dependencies.find(path_obj);
|
||||
if (dep_iter.isValid()) {
|
||||
for (const Path& p : dep_iter.value()) {
|
||||
|
|
|
@ -8,7 +8,6 @@ EntityFolders::EntityFolders(World& world, IAllocator& allocator)
|
|||
: m_entities(allocator)
|
||||
, m_world(world)
|
||||
, m_folders(allocator)
|
||||
, m_allocator(allocator)
|
||||
{
|
||||
ASSERT(!world.getFirstEntity().isValid());
|
||||
world.entityDestroyed().bind<&EntityFolders::onEntityDestroyed>(this);
|
||||
|
|
|
@ -58,7 +58,6 @@ private:
|
|||
void unlink(Folder& folder);
|
||||
FolderHandle generateUniqueID();
|
||||
|
||||
IAllocator& m_allocator;
|
||||
World& m_world;
|
||||
Array<Entity> m_entities;
|
||||
Array<Folder> m_folders;
|
||||
|
|
|
@ -269,7 +269,6 @@ struct ProfilerUIImpl final : StudioApp::GUIPlugin {
|
|||
|
||||
void timeline(float from_x, float to_x, float top, float bottom, u64 start_t) {
|
||||
const float view_length_us = (float)1'000'000 * float(m_range / double(profiler::frequency()));
|
||||
const float timeline_height = ImGui::GetTextLineHeightWithSpacing();
|
||||
const ImColor border_color(ImGui::GetStyle().Colors[ImGuiCol_FrameBg]);
|
||||
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
|
@ -1348,7 +1347,6 @@ struct ProfilerUIImpl final : StudioApp::GUIPlugin {
|
|||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
timeline(from_x, to_x, timeline_y, before_gpu_y, timeline_start_t);
|
||||
}
|
||||
|
||||
|
|
|
@ -1367,7 +1367,6 @@ struct StudioAppImpl final : StudioApp
|
|||
if (selected) {
|
||||
char filename[MAX_PATH];
|
||||
Path::normalize(m_file_selector.getPath(), filename);
|
||||
const char* base_path = m_engine->getFileSystem().getBasePath();
|
||||
EntityRef entity = selected_entities[0];
|
||||
m_editor->getPrefabSystem().savePrefab(entity, Path(filename));
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
@ -1845,7 +1844,6 @@ struct StudioAppImpl final : StudioApp
|
|||
node_open = ImGui::TreeNodeEx((void*)folder, flags, "%s%s", ICON_FA_FOLDER, folder->name);
|
||||
}
|
||||
}
|
||||
const ImGuiID node_id = ImGui::GetItemID();
|
||||
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (auto* payload = ImGui::AcceptDragDropPayload("entity")) {
|
||||
|
@ -3001,7 +2999,7 @@ struct StudioAppImpl final : StudioApp
|
|||
LuaWrapper::push(L, world); // [Entity.new, Lumix.Entity, world]
|
||||
LuaWrapper::push(L, entity.index); // [Entity.new, Lumix.Entity, world, entity_index]
|
||||
const bool error = !LuaWrapper::pcall(L, 3, 1); // [entity]
|
||||
return 1;
|
||||
return error ? 0 : 1;
|
||||
}
|
||||
|
||||
static int LUA_getResources(lua_State* L)
|
||||
|
|
|
@ -45,7 +45,7 @@ enum class TokenType : u8 {
|
|||
};
|
||||
|
||||
static bool isWordChar(char c) {
|
||||
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_';
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
|
||||
}
|
||||
|
||||
static bool tokenize(const char* str, u32& token_len, u8& token_type, u8 prev_token_type) {
|
||||
|
@ -196,7 +196,7 @@ static bool tokenize(const char* str, u32& token_len, u8& token_type, u8 prev_to
|
|||
return *c;
|
||||
}
|
||||
|
||||
if (*c >= 'a' && *c <= 'z' || *c >= 'A' && *c <= 'Z' || *c == '_') {
|
||||
if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_') {
|
||||
token_type = (u8)TokenType::IDENTIFIER;
|
||||
while (isWordChar(*c)) ++c;
|
||||
token_len = u32(c - str);
|
||||
|
@ -246,7 +246,7 @@ enum class TokenType : u8 {
|
|||
};
|
||||
|
||||
static bool isWordChar(char c) {
|
||||
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_';
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
|
||||
}
|
||||
|
||||
static bool tokenize(const char* str, u32& token_len, u8& token_type, u8 prev_token_type) {
|
||||
|
@ -381,7 +381,7 @@ static bool tokenize(const char* str, u32& token_len, u8& token_type, u8 prev_to
|
|||
return *c;
|
||||
}
|
||||
|
||||
if (*c >= 'a' && *c <= 'z' || *c >= 'A' && *c <= 'Z' || *c == '_') {
|
||||
if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_') {
|
||||
token_type = (u8)TokenType::IDENTIFIER;
|
||||
while (isWordChar(*c)) ++c;
|
||||
token_len = u32(c - str);
|
||||
|
@ -417,8 +417,8 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
i32 line = 0;
|
||||
bool operator !=(const TextPoint& rhs) const { return col != rhs.col || line != rhs.line; }
|
||||
bool operator ==(const TextPoint& rhs) const { return col == rhs.col && line == rhs.line; }
|
||||
bool operator < (const TextPoint& rhs) const { return line < rhs.line || line == rhs.line && col < rhs.col; }
|
||||
bool operator > (const TextPoint& rhs) const { return line > rhs.line || line == rhs.line && col > rhs.col; }
|
||||
bool operator < (const TextPoint& rhs) const { return line < rhs.line || (line == rhs.line && col < rhs.col); }
|
||||
bool operator > (const TextPoint& rhs) const { return line > rhs.line || (line == rhs.line && col > rhs.col); }
|
||||
};
|
||||
|
||||
struct Cursor : TextPoint {
|
||||
|
@ -641,7 +641,6 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
}
|
||||
|
||||
ImVec2 toScreenPosition(u32 line, u32 col) {
|
||||
ImVec2 v = m_text_area_screen_pos;
|
||||
float y = line * ImGui::GetTextLineHeight();
|
||||
const char* line_str = m_lines[line].value.c_str();
|
||||
float x = ImGui::CalcTextSize(line_str, line_str + col).x;
|
||||
|
@ -810,9 +809,7 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
|
||||
void moveCursorDown(Cursor& cursor, u32 line_count = 1) {
|
||||
const char* line_str = m_lines[cursor.line].value.c_str();
|
||||
float old_x = ImGui::CalcTextSize(line_str, line_str + cursor.col).x;
|
||||
|
||||
ImVec2 cursor_pos = toScreenPosition(cursor.line, cursor.col);
|
||||
cursor.line = minimum(m_lines.size() - 1, cursor.line + line_count);
|
||||
|
||||
u32 num_chars_in_line = m_lines[cursor.line].length();
|
||||
|
@ -1056,7 +1053,7 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
}
|
||||
|
||||
static bool isWordChar(char c) {
|
||||
return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_';
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
|
||||
}
|
||||
|
||||
Cursor getWord(TextPoint& point) const {
|
||||
|
@ -1090,7 +1087,7 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
Cursor& getBottomCursor() {
|
||||
Cursor* bottom = &m_cursors[0];
|
||||
for (Cursor& cursor : m_cursors) {
|
||||
if (bottom->line < cursor.line || bottom->line == cursor.line && bottom->col < cursor.col) {
|
||||
if (bottom->line < cursor.line || (bottom->line == cursor.line && bottom->col < cursor.col)) {
|
||||
bottom = &cursor;
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1148,6 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
r.to = to;
|
||||
r.execute(*this, false);
|
||||
|
||||
i32 line = from.line;
|
||||
for (Cursor& cursor : m_cursors) {
|
||||
if (cursor < from) continue;
|
||||
|
||||
|
@ -1343,9 +1339,6 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
p.x += text_area_size.x - 350;
|
||||
p.x = maximum(p.x, text_area_pos.x);
|
||||
ImGui::SetCursorScreenPos(p);
|
||||
float w = text_area_pos.x + text_area_size.x - p.x;
|
||||
float h = ImGui::GetTextLineHeightWithSpacing();
|
||||
ImGui::SetCursorScreenPos(p);
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
if (m_focus_search) ImGui::SetKeyboardFocusHere();
|
||||
m_focus_search = false;
|
||||
|
@ -1358,7 +1351,7 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
else if (ImGui::InputTextWithHint("##findtext", ICON_FA_SEARCH " Find Text", m_search_text, sizeof(m_search_text), flags)) {
|
||||
find(m_search_from);
|
||||
}
|
||||
if (ImGui::IsItemActive() && ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_F3)) {
|
||||
if ((ImGui::IsItemActive() && ImGui::IsKeyPressed(ImGuiKey_Enter)) || ImGui::IsKeyPressed(ImGuiKey_F3)) {
|
||||
find(m_cursors[0]);
|
||||
}
|
||||
if (font) ImGui::PopFont();
|
||||
|
@ -1472,7 +1465,7 @@ struct CodeEditorImpl final : CodeEditor {
|
|||
ImGui::ItemAdd(bb, id);
|
||||
const bool hovered = ImGui::ItemHoverable(bb, id, 0);
|
||||
const bool clicked = hovered && ImGui::IsItemClicked();
|
||||
if (m_focus_editor || clicked && !ImGui::IsItemActive()) {
|
||||
if (m_focus_editor || (clicked && !ImGui::IsItemActive())) {
|
||||
m_focus_editor = false;
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
ImGui::SetActiveID(id, window);
|
||||
|
|
|
@ -2199,7 +2199,6 @@ public:
|
|||
ASSERT(entities);
|
||||
if (count <= 0) return;
|
||||
|
||||
World* world = getWorld();
|
||||
UniquePtr<IEditorCommand> command = UniquePtr<LocalRotateEntityCommand>::create(m_allocator, *this, entities, local_rotations, count, m_allocator);
|
||||
executeCommand(command.move());
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ static struct Instance
|
|||
}
|
||||
|
||||
static EVENT_TRACE_LOGFILE trace = {};
|
||||
trace.LoggerName = KERNEL_LOGGER_NAME;
|
||||
trace.LoggerName = (decltype(trace.LoggerName))KERNEL_LOGGER_NAME;
|
||||
trace.ProcessTraceMode = PROCESS_TRACE_MODE_RAW_TIMESTAMP | PROCESS_TRACE_MODE_REAL_TIME | PROCESS_TRACE_MODE_EVENT_RECORD;
|
||||
trace.EventRecordCallback = TraceTask::callback;
|
||||
trace_task.open_handle = OpenTrace(&trace);
|
||||
|
|
|
@ -249,7 +249,6 @@ Span<u8> OutputPagedStream::reserve(u32 size) {
|
|||
}
|
||||
|
||||
bool OutputPagedStream::write(const void* data, u64 size) {
|
||||
const u8* src = (const u8*)data;
|
||||
while (size > 0) {
|
||||
Span<u8> dst = reserve((u32)size);
|
||||
memcpy(dst.begin(), data, dst.length());
|
||||
|
|
|
@ -138,7 +138,7 @@ struct LUMIX_ENGINE_API String {
|
|||
u32 length() const { return m_size; }
|
||||
const char* c_str() const { return isSmall() ? m_small : m_big; }
|
||||
template <typename... T>
|
||||
void append(T... args) { int tmp[] = { 0, (add(args), 0)... }; }
|
||||
void append(T... args) { int tmp[] = { 0, (add(args), 0)... }; (void)tmp; }
|
||||
void insert(u32 position, const char* value);
|
||||
void insert(u32 position, StringView value);
|
||||
void eraseAt(u32 position);
|
||||
|
|
|
@ -1550,6 +1550,7 @@ struct NetworkStream* listen(const char* ip, u16 port, IAllocator& allocator) {
|
|||
if (retVal == SOCKET_ERROR) return nullptr;
|
||||
|
||||
i32 res = ::listen(listen_socket, 10);
|
||||
if (res != 0) return nullptr;
|
||||
|
||||
SOCKET socket = ::accept(listen_socket, nullptr, nullptr);
|
||||
closesocket(listen_socket);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "renderer/renderer.h"
|
||||
#include "stb/stb_image.h"
|
||||
#include <math.h>
|
||||
#include <stb/stb_image_resize.h>
|
||||
#include <stb/stb_image_resize2.h>
|
||||
|
||||
namespace Lumix {
|
||||
|
||||
|
@ -886,9 +886,7 @@ struct ResizeNode final : CompositeTexture::Node {
|
|||
const u32 h = type == Type::PIXELS ? size.y : u32(in.h * scale.y * 0.01f + 0.5f);
|
||||
CompositeTexture::Image& out = m_outputs.emplace(w, h, in.channels, m_allocator);
|
||||
|
||||
const i32 res = stbir_resize_float(in.pixels.data(), in.w, in.h, 0, out.pixels.data(), w, h, 0, out.channels);
|
||||
if (res != 1) return error("Failed to resize image");
|
||||
return true;
|
||||
return nullptr != stbir_resize_float_linear(in.pixels.data(), in.w, in.h, 0, out.pixels.data(), w, h, 0, (stbir_pixel_layout)out.channels);
|
||||
}
|
||||
|
||||
bool gui() override {
|
||||
|
@ -3374,7 +3372,7 @@ struct CompositeTextureEditorImpl : CompositeTextureEditor, NodeEditor {
|
|||
Renderer* renderer = (Renderer*)m_resource.m_app.getEngine().getSystemManager().getSystem("renderer");
|
||||
if (renderer) {
|
||||
const CompositeTexture::Image& pd = preview_node->m_outputs[0];
|
||||
gpu::TextureFormat format;
|
||||
gpu::TextureFormat format = gpu::TextureFormat::RGBA32F;
|
||||
switch (pd.channels) {
|
||||
case 1: format = gpu::TextureFormat::R32F; break;
|
||||
case 2: format = gpu::TextureFormat::RG32F; break;
|
||||
|
|
|
@ -827,7 +827,6 @@ void FBXImporter::postprocessMeshes(const ImportConfig& cfg, const Path& path)
|
|||
VertexLayout vertex_layout;
|
||||
|
||||
const bool compute_tangents = !tangents.values && uvs.values;
|
||||
const int packed_vertex_size = getVertexSize(*mesh, import_mesh.is_skinned, cfg);
|
||||
|
||||
vertex_layout.size = sizeof(Vec3); // position
|
||||
vertex_layout.normal_offset = vertex_layout.size;
|
||||
|
@ -942,7 +941,6 @@ void FBXImporter::gatherMeshes()
|
|||
for (int mesh_idx = 0; mesh_idx < c; ++mesh_idx) {
|
||||
const ofbx::Mesh* fbx_mesh = (const ofbx::Mesh*)m_scene->getMesh(mesh_idx);
|
||||
const int mat_count = fbx_mesh->getMaterialCount();
|
||||
const i32 meshes_offset = m_meshes.size();
|
||||
for (int j = 0; j < mat_count; ++j) {
|
||||
ImportMesh& mesh = m_meshes.emplace(m_allocator);
|
||||
mesh.is_skinned = false;
|
||||
|
|
|
@ -72,7 +72,6 @@ private:
|
|||
int width;
|
||||
int height;
|
||||
} m_forced_viewport;
|
||||
int m_captured_mouse_x, m_captured_mouse_y;
|
||||
Action m_toggle_ui;
|
||||
Action m_fullscreen_action;
|
||||
};
|
||||
|
|
|
@ -218,7 +218,6 @@ struct Node : NodeEditorNode {
|
|||
bool nodeGUI() override {
|
||||
m_input_counter = 0;
|
||||
m_output_counter = 0;
|
||||
const ImVec2 old_pos = m_pos;
|
||||
ImGuiEx::BeginNode(m_id, m_pos, &m_selected);
|
||||
bool res = onGUI();
|
||||
if (m_error.length() > 0) {
|
||||
|
@ -3379,7 +3378,6 @@ struct ParticleEditorWindow : AssetEditorWindow, NodeEditor {
|
|||
|
||||
for (u32 emitter_idx = 0, c = system->getEmitters().size(); emitter_idx < c; ++emitter_idx) {
|
||||
ASSERT(c == m_resource.m_emitters.size());
|
||||
const ParticleSystem::Emitter& emitter = system->getEmitters()[emitter_idx];
|
||||
const UniquePtr<ParticleEmitterEditorResource>& editor_emitter = m_resource.m_emitters[emitter_idx];
|
||||
OutputMemoryStream instructions(m_allocator);
|
||||
instructions.resize(editor_emitter->m_update.size() + editor_emitter->m_emit.size() + editor_emitter->m_output.size());
|
||||
|
|
|
@ -55,22 +55,16 @@
|
|||
#include "renderer/texture.h"
|
||||
#include "renderer/terrain.h"
|
||||
#include "scene_view.h"
|
||||
#include "stb/stb_image.h"
|
||||
#include "stb/stb_image_resize.h"
|
||||
#include "terrain_editor.h"
|
||||
#include "world_viewer.h"
|
||||
|
||||
#define RGBCX_IMPLEMENTATION
|
||||
#include <rgbcx/rgbcx.h>
|
||||
#include <stb/stb_image_resize.h>
|
||||
#include "stb/stb_image.h"
|
||||
#include <stb/stb_image_resize2.h>
|
||||
|
||||
|
||||
using namespace Lumix;
|
||||
static AtomicI32 xx = 0;
|
||||
|
||||
static Animation::Flags operator | (Animation::Flags a, Animation::Flags b) {
|
||||
return Animation::Flags(u32(a) | u32(b));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -220,12 +214,12 @@ static void computeMip(Span<const u8> src, Span<u8> dst, u32 w, u32 h, u32 dst_w
|
|||
downsampleNormal(src, dst, w, h, dst_w, dst_h);
|
||||
}
|
||||
else if (is_srgb) {
|
||||
i32 res = stbir_resize_uint8_srgb(src.begin(), w, h, 0, dst.begin(), dst_w, dst_h, 0, 4, 3, STBIR_ALPHA_CHANNEL_NONE);
|
||||
ASSERT(res == 1);
|
||||
u8* res = stbir_resize_uint8_srgb(src.begin(), w, h, 0, dst.begin(), dst_w, dst_h, 0, STBIR_RGBA);
|
||||
ASSERT(res);
|
||||
}
|
||||
else {
|
||||
i32 res = stbir_resize_uint8(src.begin(), w, h, 0, dst.begin(), dst_w, dst_h, 0, 4);
|
||||
ASSERT(res == 1);
|
||||
u8* res = stbir_resize_uint8_linear(src.begin(), w, h, 0, dst.begin(), dst_w, dst_h, 0, STBIR_RGBA);
|
||||
ASSERT(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1523,7 +1517,7 @@ struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
|||
const CompositeTexture::Image& layer0 = res.layers[0];
|
||||
if (layer0.channels != 4) return;
|
||||
|
||||
stbir_resize_uint8(layer0.asU8().data(),
|
||||
stbir_resize_uint8_linear(layer0.asU8().data(),
|
||||
layer0.w,
|
||||
layer0.h,
|
||||
0,
|
||||
|
@ -1531,7 +1525,7 @@ struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
|||
AssetBrowser::TILE_SIZE,
|
||||
AssetBrowser::TILE_SIZE,
|
||||
0,
|
||||
4);
|
||||
STBIR_RGBA);
|
||||
|
||||
applyTint();
|
||||
|
||||
|
@ -1548,7 +1542,7 @@ struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
|||
return;
|
||||
}
|
||||
|
||||
stbir_resize_uint8(data,
|
||||
stbir_resize_uint8_linear(data,
|
||||
w,
|
||||
h,
|
||||
0,
|
||||
|
@ -1556,7 +1550,7 @@ struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
|||
AssetBrowser::TILE_SIZE,
|
||||
AssetBrowser::TILE_SIZE,
|
||||
0,
|
||||
4);
|
||||
STBIR_RGBA);
|
||||
stbi_image_free(data);
|
||||
|
||||
applyTint();
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
#pragma warning(disable : 4312)
|
||||
#endif
|
||||
#include "stb/stb_image.h"
|
||||
#include "stb/stb_image_resize.h"
|
||||
#include "stb/stb_image_resize2.h"
|
||||
|
|
|
@ -791,162 +791,6 @@ Terrain* TerrainEditor::getTerrain() const {
|
|||
return module->getTerrain(selected_entities[0]);
|
||||
}
|
||||
|
||||
struct PrefabProbability {
|
||||
PrefabResource* resource;
|
||||
Vec4 distances;
|
||||
Vec2 scale;
|
||||
Vec2 y_offset;
|
||||
float multiplier = 1.f;
|
||||
};
|
||||
|
||||
struct ModelProbability {
|
||||
Model* resource;
|
||||
Vec4 distances;
|
||||
Vec2 scale;
|
||||
Vec2 y_offset;
|
||||
float multiplier = 1.f;
|
||||
};
|
||||
|
||||
static void getPrefabs(StudioApp& app, lua_State* L, i32 idx, const char* key, Array<PrefabProbability>& prefabs) {
|
||||
const int type = LuaWrapper::getField(L, idx, key);
|
||||
if (type == LUA_TNIL) luaL_error(L, "missing `%s`", key);
|
||||
if (type != LUA_TTABLE) luaL_error(L, "`%s` is not a table", key);
|
||||
|
||||
WorldEditor& editor = app.getWorldEditor();
|
||||
ResourceManagerHub& rm = editor.getEngine().getResourceManager();
|
||||
|
||||
const i32 n = (int)lua_objlen(L, -1);
|
||||
for (i32 i = 0; i < n; ++i) {
|
||||
lua_rawgeti(L, -1, i + 1);
|
||||
if(lua_istable(L, -1)) {
|
||||
if (LuaWrapper::getField(L, -1, "prefab") != LUA_TSTRING) {
|
||||
lua_pop(L, 1);
|
||||
luaL_argerror(L, idx, "'prefab' is not string or is missing");
|
||||
}
|
||||
const char* prefab_path = LuaWrapper::toType<const char*>(L, -1);
|
||||
PrefabResource* res = rm.load<PrefabResource>(Path(prefab_path));
|
||||
lua_pop(L, 1);
|
||||
lua_getfield(L, -1, "distances");
|
||||
if (!LuaWrapper::isType<Vec4>(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
res->decRefCount();
|
||||
luaL_argerror(L, idx, "'distances' is not vec4 or is missing");
|
||||
}
|
||||
const Vec4 distances = LuaWrapper::toType<Vec4>(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
Vec2 scale = Vec2(1, 1);
|
||||
LuaWrapper::getOptionalField(L, -1, "scale", &scale);
|
||||
Vec2 y_offset = Vec2(0, 0);
|
||||
LuaWrapper::getOptionalField(L, -1, "y_offset", &y_offset);
|
||||
|
||||
PrefabProbability& prob = prefabs.emplace();
|
||||
LuaWrapper::getOptionalField(L, -1, "multiplier", &prob.multiplier);
|
||||
prob.resource = res;
|
||||
prob.distances = distances;
|
||||
prob.scale = scale;
|
||||
prob.y_offset = y_offset;
|
||||
}
|
||||
else {
|
||||
lua_pop(L, 1);
|
||||
luaL_argerror(L, idx, "table of prefabs expected");
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
static void getModels(StudioApp& app, lua_State* L, i32 idx, const char* key, Array<ModelProbability>& prefabs) {
|
||||
const int type = LuaWrapper::getField(L, idx, key);
|
||||
if (type == LUA_TNIL) luaL_error(L, "missing `%s`", key);
|
||||
if (type != LUA_TTABLE) luaL_error(L, "`%s` is not a table", key);
|
||||
|
||||
WorldEditor& editor = app.getWorldEditor();
|
||||
ResourceManagerHub& rm = editor.getEngine().getResourceManager();
|
||||
|
||||
const i32 n = (int)lua_objlen(L, -1);
|
||||
for (i32 i = 0; i < n; ++i) {
|
||||
lua_rawgeti(L, -1, i + 1);
|
||||
if(lua_istable(L, -1)) {
|
||||
if (LuaWrapper::getField(L, -1, "model") != LUA_TSTRING) {
|
||||
lua_pop(L, 1);
|
||||
luaL_argerror(L, idx, "'model' is not string or is missing");
|
||||
}
|
||||
const char* prefab_path = LuaWrapper::toType<const char*>(L, -1);
|
||||
Model* res = rm.load<Model>(Path(prefab_path));
|
||||
lua_pop(L, 1);
|
||||
lua_getfield(L, -1, "distances");
|
||||
if (!LuaWrapper::isType<Vec4>(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
res->decRefCount();
|
||||
luaL_argerror(L, idx, "'distances' is not vec4 or is missing");
|
||||
}
|
||||
const Vec4 distances = LuaWrapper::toType<Vec4>(L, -1);
|
||||
lua_pop(L, 1);
|
||||
if (distances.x > distances.w) {
|
||||
res->decRefCount();
|
||||
luaL_argerror(L, idx, "'distances' are not sorted");
|
||||
}
|
||||
|
||||
Vec2 scale = Vec2(1, 1);
|
||||
LuaWrapper::getOptionalField(L, -1, "scale", &scale);
|
||||
Vec2 y_offset = Vec2(0, 0);
|
||||
LuaWrapper::getOptionalField(L, -1, "y_offset", &y_offset);
|
||||
|
||||
ModelProbability& prob = prefabs.emplace();
|
||||
LuaWrapper::getOptionalField(L, -1, "multiplier", &prob.multiplier);
|
||||
prob.resource = res;
|
||||
prob.distances = distances;
|
||||
prob.scale = scale;
|
||||
prob.y_offset = y_offset;
|
||||
}
|
||||
else {
|
||||
lua_pop(L, 1);
|
||||
luaL_argerror(L, idx, "table of models expected");
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static u32 getRandomItem(float distance, const Array<T>& probs) {
|
||||
float sum = 0;
|
||||
|
||||
auto get = [](float distance, const T& prob){
|
||||
if (distance < prob.distances.x) return 0.f;
|
||||
if (distance > prob.distances.w) return 0.f;
|
||||
|
||||
if (distance < prob.distances.y) {
|
||||
return prob.multiplier * (distance - prob.distances.x) / (prob.distances.y - prob.distances.x);
|
||||
}
|
||||
else if (distance < prob.distances.z) {
|
||||
return prob.multiplier;
|
||||
}
|
||||
return prob.multiplier * (1 - (distance - prob.distances.z) / (prob.distances.w - prob.distances.z));
|
||||
};
|
||||
|
||||
for (const T& prob : probs) {
|
||||
sum += get(distance, prob);
|
||||
}
|
||||
if (sum == 0) return 0xffFFffFF;
|
||||
|
||||
float r = randFloat() * sum;
|
||||
|
||||
for (i32 i = 0; i < probs.size(); ++i) {
|
||||
const T& prob = probs[i];
|
||||
float p = get(distance, prob);
|
||||
if (r < p) return i;
|
||||
r -= p;
|
||||
}
|
||||
|
||||
ASSERT(false);
|
||||
return 0xffFFffFF;
|
||||
}
|
||||
|
||||
|
||||
void TerrainEditor::increaseBrushSize()
|
||||
{
|
||||
if (m_terrain_brush_size < 10)
|
||||
|
|
|
@ -336,7 +336,6 @@ int import(lua_State* L)
|
|||
{
|
||||
const char* path = LuaWrapper::checkArg<const char*>(L, 1);
|
||||
Shader* shader = getShader(L);
|
||||
FileSystem& fs = shader->m_renderer.getEngine().getFileSystem();
|
||||
|
||||
OutputMemoryStream content(shader->m_allocator);
|
||||
ResourceManagerHub& rm = shader->getResourceManager().getOwner();
|
||||
|
@ -359,7 +358,6 @@ int include(lua_State* L)
|
|||
|
||||
Shader* shader = getShader(L);
|
||||
|
||||
FileSystem& fs = shader->m_renderer.getEngine().getFileSystem();
|
||||
ResourceManagerHub& rm = shader->getResourceManager().getOwner();
|
||||
|
||||
OutputMemoryStream content(shader->m_allocator);
|
||||
|
|
Loading…
Reference in a new issue