Merge branch 'master' of https://gitee.com/lveyou/dl
This commit is contained in:
@@ -45,14 +45,6 @@ public:
|
||||
for (; i < N; ++i)
|
||||
_data[i] = {};
|
||||
}
|
||||
constexpr Array<T, N>& operator=(const std::array<T, N>& b)
|
||||
{
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
{
|
||||
_data[i] = b[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
constexpr T& operator[](size_t i)
|
||||
{
|
||||
assert(i < N);
|
||||
@@ -116,14 +108,6 @@ public:
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
_data[i] = i < N_LIST ? *(data.begin() + i) : T{};
|
||||
}
|
||||
constexpr Array<T, 2>& operator=(const std::array<T, 2>& b)
|
||||
{
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
_data[i] = b[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
constexpr const T& Get(size_t i) const
|
||||
{
|
||||
assert(i < 2);
|
||||
@@ -192,14 +176,6 @@ public:
|
||||
size_t N_LIST = std::size(data);
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
_data[i] = i < N_LIST ? *(data.begin() + i) : T{};
|
||||
}
|
||||
constexpr Array<T, 3>& operator=(const std::array<T, 3>& b)
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
{
|
||||
_data[i] = b[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
constexpr const T& Get(size_t i) const
|
||||
{
|
||||
@@ -286,14 +262,6 @@ public:
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
_data[i] = i < N_LIST ? *(data.begin() + i) : T{};
|
||||
}
|
||||
constexpr Array<T, 4>& operator=(const std::array<T, 4>& b)
|
||||
{
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
{
|
||||
_data[i] = b[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
constexpr const T& Get(size_t i) const
|
||||
{
|
||||
assert(i < 4);
|
||||
@@ -350,10 +318,6 @@ public:
|
||||
constexpr Array(std::initializer_list<T> data)
|
||||
{
|
||||
}
|
||||
constexpr Array<T, 0>& operator=(const std::array<T, 0>& b)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
constexpr T& operator[](size_t i)
|
||||
{
|
||||
return *begin();
|
||||
|
||||
@@ -30,6 +30,16 @@ constexpr Array<T1, N> toArray(const Array<T, N>& a)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
constexpr Array<T, N> toArray(const std::array<T, N>& a)
|
||||
{
|
||||
Array<T, N> ret;
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
{
|
||||
ret[i] = a[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* @brief 转换到Position,已知长度
|
||||
*/
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace dl
|
||||
_radin[0] = Math::Angle2Radin(_config.node.angle[0]);
|
||||
_radin[1] = Math::Angle2Radin(_config.node.angle[1]);
|
||||
|
||||
_gravity = _config.system.gravity;
|
||||
_gravity = toArray(_config.system.gravity);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -73,8 +73,9 @@ class Sprite
|
||||
public:
|
||||
enum class Sampler
|
||||
{
|
||||
NORMAL,
|
||||
PIXEL
|
||||
NORMAL, // 线性采样(写实画风使用)
|
||||
PIXEL, // 点采样(像素风使用)
|
||||
UI, // 线性采样、无mipmap
|
||||
};
|
||||
enum class Blend
|
||||
{
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace dl::UI
|
||||
|
||||
_ui._spr->SetUI(true);
|
||||
_ui._spr->SetCoor(_coor);
|
||||
|
||||
_cptElemData._size = _ui._spr->GetSize();
|
||||
}
|
||||
|
||||
void Background::Set(Sprite9* spr9)
|
||||
@@ -69,6 +71,8 @@ namespace dl::UI
|
||||
|
||||
_ui._spr9->SetUI(true);
|
||||
_ui._spr9->GetCoor()->SetParent(_coor);
|
||||
|
||||
_cptElemData._size = toPosition(_ui._spr9->GetSize());
|
||||
}
|
||||
|
||||
void Background::Clear()
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
/**
|
||||
* @brief 精灵组成的按钮
|
||||
* @param[in] mul_spr 多个精灵,浅拷贝
|
||||
* @note 最多五个精灵,普通、经过、按下、禁用(普通)、禁用(按下)
|
||||
* @note 最多6个精灵,普通、经过、按下、禁用(普通)、经过(按下)、禁用(按下)
|
||||
* 最少3个,缺少的禁用状态叠加灰度,4个时用一样的禁用状态。
|
||||
* 可以额外拥有文本
|
||||
*/
|
||||
|
||||
+26
-1
@@ -173,7 +173,7 @@ void Panel::Update()
|
||||
if (_bNeedRefreshPos)
|
||||
{
|
||||
_bNeedRefreshPos = false;
|
||||
_refresh_pos(GetParent()->GetSize());
|
||||
_refresh_pos(GetParentSize());
|
||||
}
|
||||
|
||||
// 后优先级组件
|
||||
@@ -294,6 +294,9 @@ void Panel::_render_child()
|
||||
|
||||
void Panel::_refresh_size()
|
||||
{
|
||||
if(_align != Align::LT)
|
||||
_bNeedRefreshPos = true; // 修改大小会影响自己的对齐,即Align
|
||||
|
||||
if (_bSizeFull)
|
||||
{
|
||||
// 父节点大小
|
||||
@@ -634,6 +637,28 @@ RectF Panel::GetRect()
|
||||
return ret;
|
||||
}
|
||||
|
||||
dl::Position Panel::GetParentSize()
|
||||
{
|
||||
auto parent = GetParent();
|
||||
if (parent && parent->GetSize()!= Position{})
|
||||
{
|
||||
return parent->GetSize();
|
||||
}
|
||||
|
||||
return toPosition(g_system->GetWindowSize()) / g_ui->GetScale();
|
||||
}
|
||||
|
||||
dl::Position Panel::GetSize()
|
||||
{
|
||||
if (_bSizeAuto)
|
||||
return _locator.GetSize();
|
||||
if (_size == Position{})
|
||||
{
|
||||
return GetParentSize();
|
||||
}
|
||||
return _size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+10
-8
@@ -501,13 +501,15 @@ public:
|
||||
|
||||
/**
|
||||
* @brief 返回大小
|
||||
* @note 自动大小则使用定位器自动大小
|
||||
* 若坐标为0,则使用父节点大小,直到窗口大小
|
||||
*/
|
||||
Position GetSize()
|
||||
{
|
||||
if (_bSizeAuto)
|
||||
return _locator.GetSize();
|
||||
return _size;
|
||||
}
|
||||
Position GetSize();
|
||||
/**
|
||||
* @brief 返回父节点大小
|
||||
* @note 父节点不存在或为0时,返回窗口大小
|
||||
*/
|
||||
Position GetParentSize();
|
||||
/**
|
||||
* @brief 返回所有元素和子节点组成的包围盒
|
||||
*/
|
||||
@@ -710,14 +712,14 @@ private:
|
||||
NTree<Panel*>::Node* _node;
|
||||
|
||||
// location
|
||||
Align::Direction2 _align; // 在父节点的对齐
|
||||
Align::Direction2 _align; // 自己大小对齐
|
||||
Position _posPixel;
|
||||
Position _posScale;
|
||||
|
||||
// locator
|
||||
Locator _locator;
|
||||
|
||||
Position _size; // 指定大小
|
||||
Position _size; // 指定大小(0表示跟随父节点大小)
|
||||
bool _bSizeFull;// 与父节点同大小
|
||||
bool _bSizeAuto; // 自动大小
|
||||
|
||||
|
||||
+32
-14
@@ -3726,25 +3726,26 @@ void VK::_create_2d()
|
||||
// 3.纹理采样器
|
||||
VkSamplerCreateInfo samplerInfo{};
|
||||
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||
samplerInfo.magFilter = VK_FILTER_NEAREST;// VK_FILTER_LINEAR;
|
||||
samplerInfo.minFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.anisotropyEnable = VK_TRUE;
|
||||
|
||||
VkPhysicalDeviceProperties properties{};
|
||||
vkGetPhysicalDeviceProperties(_physicalDevice, &properties);
|
||||
//VkPhysicalDeviceProperties properties{};
|
||||
//vkGetPhysicalDeviceProperties(_physicalDevice, &properties);
|
||||
|
||||
if (true)
|
||||
{
|
||||
samplerInfo.maxAnisotropy = properties.limits.maxSamplerAnisotropy;
|
||||
}
|
||||
else
|
||||
{
|
||||
samplerInfo.anisotropyEnable = VK_FALSE;
|
||||
samplerInfo.maxAnisotropy = 1.0f;
|
||||
}
|
||||
//// 2d不应该开启各向异性采样
|
||||
//if (false)
|
||||
//{
|
||||
// samplerInfo.maxAnisotropy = properties.limits.maxSamplerAnisotropy;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
samplerInfo.anisotropyEnable = VK_FALSE;
|
||||
samplerInfo.maxAnisotropy = 1.0f;
|
||||
//}
|
||||
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||
samplerInfo.unnormalizedCoordinates = VK_FALSE;
|
||||
samplerInfo.compareEnable = VK_FALSE;
|
||||
@@ -3756,7 +3757,22 @@ void VK::_create_2d()
|
||||
|
||||
if (vkCreateSampler(_device, &samplerInfo, nullptr, &_2d._textureSampler) != VK_SUCCESS)
|
||||
{
|
||||
log_damage0("创建纹理采样器失败!");
|
||||
log_damage0("创建2d纹理采样器失败!");
|
||||
return;
|
||||
}
|
||||
samplerInfo.magFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.minFilter = VK_FILTER_NEAREST;
|
||||
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
||||
if (vkCreateSampler(_device, &samplerInfo, nullptr, &_2d._textureSamplerPixel) != VK_SUCCESS)
|
||||
{
|
||||
log_damage0("创建2d纹理采样器(pixel)失败!");
|
||||
return;
|
||||
}
|
||||
// 关闭mipmap
|
||||
samplerInfo.maxLod = 0;
|
||||
if (vkCreateSampler(_device, &samplerInfo, nullptr, &_2d._textureSamplerUI) != VK_SUCCESS)
|
||||
{
|
||||
log_damage0("创建2d纹理采样器(ui)失败!");
|
||||
return;
|
||||
}
|
||||
//3.5 索引缓冲
|
||||
@@ -3849,6 +3865,8 @@ void VK::_delete_2d()
|
||||
}
|
||||
|
||||
vkDestroySampler(_device, _2d._textureSampler, nullptr);
|
||||
vkDestroySampler(_device, _2d._textureSamplerPixel, nullptr);
|
||||
vkDestroySampler(_device, _2d._textureSamplerUI, nullptr);
|
||||
for (auto& iter : _2d._allCanvas)
|
||||
{
|
||||
iter.second->Delete(_device);
|
||||
|
||||
+3
-1
@@ -414,7 +414,9 @@ public:
|
||||
std::vector<VkDescriptorSet> _descriptorSets; // 所有描述符集
|
||||
VkBuffer _indexBuffer; // 索引缓冲(注意是32位)
|
||||
VkDeviceMemory _indexBufferMemory; // 索引缓冲内存
|
||||
VkSampler _textureSampler; // 纹理采样器
|
||||
VkSampler _textureSampler; // 2d纹理采样器
|
||||
VkSampler _textureSamplerPixel; // 2d纹理采样器
|
||||
VkSampler _textureSamplerUI; // 2d纹理采样器
|
||||
std::array<CBO, NUM_MAX_ROOT_COOR> _allCBO; // 常量缓冲
|
||||
size_t _curPushConstant; // 当前使用 常量缓冲 下标
|
||||
std::array<Coor*, NUM_MAX_ROOT_COOR> _allRootCoor; // 所有根坐标系
|
||||
|
||||
@@ -12,7 +12,7 @@ endif()
|
||||
if (NOT DEFINED USE_CONSOLE)
|
||||
set(USE_CONSOLE true)
|
||||
endif()
|
||||
if(NOT DEFINED USE_CRASH_RPT)
|
||||
if(WIN32 AND (NOT DEFINED USE_CRASH_RPT))
|
||||
set(USE_CRASH_RPT true)
|
||||
endif()
|
||||
if(USE_CRASH_RPT)
|
||||
|
||||
Reference in New Issue
Block a user