加入 SpriteRegion 与基础 Tilemap 绘制
DrawContext 现在支持从 atlas 子区域绘制 SpriteRegion,并在 draw_sprite_ex 中加入屏幕裁剪,避免边缘 sprite 逐像素依赖 FrameBuffer 越界保护。新增基础 Tilemap 数据结构和 draw_tilemap,按视口可见范围遍历 tile,并在视口边缘进行像素级裁剪,支持 camera 像素级滚动时显示半个 tile。 Demo 增加小型滚动 tilemap 测试,复用现有测试 sprite 作为单 tile atlas。文档同步记录 SpriteRegion、Tilemap、viewport 裁剪语义和后续优化方向。 Constraint: IMX6U 热路径应避免全地图扫描和运行时资源解码 Constraint: 当前 tilemap 先保持单 atlas、固定 tile 尺寸的简单模型 Rejected: 直接每帧遍历整张 tilemap | 大地图上会浪费 CPU Rejected: 立即引入复杂地图资源系统 | 当前阶段只需要验证绘制链路 Confidence: high Scope-risk: moderate Directive: 扩展 Tilemap 时保持 tile 范围遍历 + 像素级边缘裁剪的语义 Tested: cmake --build build-win --config Release Not-tested: 尚未在 IMX6U 真机上验证 framebuffer/SDL 后端性能
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "Image.h"
|
||||
|
||||
namespace RenderData
|
||||
{
|
||||
struct SpriteRegion
|
||||
{
|
||||
const Image* atlas;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
|
||||
SpriteRegion()
|
||||
: atlas(nullptr), x(0), y(0), width(0), height(0) {}
|
||||
|
||||
SpriteRegion(const Image* atlas, int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
: atlas(atlas), x(x), y(y), width(width), height(height) {}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user