trying to fix tilempas, kind working
This commit is contained in:
parent
e03729b42b
commit
b80d730ef3
32
imgui.ini
32
imgui.ini
@ -10,24 +10,24 @@ Collapsed=1
|
||||
|
||||
[Window][WindowOverViewport_11111111]
|
||||
Pos=0,19
|
||||
Size=1280,701
|
||||
Size=1920,1158
|
||||
Collapsed=0
|
||||
|
||||
[Window][Inspector]
|
||||
Pos=913,19
|
||||
Size=367,202
|
||||
Pos=1553,19
|
||||
Size=367,659
|
||||
Collapsed=0
|
||||
DockId=0x00000018,0
|
||||
|
||||
[Window][Scene Tree]
|
||||
Pos=0,19
|
||||
Size=342,356
|
||||
Size=342,589
|
||||
Collapsed=0
|
||||
DockId=0x0000000F,0
|
||||
|
||||
[Window][Viewport]
|
||||
Pos=344,19
|
||||
Size=567,202
|
||||
Size=1207,659
|
||||
Collapsed=0
|
||||
DockId=0x00000017,0
|
||||
|
||||
@ -36,14 +36,14 @@ Size=1280,19
|
||||
Collapsed=0
|
||||
|
||||
[Window][Performance Info]
|
||||
Pos=1094,223
|
||||
Size=186,497
|
||||
Pos=1606,680
|
||||
Size=314,497
|
||||
Collapsed=0
|
||||
DockId=0x00000016,0
|
||||
|
||||
[Window][Console]
|
||||
Pos=344,223
|
||||
Size=715,203
|
||||
Pos=344,680
|
||||
Size=1206,203
|
||||
Collapsed=0
|
||||
DockId=0x00000013,0
|
||||
|
||||
@ -54,8 +54,8 @@ Collapsed=0
|
||||
DockId=0x00000017,1
|
||||
|
||||
[Window][Profiler]
|
||||
Pos=344,428
|
||||
Size=715,292
|
||||
Pos=344,885
|
||||
Size=1206,292
|
||||
Collapsed=0
|
||||
DockId=0x00000014,0
|
||||
|
||||
@ -112,8 +112,8 @@ Collapsed=0
|
||||
DockId=0x0000000E,0
|
||||
|
||||
[Window][Audio Output]
|
||||
Pos=1061,223
|
||||
Size=31,497
|
||||
Pos=1552,680
|
||||
Size=52,497
|
||||
Collapsed=0
|
||||
DockId=0x00000012,0
|
||||
|
||||
@ -124,13 +124,13 @@ Collapsed=0
|
||||
DockId=0x0000000D,0
|
||||
|
||||
[Window][Resources]
|
||||
Pos=0,377
|
||||
Size=342,343
|
||||
Pos=0,610
|
||||
Size=342,567
|
||||
Collapsed=0
|
||||
DockId=0x00000010,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0x11111111 Window=0x1BBC0F80 Pos=0,19 Size=1280,701 Split=X
|
||||
DockSpace ID=0x11111111 Window=0x1BBC0F80 Pos=0,19 Size=1920,1158 Split=X
|
||||
DockNode ID=0x00000005 Parent=0x11111111 SizeRef=989,1158 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=342,701 Split=Y Selected=0x12EF0F59
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=342,637 Split=Y Selected=0x12EF0F59
|
||||
|
@ -1,2 +1,3 @@
|
||||
[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d -Isrc/vendor/xxhash -Isrc/vendor/miniaudio -IC:/msys64/mingw64/include -Isrc\vendor\imgui -IC:\msys64\mingw64\lib\libyaml-cpp.a -MMD -MP -c src\src\Renderer.cpp -o src\build\Renderer.o
|
||||
[COMPILE] g++ -std=c++20 -Wall -g -Isrc/include -Isrc/include/lua -Isrc/vendor -Isrc/vendor/imgui -Isrc/vendor/box2d -Isrc/vendor/xxhash -Isrc/vendor/miniaudio -IC:/msys64/mingw64/include -Isrc\vendor\imgui -IC:\msys64\mingw64\lib\libyaml-cpp.a -MMD -MP -c src\src\Engine.cpp -o src\build\Engine.o
|
||||
[LINK] g++ src\build\Engine.o src\build\main.o src\build\Renderer.o src\build\Components\AnimationComponent.o src\build\Components\AudioPlayerComponent.o src\build\Components\CameraComponent.o src\build\Components\LightComponent.o src\build\Components\ParticleComponent.o src\build\Components\PhysicsComponent.o src\build\Components\ScriptComponent.o src\build\Components\SpriteComponent.o src\build\Components\TextComonent.o src\build\Components\TilemapComponent.o src\build\core\audio\AudioEngine.o src\build\core\utils\AssetManager.o src\build\core\utils\EngineConfig.o src\build\core\utils\ExceptionHandler.o src\build\core\utils\FileDialog.o src\build\core\utils\input.o src\build\core\utils\LoadingWindow.o src\build\core\utils\Logging.o src\build\core\utils\Profiler.o src\build\core\utils\Texture.o src\build\core\utils\utils.o src\build\editor\windows\AssetBrowser.o src\build\editor\windows\AudioInfo.o src\build\editor\windows\Inspector.o src\build\Entitys\Object.o src\build\utils\GameObjectsList.o src\build\utils\Shader.o src\build\utils\UID.o src\build\lapi.o src\build\lauxlib.o src\build\lbaselib.o src\build\lcode.o src\build\lcorolib.o src\build\lctype.o src\build\ldblib.o src\build\ldebug.o src\build\ldo.o src\build\ldump.o src\build\lfunc.o src\build\lgc.o src\build\linit.o src\build\liolib.o src\build\llex.o src\build\lmathlib.o src\build\lmem.o src\build\loadlib.o src\build\lobject.o src\build\lopcodes.o src\build\loslib.o src\build\lparser.o src\build\lstate.o src\build\lstring.o src\build\lstrlib.o src\build\ltable.o src\build\ltablib.o src\build\ltm.o src\build\lua.o src\build\luac.o src\build\lundump.o src\build\lutf8lib.o src\build\lvm.o src\build\lzio.o src\build\imgui.o src\build\imgui_demo.o src\build\imgui_draw.o src\build\imgui_impl_glfw.o src\build\imgui_impl_opengl3.o src\build\imgui_tables.o src\build\imgui_widgets.o src\build\aabb.o src\build\arena_allocator.o src\build\array.o src\build\bitset.o src\build\body.o src\build\broad_phase.o src\build\constraint_graph.o src\build\contact.o src\build\contact_solver.o src\build\core.o src\build\distance.o src\build\distance_joint.o src\build\dynamic_tree.o src\build\geometry.o src\build\hull.o src\build\id_pool.o src\build\island.o src\build\joint.o src\build\manifold.o src\build\math_functions.o src\build\motor_joint.o src\build\mouse_joint.o src\build\mover.o src\build\prismatic_joint.o src\build\revolute_joint.o src\build\sensor.o src\build\shape.o src\build\solver.o src\build\solver_set.o src\build\table.o src\build\timer.o src\build\types.o src\build\weld_joint.o src\build\wheel_joint.o src\build\world.o src\build\xxhash.o src\build\miniaudio.o -o src\build\app.exe -LC:\msys64\mingw64\lib -lglfw3 -lglew32 -lopengl32 -lgdi32 -lyaml-cpp -lcomdlg32 -lssl -lcrypto -ldbghelp
|
||||
[RUN] Executed app.exe successfully.
|
||||
|
@ -1,11 +1,11 @@
|
||||
engine_version: 0.1.0
|
||||
scene_name: TilemapTest
|
||||
scene_hash: 7d49ebf46bff80d1f399d038f7cf65407940195676c52867fa427bc243f9614d
|
||||
scene_hash: 2be70327aa4c92915838833fd519fdf4ee39fc83f5fd744e89ef8b0eccc4e29c
|
||||
format_version: 1
|
||||
objects:
|
||||
- name: Hello, Create
|
||||
uid: b6da0e9b788248759d630d5599fdf8df
|
||||
id: 0
|
||||
uid: 59eb7ea5a5f4448a8546571c877bc583
|
||||
id: 1
|
||||
position: [0, 0]
|
||||
rotation: 0
|
||||
layer: 0
|
||||
@ -19,38 +19,42 @@ objects:
|
||||
x: 32
|
||||
y: 32
|
||||
Tiles:
|
||||
- [3, 4, 158]
|
||||
- [4, 3, 127]
|
||||
- [3, 3, 126]
|
||||
- [4, 2, 95]
|
||||
- [3, 2, 94]
|
||||
- [4, 1, 63]
|
||||
- [3, 1, 62]
|
||||
- [4, 0, 31]
|
||||
- [4, 4, 159]
|
||||
- [3, 0, 30]
|
||||
children: []
|
||||
- name: NewObject
|
||||
uid: 248c6524f6b447cca4a249eb85500d59
|
||||
id: 1
|
||||
position: [0, 0]
|
||||
rotation: 0
|
||||
layer: 0
|
||||
visable: true
|
||||
components:
|
||||
- type: AnimationComponent
|
||||
TextureUAID: 2
|
||||
TexelWidth: 64
|
||||
TexelHeight: 64
|
||||
FrameDuration: 0.0500000007
|
||||
StartFrame: 0
|
||||
EndFrame: 56
|
||||
- [8, 18, 159]
|
||||
- [3, 14, 62]
|
||||
- [-2, 12, 30]
|
||||
- [3, 13, 30]
|
||||
- [-2, 16, 158]
|
||||
- [-1, 15, 127]
|
||||
- [4, 17, 159]
|
||||
- [-2, 15, 126]
|
||||
- [3, 17, 158]
|
||||
- [-1, 14, 95]
|
||||
- [4, 16, 127]
|
||||
- [-2, 14, 94]
|
||||
- [3, 16, 126]
|
||||
- [-1, 13, 63]
|
||||
- [4, 15, 95]
|
||||
- [-2, 13, 62]
|
||||
- [3, 15, 94]
|
||||
- [-1, 12, 31]
|
||||
- [4, 14, 63]
|
||||
- [4, 13, 31]
|
||||
- [-1, 16, 159]
|
||||
- [7, 14, 30]
|
||||
- [8, 14, 31]
|
||||
- [7, 15, 62]
|
||||
- [8, 15, 63]
|
||||
- [7, 16, 94]
|
||||
- [8, 16, 95]
|
||||
- [7, 17, 126]
|
||||
- [8, 17, 127]
|
||||
- [7, 18, 158]
|
||||
children: []
|
||||
color_correction:
|
||||
brightness: 1
|
||||
saturation: 1
|
||||
gamma: 1
|
||||
bloom: true
|
||||
bloom: false
|
||||
intensity: 1.20000005
|
||||
threshold: 1
|
||||
Assets:
|
||||
@ -59,28 +63,8 @@ Assets:
|
||||
filename: 6656e7221e49a1774d2fb280357e56f8d25d9d95.png
|
||||
filetype: png
|
||||
type: 0
|
||||
size: [1024, 1024]
|
||||
hash: e8aaee6025f21557
|
||||
channels: 4
|
||||
format: GL_RGBA
|
||||
lastModified: 1744577923
|
||||
- uaid: 2
|
||||
path: C:\Users\spenc\OneDrive\Pictures\Pixel Holy Spell Effect 32x32 Pack 3\00.png
|
||||
filename: 00.png
|
||||
filetype: png
|
||||
type: 0
|
||||
size: [1216, 192]
|
||||
hash: 2b0b3c20179d6f12
|
||||
size: [1024, 1024]
|
||||
channels: 4
|
||||
format: GL_RGBA
|
||||
lastModified: 1687052065
|
||||
- uaid: 3
|
||||
path: C:\Users\spenc\OneDrive\Pictures\Pixel Holy Spell Effect 32x32 Pack 3\01.png
|
||||
filename: 01.png
|
||||
filetype: png
|
||||
type: 0
|
||||
size: [704, 576]
|
||||
hash: 82866fcf3324b785
|
||||
channels: 4
|
||||
format: GL_RGBA
|
||||
lastModified: 1687052107
|
@ -480,70 +480,79 @@ void Renderer::AddLight(const glm::vec2 &screenPos, const glm::vec3 &color, floa
|
||||
s_LightsCount++;
|
||||
}
|
||||
|
||||
void Renderer::DrawTilemap(TilemapComponent *tilemap,
|
||||
const glm::vec2 & /*pos*/,
|
||||
|
||||
|
||||
|
||||
void Renderer::DrawTilemap(TilemapComponent* tilemap,
|
||||
const glm::vec2& ,
|
||||
float zoom,
|
||||
const glm::vec2 &cameraPos)
|
||||
const glm::vec2& cameraPos)
|
||||
{
|
||||
PROFILE_DEEP_SCOPE("Renderer::DrawTilemap");
|
||||
if (!tilemap)
|
||||
return;
|
||||
if (!tilemap) return;
|
||||
|
||||
// grab atlas + texture
|
||||
TextureAtlas *atlas = tilemap->GetAtlas();
|
||||
if (!atlas || !atlas->texture)
|
||||
return;
|
||||
TextureAtlas* atlas = tilemap->GetAtlas();
|
||||
auto texture = atlas->texture;
|
||||
if (!texture) return;
|
||||
|
||||
// world-space size of one cell
|
||||
const auto &tileSize = tilemap->GetTileSize();
|
||||
glm::vec2 screenCenter{width * 0.5f, height * 0.5f};
|
||||
// world-space size of one tile, and center of the screen
|
||||
glm::vec2 tileSize = tilemap->GetTileSize();
|
||||
glm::vec2 halfScreen{ width * 0.5f, height * 0.5f };
|
||||
|
||||
// draw every cell
|
||||
for (auto [key, tileIndex] : tilemap->GetTileData())
|
||||
for (auto& [key, idx] : tilemap->GetTileData())
|
||||
{
|
||||
// skip bad indices
|
||||
if (tileIndex < 0 || tileIndex >= atlas->GetTotalFrames())
|
||||
if (idx < 0 || idx >= atlas->GetTotalFrames())
|
||||
continue;
|
||||
|
||||
// decode grid coords
|
||||
int gx, gy;
|
||||
TilemapComponent::UnpackCoord(key, gx, gy);
|
||||
|
||||
|
||||
// world→screen position
|
||||
glm::vec2 worldPos = {gx * tileSize.x, gy * tileSize.y};
|
||||
glm::vec2 screenPos = (worldPos - cameraPos) * zoom + screenCenter;
|
||||
|
||||
// quad size in screen‐space
|
||||
glm::vec2 worldPos{ gx * tileSize.x, gy * tileSize.y };
|
||||
glm::vec2 screenPos = (worldPos - cameraPos) * zoom + halfScreen;
|
||||
glm::vec2 finalSize = tileSize * zoom;
|
||||
|
||||
if (screenPos.x + finalSize.x < 0.0f || screenPos.x > width ||
|
||||
screenPos.y + finalSize.y < 0.0f || screenPos.y > height)
|
||||
continue;
|
||||
|
||||
const core::types::Vec2 uvMin = atlas->GetFrameUV(tileIndex);
|
||||
const core::types::Vec2 uvMax = uvMin + atlas->GetFrameSizeUV();
|
||||
core::types::Vec2 frameUV = atlas->GetFrameUV(idx);
|
||||
core::types::Vec2 frameSize = atlas->GetFrameSizeUV();
|
||||
|
||||
// batch that sprite
|
||||
BatchedSprite entry{};
|
||||
entry.screenPos = screenPos;
|
||||
entry.size = finalSize;
|
||||
entry.rotationRad = 0.0f;
|
||||
entry.textureID = atlas->texture->GetID();
|
||||
entry.normalMapID = defaultNormalMap;
|
||||
entry.renderType = RenderType::Unlit;
|
||||
entry.sprite = nullptr;
|
||||
entry.texCoords = glm::vec4(
|
||||
uvMin.x, uvMin.y,
|
||||
uvMax.x, uvMax.y);
|
||||
float u0 = frameUV.x;
|
||||
float v0 = frameUV.y;
|
||||
float u1 = u0 + frameSize.x;
|
||||
float v1 = v0 + frameSize.y;
|
||||
|
||||
SortedDrawEntry drawEntry{};
|
||||
drawEntry.sprite = entry;
|
||||
drawEntry.shader = &unlitShader;
|
||||
drawEntry.useLighting = false;
|
||||
drawEntry.usesUV = true;
|
||||
v0 = 1.0f - v0;
|
||||
v1 = 1.0f - v1;
|
||||
|
||||
sortedDrawList.push_back(drawEntry);
|
||||
glm::vec2 uvBL{ u0, v1 };
|
||||
glm::vec2 uvTR{ u1, v0 };
|
||||
|
||||
// Bake into your batched sprite
|
||||
BatchedSprite sprite{};
|
||||
sprite.screenPos = screenPos;
|
||||
sprite.size = finalSize;
|
||||
sprite.rotationRad = 0.0f;
|
||||
sprite.textureID = texture->GetID();
|
||||
sprite.normalMapID = defaultNormalMap;
|
||||
sprite.renderType = RenderType::Unlit;
|
||||
sprite.texCoords = glm::vec4(
|
||||
uvBL.x, uvBL.y,
|
||||
uvTR.x, uvTR.y
|
||||
);
|
||||
|
||||
SortedDrawEntry entry{};
|
||||
entry.sprite = sprite;
|
||||
entry.shader = &unlitShader;
|
||||
entry.useLighting = false;
|
||||
entry.usesUV = true;
|
||||
|
||||
sortedDrawList.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Renderer::DrawQuad(const core::types::Vec2 &pos, const core::types::Vec2 &size, float rotation, const core::types::Color &color)
|
||||
{
|
||||
PROFILE_DEEP_SCOPE("Renderer::DrawQuad");
|
||||
|
Loading…
Reference in New Issue
Block a user