refactors, removed min max macro usage
This commit is contained in:
@@ -21,20 +21,30 @@ The documentation completion is still pending....
|
||||
2. Music
|
||||
5. Vector
|
||||
6. Matrix
|
||||
7. Scene
|
||||
TODO
|
||||
8. MainComponent
|
||||
9. RenderPath
|
||||
1. RenderPath2D
|
||||
2. RenderPath3D
|
||||
1. RenderPath3D_Forward
|
||||
2. RenderPath3D_Deferred
|
||||
4. LoadingScreen
|
||||
10. Network
|
||||
7. Scene System (using entity-component system)
|
||||
1. Entity
|
||||
2. Scene
|
||||
3. NameComponent
|
||||
4. LayerComponent
|
||||
5. TransformComponent
|
||||
6. CameraComponent
|
||||
7. AnimationComponent
|
||||
8. MaterialComponent
|
||||
9. EmitterComponent
|
||||
10. LightComponent
|
||||
8. High Level Interface
|
||||
1. MainComponent
|
||||
2. RenderPath
|
||||
1. RenderPath2D
|
||||
2. RenderPath3D
|
||||
1. RenderPath3D_Forward
|
||||
2. RenderPath3D_Deferred
|
||||
3. LoadingScreen
|
||||
9. Network
|
||||
1. Server
|
||||
2. Client
|
||||
11. Input Handling
|
||||
12. ResourceManager
|
||||
10. Input Handling
|
||||
11. ResourceManager
|
||||
|
||||
## Introduction and usage
|
||||
Scripting in Wicked Engine is powered by Lua, meaning that the user can make use of the
|
||||
@@ -338,16 +348,18 @@ A four by four matrix, efficient calculations with SIMD support.
|
||||
Manipulate the 3D scene with these components.
|
||||
|
||||
#### Entity
|
||||
An entity is just an int value and works as a handle to retrieve associated components
|
||||
An entity is just an int value (int in LUA and uint32 in C++) and works as a handle to retrieve associated components
|
||||
|
||||
#### Scene
|
||||
- [outer]GetScene() : Scene result -- returns the current scene
|
||||
The scene holds components. Entity handles can be used to retrieve associated components through the scene.
|
||||
- [constructor]Scene() : Scene result -- creates a custom scene
|
||||
- [outer]GetScene() : Scene result -- returns the global scene
|
||||
- [outer]LoadModel(string fileName, opt Matrix transform) : int rootEntity -- Load Model from file. returns a root entity that everything in this model is attached to
|
||||
- [outer]LoadModel(Scene scene, string fileName, opt Matrix transform) : int rootEntity -- Load Model from file into specified scene. returns a root entity that everything in this model is attached to
|
||||
- [outer]Pick(Ray ray, opt PICKTYPE pickType, opt uint layerMask, opt Scene scene) : int entity, Vector position,normal, float distance -- Perform ray-picking in the scene. pickType is a bitmask specifying object types to check against. layerMask is a bitmask specifying which layers to check against. Scene parameter is optional and will use the global scene if not specified.
|
||||
- Update() -- updates the scene and every entity and component inside the scene
|
||||
- Clear() -- deletes every entity and component inside the scene
|
||||
- Merge() -- moves contents from an other scene into this one
|
||||
- Merge(Scene other) -- moves contents from an other scene into this one. The other scene will be empty after this operation (contents are moved, not copied)
|
||||
|
||||
- Entity_FindByName(string value) : int entity -- returns an entity ID if it exists, and 0 otherwise
|
||||
- Entity_Remove(Entity entity) -- removes an entity and deletes all its components if it exists
|
||||
|
||||
+1
-1
@@ -835,7 +835,7 @@ void EditorComponent::Update(float dt)
|
||||
else if (wiInputManager::down(VK_LCONTROL) || currentMouse.z != 0.0f)
|
||||
{
|
||||
cameraWnd->camera_transform.Translate(XMFLOAT3(0, 0, yDif * 4 + currentMouse.z));
|
||||
cameraWnd->camera_transform.translation_local.z = min(0, cameraWnd->camera_transform.translation_local.z);
|
||||
cameraWnd->camera_transform.translation_local.z = std::min(0.0f, cameraWnd->camera_transform.translation_local.z);
|
||||
camera.SetDirty();
|
||||
}
|
||||
else if(abs(xDif) + abs(yDif) > 0)
|
||||
|
||||
@@ -119,7 +119,7 @@ void RegisterTexture2D(tinygltf::Image *image, const string& type_name)
|
||||
{
|
||||
InitData[mip].pSysMem = image->image.data();
|
||||
InitData[mip].SysMemPitch = static_cast<UINT>(mipwidth * channelCount);
|
||||
mipwidth = max(1, mipwidth / 2);
|
||||
mipwidth = std::max(1u, mipwidth / 2);
|
||||
}
|
||||
|
||||
Texture2D* tex = new Texture2D;
|
||||
|
||||
@@ -1,22 +1,2 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
#include "WickedEngine.h"
|
||||
@@ -1,22 +1,2 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
#include <WickedEngine.h> // include wicked engine library
|
||||
|
||||
@@ -1,23 +1,3 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files:
|
||||
#include <windows.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
#include "WickedEngine.h"
|
||||
#include "Tests.h"
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
|
||||
// Platform specific:
|
||||
#define NOMINMAX
|
||||
#undef min
|
||||
#undef max
|
||||
#include <SDKDDKVer.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "wiGraphicsDevice_Vulkan.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace wiGraphics;
|
||||
@@ -120,7 +121,7 @@ void MainComponent::Run()
|
||||
wiProfiler::BeginFrame();
|
||||
wiProfiler::BeginRange("CPU Frame", wiProfiler::DOMAIN_CPU);
|
||||
|
||||
deltaTime = float(max(0, timer.elapsed() / 1000.0));
|
||||
deltaTime = float(std::max(0.0, timer.elapsed() / 1000.0));
|
||||
timer.record();
|
||||
|
||||
if (wiWindowRegistration::IsWindowActive())
|
||||
|
||||
@@ -11,7 +11,7 @@ struct VSOut {
|
||||
|
||||
VSOut main(uint vid : SV_VERTEXID)
|
||||
{
|
||||
VSOut Out = (VSOut)0;
|
||||
VSOut Out;
|
||||
Out.pos = Out.pos2D = mul(float4(ICOSPHERE[vid].xyz, 0), g_xCamera_VP);
|
||||
Out.nor=ICOSPHERE[vid].xyz;
|
||||
Out.pos2DPrev = mul(float4(ICOSPHERE[vid].xyz, 0), g_xFrame_MainCamera_PrevVP);
|
||||
|
||||
@@ -10,7 +10,7 @@ struct VSOut_Sphere
|
||||
|
||||
VSOut_Sphere main( uint vID : SV_VERTEXID )
|
||||
{
|
||||
VSOut_Sphere o = (VSOut_Sphere)0;
|
||||
VSOut_Sphere o;
|
||||
o.pos = UVSPHERE[vID];
|
||||
o.nor = o.pos.xyz;
|
||||
o.pos = mul(o.pos, g_xTransform);
|
||||
|
||||
@@ -2,18 +2,23 @@
|
||||
|
||||
PixelInputType main(Input_Object_POS_TEX input)
|
||||
{
|
||||
PixelInputType Out = (PixelInputType)0;
|
||||
PixelInputType Out;
|
||||
|
||||
float4x4 WORLD = MakeWorldMatrixFromInstance(input.inst);
|
||||
VertexSurface surface = MakeVertexSurfaceFromInput(input);
|
||||
|
||||
surface.position = mul(surface.position, WORLD);
|
||||
surface.normal = normalize(mul(surface.normal, (float3x3)WORLD));
|
||||
|
||||
Out.clip = 0;
|
||||
|
||||
Out.pos3D = surface.position.xyz;
|
||||
Out.pos = Out.pos2D = mul(surface.position, g_xCamera_VP);
|
||||
Out.pos2DPrev = Out.pos2D; // no need for water
|
||||
Out.pos3D = surface.position.xyz;
|
||||
Out.color = surface.color;
|
||||
Out.uvsets = surface.uvsets;
|
||||
Out.nor = normalize(mul(surface.normal, (float3x3)WORLD));
|
||||
Out.atl = 0;
|
||||
Out.nor = surface.normal;
|
||||
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_View).xy;
|
||||
|
||||
Out.ReflectionMapSamplingPos = mul(surface.position, g_xFrame_MainCamera_ReflVP);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "wiProfiler.h"
|
||||
#include "wiBackLog.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace wiGraphics;
|
||||
|
||||
@@ -230,7 +232,7 @@ void wiEmittedParticle::UpdateCPU(const TransformComponent& transform, float dt)
|
||||
if (IsPaused())
|
||||
return;
|
||||
|
||||
emit = max(0, emit - floorf(emit));
|
||||
emit = std::max(0.0f, emit - floorf(emit));
|
||||
|
||||
CreateSelfBuffers();
|
||||
|
||||
|
||||
@@ -539,7 +539,7 @@ void wiFont::Draw(GRAPHICSTHREAD threadID) const
|
||||
|
||||
int wiFont::textWidth() const
|
||||
{
|
||||
if (style >= fontStyles.size())
|
||||
if (style >= (int)fontStyles.size())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -573,14 +573,14 @@ int wiFont::textWidth() const
|
||||
const Glyph& glyph = glyph_lookup.at(hash);
|
||||
currentLineWidth += int((glyph.width + params.spacingX) * params.scaling);
|
||||
}
|
||||
maxWidth = max(maxWidth, currentLineWidth);
|
||||
maxWidth = std::max(maxWidth, currentLineWidth);
|
||||
}
|
||||
|
||||
return maxWidth;
|
||||
}
|
||||
int wiFont::textHeight() const
|
||||
{
|
||||
if (style >= fontStyles.size())
|
||||
if (style >= (int)fontStyles.size())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma comment(lib,"dxguid.lib")
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -1777,7 +1778,7 @@ HRESULT GraphicsDevice_DX11::CreateTexture2D(const TextureDesc* pDesc, const Sub
|
||||
D3D11_SUBRESOURCE_DATA* data = nullptr;
|
||||
if (pInitialData != nullptr)
|
||||
{
|
||||
UINT dataCount = pDesc->ArraySize * max(1, pDesc->MipLevels);
|
||||
UINT dataCount = pDesc->ArraySize * std::max(1u, pDesc->MipLevels);
|
||||
data = new D3D11_SUBRESOURCE_DATA[dataCount];
|
||||
for (UINT slice = 0; slice < dataCount; ++slice)
|
||||
{
|
||||
@@ -1795,7 +1796,7 @@ HRESULT GraphicsDevice_DX11::CreateTexture2D(const TextureDesc* pDesc, const Sub
|
||||
|
||||
if (pTexture2D->desc.MipLevels == 0)
|
||||
{
|
||||
pTexture2D->desc.MipLevels = (UINT)log2(max(pTexture2D->desc.Width, pTexture2D->desc.Height));
|
||||
pTexture2D->desc.MipLevels = (UINT)log2(std::max(pTexture2D->desc.Width, pTexture2D->desc.Height));
|
||||
}
|
||||
|
||||
CreateRenderTargetView(pTexture2D);
|
||||
@@ -1898,7 +1899,7 @@ HRESULT GraphicsDevice_DX11::CreateTexture3D(const TextureDesc* pDesc, const Sub
|
||||
|
||||
if (pTexture3D->desc.MipLevels == 0)
|
||||
{
|
||||
pTexture3D->desc.MipLevels = (UINT)log2(max(pTexture3D->desc.Width, max(pTexture3D->desc.Height, pTexture3D->desc.Depth)));
|
||||
pTexture3D->desc.MipLevels = (UINT)log2(std::max(pTexture3D->desc.Width, std::max(pTexture3D->desc.Height, pTexture3D->desc.Depth)));
|
||||
}
|
||||
|
||||
CreateShaderResourceView(pTexture3D);
|
||||
@@ -3227,7 +3228,7 @@ void GraphicsDevice_DX11::BindRenderTargets(UINT NumViews, const Texture2D* cons
|
||||
{
|
||||
// RTVs:
|
||||
ID3D11RenderTargetView* renderTargetViews[8] = {};
|
||||
for (UINT i = 0; i < min(NumViews, 8); ++i)
|
||||
for (UINT i = 0; i < std::min(NumViews, 8u); ++i)
|
||||
{
|
||||
if (arrayIndex < 0 || ppRenderTargets[i]->additionalRTVs.empty())
|
||||
{
|
||||
@@ -3400,8 +3401,8 @@ void GraphicsDevice_DX11::BindUAV(SHADERSTAGE stage, const GPUResource* resource
|
||||
else
|
||||
{
|
||||
raster_uavs[threadID][slot] = (ID3D11UnorderedAccessView*)resource->UAV;
|
||||
raster_uavs_slot[threadID] = min(raster_uavs_slot[threadID], slot);
|
||||
raster_uavs_count[threadID] = max(raster_uavs_count[threadID], 1);
|
||||
raster_uavs_slot[threadID] = std::min(raster_uavs_slot[threadID], uint8_t(slot));
|
||||
raster_uavs_count[threadID] = std::max(raster_uavs_count[threadID], uint8_t(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3425,8 +3426,8 @@ void GraphicsDevice_DX11::BindUAVs(SHADERSTAGE stage, const GPUResource *const*
|
||||
}
|
||||
else
|
||||
{
|
||||
raster_uavs_slot[threadID] = min(raster_uavs_slot[threadID], slot);
|
||||
raster_uavs_count[threadID] = max(raster_uavs_count[threadID], count);
|
||||
raster_uavs_slot[threadID] = std::min(raster_uavs_slot[threadID], uint8_t(slot));
|
||||
raster_uavs_count[threadID] = std::max(raster_uavs_count[threadID], uint8_t(count));
|
||||
}
|
||||
}
|
||||
void GraphicsDevice_DX11::UnbindResources(UINT slot, UINT num, GRAPHICSTHREAD threadID)
|
||||
@@ -3720,7 +3721,7 @@ void GraphicsDevice_DX11::UpdateBuffer(const GPUBuffer* buffer, const void* data
|
||||
return;
|
||||
}
|
||||
|
||||
dataSize = min((int)buffer->desc.ByteWidth, dataSize);
|
||||
dataSize = std::min((int)buffer->desc.ByteWidth, dataSize);
|
||||
|
||||
if (buffer->desc.Usage == USAGE_DYNAMIC)
|
||||
{
|
||||
@@ -3795,7 +3796,7 @@ bool GraphicsDevice_DX11::DownloadResource(const GPUResource* resourceToDownload
|
||||
bool result = SUCCEEDED(hr);
|
||||
if (result)
|
||||
{
|
||||
UINT cpycount = max(1, textureToDownload->desc.Width) * max(1, textureToDownload->desc.Height) * max(1, textureToDownload->desc.Depth);
|
||||
UINT cpycount = std::max(1u, textureToDownload->desc.Width) * std::max(1u, textureToDownload->desc.Height) * std::max(1u, textureToDownload->desc.Depth);
|
||||
UINT cpystride = GetFormatStride(textureToDownload->desc.Format);
|
||||
UINT cpysize = cpycount * cpystride;
|
||||
memcpy(dataDest, mappedResource.pData, cpysize);
|
||||
@@ -3866,7 +3867,7 @@ GraphicsDevice::GPUAllocation GraphicsDevice_DX11::AllocateGPU(size_t dataSize,
|
||||
allocator.dirty = true;
|
||||
|
||||
|
||||
dataSize = min(allocator.buffer.desc.ByteWidth, dataSize);
|
||||
dataSize = std::min(size_t(allocator.buffer.desc.ByteWidth), dataSize);
|
||||
|
||||
size_t position = allocator.byteOffset;
|
||||
bool wrap = position + dataSize > allocator.buffer.desc.ByteWidth || allocator.residentFrame != FRAMECOUNT;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#endif // _DEBUG
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <wincodec.h>
|
||||
|
||||
using namespace std;
|
||||
@@ -2327,14 +2328,14 @@ namespace wiGraphics
|
||||
|
||||
if (pTexture2D->desc.MipLevels == 0)
|
||||
{
|
||||
pTexture2D->desc.MipLevels = (UINT)log2(max(pTexture2D->desc.Width, pTexture2D->desc.Height));
|
||||
pTexture2D->desc.MipLevels = (UINT)log2(std::max(pTexture2D->desc.Width, pTexture2D->desc.Height));
|
||||
}
|
||||
|
||||
|
||||
// Issue data copy on request:
|
||||
if (pInitialData != nullptr)
|
||||
{
|
||||
UINT dataCount = pDesc->ArraySize * max(1, pDesc->MipLevels);
|
||||
UINT dataCount = pDesc->ArraySize * std::max(1u, pDesc->MipLevels);
|
||||
D3D12_SUBRESOURCE_DATA* data = new D3D12_SUBRESOURCE_DATA[dataCount];
|
||||
for (UINT slice = 0; slice < dataCount; ++slice)
|
||||
{
|
||||
@@ -3423,7 +3424,7 @@ namespace wiGraphics
|
||||
result = directQueue->Signal(frameFence, FRAMECOUNT);
|
||||
|
||||
// Determine the last frame that we should not wait on:
|
||||
const uint64_t lastFrameToAllowLatency = max(BACKBUFFER_COUNT - 1, FRAMECOUNT) - (BACKBUFFER_COUNT - 1);
|
||||
const uint64_t lastFrameToAllowLatency = std::max(uint64_t(BACKBUFFER_COUNT - 1u), FRAMECOUNT) - (BACKBUFFER_COUNT - 1);
|
||||
|
||||
// Wait if too many frames are being incomplete:
|
||||
if (frameFence->GetCompletedValue() < lastFrameToAllowLatency)
|
||||
@@ -3886,7 +3887,7 @@ namespace wiGraphics
|
||||
return;
|
||||
}
|
||||
|
||||
dataSize = min((int)buffer->desc.ByteWidth, dataSize);
|
||||
dataSize = std::min((int)buffer->desc.ByteWidth, dataSize);
|
||||
dataSize = (dataSize >= 0 ? dataSize : buffer->desc.ByteWidth);
|
||||
|
||||
size_t alignment = buffer->desc.BindFlags & BIND_CONSTANT_BUFFER ? D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#ifdef WICKEDENGINE_BUILD_VULKAN
|
||||
@@ -1985,8 +1986,8 @@ namespace wiGraphics
|
||||
VkPresentModeKHR presentMode = chooseSwapPresentMode(swapChainSupport.presentModes);
|
||||
|
||||
swapChainExtent = { static_cast<uint32_t>(SCREENWIDTH), static_cast<uint32_t>(SCREENHEIGHT) };
|
||||
swapChainExtent.width = max(swapChainSupport.capabilities.minImageExtent.width, min(swapChainSupport.capabilities.maxImageExtent.width, swapChainExtent.width));
|
||||
swapChainExtent.height = max(swapChainSupport.capabilities.minImageExtent.height, min(swapChainSupport.capabilities.maxImageExtent.height, swapChainExtent.height));
|
||||
swapChainExtent.width = std::max(swapChainSupport.capabilities.minImageExtent.width, std::min(swapChainSupport.capabilities.maxImageExtent.width, swapChainExtent.width));
|
||||
swapChainExtent.height = std::max(swapChainSupport.capabilities.minImageExtent.height, std::min(swapChainSupport.capabilities.maxImageExtent.height, swapChainExtent.height));
|
||||
|
||||
//uint32_t imageCount = swapChainSupport.capabilities.minImageCount + 1;
|
||||
//if (swapChainSupport.capabilities.maxImageCount > 0 && imageCount > swapChainSupport.capabilities.maxImageCount) {
|
||||
@@ -2662,7 +2663,7 @@ namespace wiGraphics
|
||||
|
||||
if (pTexture2D->desc.MipLevels == 0)
|
||||
{
|
||||
pTexture2D->desc.MipLevels = static_cast<UINT>(log2(max(pTexture2D->desc.Width, pTexture2D->desc.Height)));
|
||||
pTexture2D->desc.MipLevels = static_cast<UINT>(log2(std::max(pTexture2D->desc.Width, pTexture2D->desc.Height)));
|
||||
}
|
||||
|
||||
|
||||
@@ -2781,8 +2782,8 @@ namespace wiGraphics
|
||||
1
|
||||
};
|
||||
|
||||
width = max(1, width / 2);
|
||||
height /= max(1, height / 2);
|
||||
width = std::max(1u, width / 2);
|
||||
height /= std::max(1u, height / 2);
|
||||
|
||||
copyRegions.push_back(copyRegion);
|
||||
}
|
||||
@@ -4489,8 +4490,8 @@ namespace wiGraphics
|
||||
for(UINT i = 0; i < numRects; ++i) {
|
||||
scissors[i].extent.width = abs(rects[i].right - rects[i].left);
|
||||
scissors[i].extent.height = abs(rects[i].top - rects[i].bottom);
|
||||
scissors[i].offset.x = max(0, rects[i].left);
|
||||
scissors[i].offset.y = max(0, rects[i].top);
|
||||
scissors[i].offset.x = std::max(0l, rects[i].left);
|
||||
scissors[i].offset.y = std::max(0l, rects[i].top);
|
||||
}
|
||||
vkCmdSetScissor(GetDirectCommandList(threadID), 0, numRects, scissors);
|
||||
}
|
||||
@@ -5019,7 +5020,7 @@ namespace wiGraphics
|
||||
return;
|
||||
}
|
||||
|
||||
dataSize = min((int)buffer->desc.ByteWidth, dataSize);
|
||||
dataSize = std::min((int)buffer->desc.ByteWidth, dataSize);
|
||||
dataSize = (dataSize >= 0 ? dataSize : buffer->desc.ByteWidth);
|
||||
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ void wiHairParticle::UpdateGPU(const MeshComponent& mesh, const MaterialComponen
|
||||
hcb.xStiffness = stiffness;
|
||||
hcb.xHairRandomness = randomness;
|
||||
hcb.xHairStrandCount = strandCount;
|
||||
hcb.xHairSegmentCount = max(segmentCount, 1);
|
||||
hcb.xHairSegmentCount = std::max(segmentCount, 1u);
|
||||
hcb.xHairParticleCount = hcb.xHairStrandCount * hcb.xHairSegmentCount;
|
||||
hcb.xHairRandomSeed = randomSeed;
|
||||
hcb.xHairViewDistance = viewDistance;
|
||||
@@ -170,7 +170,7 @@ void wiHairParticle::Draw(const CameraComponent& camera, const MaterialComponent
|
||||
|
||||
device->BindResource(VS, particleBuffer.get(), 0, threadID);
|
||||
|
||||
device->Draw(strandCount * 12 * max(segmentCount, 1), 0, threadID);
|
||||
device->Draw(strandCount * 12 * std::max(segmentCount, 1u), 0, threadID);
|
||||
|
||||
device->EventEnd(threadID);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace wiInputManager
|
||||
}
|
||||
break;
|
||||
case INPUT_TYPE_GAMEPAD:
|
||||
if (playerindex < controllers.size())
|
||||
if (playerindex < (int)controllers.size())
|
||||
{
|
||||
|
||||
const Controller& controller = controllers[playerindex];
|
||||
|
||||
@@ -63,7 +63,7 @@ float AABB::getArea() const
|
||||
}
|
||||
float AABB::getRadius() const {
|
||||
XMFLOAT3& abc = getHalfWidth();
|
||||
return max(max(abc.x, abc.y), abc.z);
|
||||
return std::max(std::max(abc.x, abc.y), abc.z);
|
||||
}
|
||||
AABB::INTERSECTION_TYPE AABB::intersects(const AABB& b) const {
|
||||
|
||||
@@ -125,20 +125,20 @@ bool AABB::intersects(const RAY& ray) const {
|
||||
float tx1 = (MIN.x - ray.origin.x)*ray.direction_inverse.x;
|
||||
float tx2 = (MAX.x - ray.origin.x)*ray.direction_inverse.x;
|
||||
|
||||
float tmin = min(tx1, tx2);
|
||||
float tmax = max(tx1, tx2);
|
||||
float tmin = std::min(tx1, tx2);
|
||||
float tmax = std::max(tx1, tx2);
|
||||
|
||||
float ty1 = (MIN.y - ray.origin.y)*ray.direction_inverse.y;
|
||||
float ty2 = (MAX.y - ray.origin.y)*ray.direction_inverse.y;
|
||||
|
||||
tmin = max(tmin, min(ty1, ty2));
|
||||
tmax = min(tmax, max(ty1, ty2));
|
||||
tmin = std::max(tmin, std::min(ty1, ty2));
|
||||
tmax = std::min(tmax, std::max(ty1, ty2));
|
||||
|
||||
float tz1 = (MIN.z - ray.origin.z)*ray.direction_inverse.z;
|
||||
float tz2 = (MAX.z - ray.origin.z)*ray.direction_inverse.z;
|
||||
|
||||
tmin = max(tmin, min(tz1, tz2));
|
||||
tmax = min(tmax, max(tz1, tz2));
|
||||
tmin = std::max(tmin, std::min(tz1, tz2));
|
||||
tmax = std::min(tmax, std::max(tz1, tz2));
|
||||
|
||||
return tmax >= tmin;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
namespace wiJobSystem
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace wiJobSystem
|
||||
auto numCores = std::thread::hardware_concurrency();
|
||||
|
||||
// Calculate the actual number of worker threads we want:
|
||||
numThreads = max(1, numCores);
|
||||
numThreads = std::max(1u, numCores);
|
||||
|
||||
for (uint32_t threadID = 0; threadID < numThreads; ++threadID)
|
||||
{
|
||||
@@ -122,7 +123,7 @@ namespace wiJobSystem
|
||||
|
||||
// Calculate the current group's offset into the jobs:
|
||||
const uint32_t groupJobOffset = groupIndex * groupSize;
|
||||
const uint32_t groupJobEnd = min(groupJobOffset + groupSize, jobCount);
|
||||
const uint32_t groupJobEnd = std::min(groupJobOffset + groupSize, jobCount);
|
||||
|
||||
wiJobDispatchArgs args;
|
||||
args.groupIndex = groupIndex;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace wiMath
|
||||
// We find projection of point p onto the line.
|
||||
// It falls where t = [(p-v) . (w-v)] / |w-v|^2
|
||||
// We clamp t from [0,1] to handle points outside the segment vw.
|
||||
const float t = max(0, min(1, XMVectorGetX(XMVector3Dot(point - segmentA, segmentB-segmentA)) / l2));
|
||||
const float t = std::max(0.0f, std::min(1.0f, XMVectorGetX(XMVector3Dot(point - segmentA, segmentB-segmentA)) / l2));
|
||||
const XMVECTOR projection = segmentA + t * (segmentB - segmentA); // Projection falls on the segment
|
||||
return Distance(point, projection);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
#include "CommonInclude.h"
|
||||
|
||||
#define saturate(x) min(max(x,0),1)
|
||||
#include <algorithm>
|
||||
|
||||
#define saturate(x) std::min(std::max(x,0.0f),1.0f)
|
||||
|
||||
namespace wiMath
|
||||
{
|
||||
@@ -98,10 +100,10 @@ namespace wiMath
|
||||
return retVal;
|
||||
}
|
||||
inline constexpr XMFLOAT3 Max(const XMFLOAT3& a, const XMFLOAT3& b) {
|
||||
return XMFLOAT3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
|
||||
return XMFLOAT3(std::max(a.x, b.x), std::max(a.y, b.y), std::max(a.z, b.z));
|
||||
}
|
||||
inline constexpr XMFLOAT3 Min(const XMFLOAT3& a, const XMFLOAT3& b) {
|
||||
return XMFLOAT3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
|
||||
return XMFLOAT3(std::min(a.x, b.x), std::min(a.y, b.y), std::min(a.z, b.z));
|
||||
}
|
||||
inline constexpr float Clamp(float val, float min, float max)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "wiSceneSystem.h"
|
||||
#include "wiBackLog.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace wiGraphics;
|
||||
using namespace wiSceneSystem;
|
||||
@@ -346,7 +348,7 @@ void wiOcean::Render(const CameraComponent& camera, const WeatherComponent& weat
|
||||
cb.xOceanPatchSizeRecip = 1.0f / params.patch_length;
|
||||
cb.xOceanMapHalfTexel = 0.5f / params.dmap_dim;
|
||||
cb.xOceanWaterHeight = params.waterHeight;
|
||||
cb.xOceanSurfaceDisplacementTolerance = max(1, params.surfaceDisplacementTolerance);
|
||||
cb.xOceanSurfaceDisplacementTolerance = std::max(1.0f, params.surfaceDisplacementTolerance);
|
||||
|
||||
device->UpdateBuffer(&g_pShadingCB, &cb, threadID);
|
||||
|
||||
|
||||
+41
-41
@@ -620,7 +620,7 @@ const std::vector<CustomShader>& GetCustomShaders()
|
||||
}
|
||||
inline const GraphicsPSO* GetCustomShaderPSO(RENDERPASS renderPass, uint32_t renderTypeFlags, int customShaderID)
|
||||
{
|
||||
if (customShaderID >= 0 && customShaderID < customShaders.size())
|
||||
if (customShaderID >= 0 && customShaderID < (int)customShaders.size())
|
||||
{
|
||||
const CustomShader& customShader = customShaders[customShaderID];
|
||||
const CustomShader::Pass& customPass = customShader.passes[renderPass];
|
||||
@@ -1235,7 +1235,7 @@ struct SHCAM
|
||||
void CreateSpotLightShadowCam(const LightComponent& light, SHCAM& shcam)
|
||||
{
|
||||
const float zNearP = 0.1f;
|
||||
const float zFarP = max(1.0f, light.GetRange());
|
||||
const float zFarP = std::max(1.0f, light.GetRange());
|
||||
shcam = SHCAM(XMFLOAT4(0, 0, 0, 1), zNearP, zFarP, light.fov);
|
||||
shcam.Update(XMMatrixRotationQuaternion(XMLoadFloat4(&light.rotation)) *
|
||||
XMMatrixTranslationFromVector(XMLoadFloat3(&light.position)));
|
||||
@@ -1316,7 +1316,7 @@ ForwardEntityMaskCB ForwardEntityCullingCPU(const FrameCulling& culling, const A
|
||||
cb.xForwardEnvProbeMask = 0;
|
||||
|
||||
uint32_t buckets[2] = { 0,0 };
|
||||
for (size_t i = 0; i < min(64, culling.culledLights.size()); ++i) // only support indexing 64 lights at max for now
|
||||
for (size_t i = 0; i < std::min(size_t(64), culling.culledLights.size()); ++i) // only support indexing 64 lights at max for now
|
||||
{
|
||||
const uint32_t lightIndex = culling.culledLights[i];
|
||||
const AABB& light_aabb = scene.aabb_lights[lightIndex];
|
||||
@@ -1332,7 +1332,7 @@ ForwardEntityMaskCB ForwardEntityCullingCPU(const FrameCulling& culling, const A
|
||||
|
||||
if (renderPass == RENDERPASS_FORWARD || renderPass == RENDERPASS_ENVMAPCAPTURE)
|
||||
{
|
||||
for (size_t i = 0; i < min(32, culling.culledDecals.size()); ++i)
|
||||
for (size_t i = 0; i < std::min(size_t(32), culling.culledDecals.size()); ++i)
|
||||
{
|
||||
const uint32_t decalIndex = culling.culledDecals[culling.culledDecals.size() - 1 - i]; // note: reverse order, for correct blending!
|
||||
const AABB& decal_aabb = scene.aabb_decals[decalIndex];
|
||||
@@ -1346,7 +1346,7 @@ ForwardEntityMaskCB ForwardEntityCullingCPU(const FrameCulling& culling, const A
|
||||
|
||||
if (renderPass == RENDERPASS_FORWARD)
|
||||
{
|
||||
for (size_t i = 0; i < min(32, culling.culledEnvProbes.size()); ++i)
|
||||
for (size_t i = 0; i < std::min(size_t(32), culling.culledEnvProbes.size()); ++i)
|
||||
{
|
||||
const uint32_t probeIndex = culling.culledEnvProbes[culling.culledEnvProbes.size() - 1 - i]; // note: reverse order, for correct blending!
|
||||
const AABB& probe_aabb = scene.aabb_probes[probeIndex];
|
||||
@@ -1478,7 +1478,7 @@ void RenderMeshes(const RenderQueue& renderQueue, RENDERPASS renderPass, UINT re
|
||||
float distance = batch.GetDistance();
|
||||
float swapDistance = instance.impostorSwapDistance;
|
||||
float fadeThreshold = instance.impostorFadeThresholdRadius;
|
||||
dither = max(0, distance - swapDistance) / fadeThreshold;
|
||||
dither = std::max(0.0f, distance - swapDistance) / fadeThreshold;
|
||||
}
|
||||
|
||||
if (dither > 0)
|
||||
@@ -1818,7 +1818,7 @@ void RenderImpostors(const CameraComponent& camera, RENDERPASS renderPass, GRAPH
|
||||
continue;
|
||||
}
|
||||
|
||||
float dither = max(0, impostor.swapInDistance - distance) / impostor.fadeThresholdRadius;
|
||||
float dither = std::max(0.0f, impostor.swapInDistance - distance) / impostor.fadeThresholdRadius;
|
||||
|
||||
((volatile Instance*)instances.data)[drawableInstanceCount].Create(mat, XMFLOAT4((float)impostorID * impostorCaptureAngles * 3, 1, 1, 1), dither);
|
||||
|
||||
@@ -4055,7 +4055,7 @@ void UpdateRenderData(GRAPHICSTHREAD threadID)
|
||||
entityArray[entityCounter].SetType(force.type);
|
||||
entityArray[entityCounter].positionWS = force.position;
|
||||
entityArray[entityCounter].energy = force.gravity;
|
||||
entityArray[entityCounter].range = 1.0f / max(0.0001f, force.GetRange()); // avoid division in shader
|
||||
entityArray[entityCounter].range = 1.0f / std::max(0.0001f, force.GetRange()); // avoid division in shader
|
||||
entityArray[entityCounter].coneAngleCos = force.GetRange(); // this will be the real range in the less common shaders...
|
||||
// The default planar force field is facing upwards, and thus the pull direction is downwards:
|
||||
entityArray[entityCounter].directionWS = force.direction;
|
||||
@@ -4668,7 +4668,7 @@ void DrawLightVisualizers(const CameraComponent& camera, GRAPHICSTHREAD threadID
|
||||
else if (type == LightComponent::TUBE)
|
||||
{
|
||||
XMStoreFloat4x4(&lcb.lightWorld, XMMatrixTranspose(
|
||||
XMMatrixScaling(max(light.width * 0.5f, light.radius), light.radius, light.radius)*
|
||||
XMMatrixScaling(std::max(light.width * 0.5f, light.radius), light.radius, light.radius)*
|
||||
XMMatrixRotationQuaternion(XMLoadFloat4(&light.rotation))*
|
||||
XMMatrixTranslationFromVector(XMLoadFloat3(&light.position))*
|
||||
camera.GetViewProjection()
|
||||
@@ -5059,7 +5059,7 @@ void DrawForShadowMap(const CameraComponent& camera, GRAPHICSTHREAD threadID, ui
|
||||
SHCAM shcam;
|
||||
CreateSpotLightShadowCam(light, shcam);
|
||||
|
||||
const float zFarP = max(1.0f, light.GetRange());
|
||||
const float zFarP = std::max(1.0f, light.GetRange());
|
||||
Frustum frustum;
|
||||
frustum.Create(shcam.realProjection, shcam.View, zFarP);
|
||||
|
||||
@@ -5171,7 +5171,7 @@ void DrawForShadowMap(const CameraComponent& camera, GRAPHICSTHREAD threadID, ui
|
||||
device->BindConstantBuffer(PS, &constantBuffers[CBTYPE_MISC], CB_GETBINDSLOT(MiscCB), threadID);
|
||||
|
||||
const float zNearP = 0.1f;
|
||||
const float zFarP = max(1.0f, light.GetRange());
|
||||
const float zFarP = std::max(1.0f, light.GetRange());
|
||||
SHCAM cameras[] = {
|
||||
SHCAM(XMFLOAT4(0.5f, -0.5f, -0.5f, -0.5f), zNearP, zFarP, XM_PIDIV2), //+x
|
||||
SHCAM(XMFLOAT4(0.5f, 0.5f, 0.5f, -0.5f), zNearP, zFarP, XM_PIDIV2), //-x
|
||||
@@ -6326,7 +6326,7 @@ void RefreshEnvProbes(GRAPHICSTHREAD threadID)
|
||||
for (UINT i = desc.MipLevels - 1; i > 0; --i)
|
||||
{
|
||||
device->BindUAV(CS, texture, 0, threadID, i);
|
||||
device->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, max(0, (int)i - 2));
|
||||
device->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, std::max(0, (int)i - 2));
|
||||
|
||||
FilterEnvmapCB cb;
|
||||
cb.filterResolution.x = desc.Width;
|
||||
@@ -6338,8 +6338,8 @@ void RefreshEnvProbes(GRAPHICSTHREAD threadID)
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_FILTERENVMAP], CB_GETBINDSLOT(FilterEnvmapCB), threadID);
|
||||
|
||||
device->Dispatch(
|
||||
max(1, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
max(1, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
6,
|
||||
threadID);
|
||||
|
||||
@@ -6368,7 +6368,7 @@ void ManageImpostors()
|
||||
|
||||
Scene& scene = GetScene();
|
||||
|
||||
for (size_t impostorIndex = 0; impostorIndex < min(maxImpostorCount, scene.impostors.GetCount()); ++impostorIndex)
|
||||
for (size_t impostorIndex = 0; impostorIndex < std::min((size_t)maxImpostorCount, scene.impostors.GetCount()); ++impostorIndex)
|
||||
{
|
||||
ImpostorComponent& impostor = scene.impostors[impostorIndex];
|
||||
if (!impostor.IsDirty())
|
||||
@@ -6978,8 +6978,8 @@ void GenerateMipChain(const Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
{
|
||||
device->BindUAV(CS, texture, 0, threadID, i + 1);
|
||||
device->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, i);
|
||||
desc.Width = max(1, desc.Width / 2);
|
||||
desc.Height = max(1, desc.Height / 2);
|
||||
desc.Width = std::max(1u, desc.Width / 2);
|
||||
desc.Height = std::max(1u, desc.Height / 2);
|
||||
|
||||
GenerateMIPChainCB cb;
|
||||
cb.outputResolution.x = desc.Width;
|
||||
@@ -6989,8 +6989,8 @@ void GenerateMipChain(const Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_MIPGEN], CB_GETBINDSLOT(GenerateMIPChainCB), threadID);
|
||||
|
||||
device->Dispatch(
|
||||
max(1, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
max(1, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
6,
|
||||
threadID);
|
||||
|
||||
@@ -7026,8 +7026,8 @@ void GenerateMipChain(const Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
{
|
||||
device->BindUAV(CS, texture, 0, threadID, i + 1);
|
||||
device->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, i);
|
||||
desc.Width = max(1, desc.Width / 2);
|
||||
desc.Height = max(1, desc.Height / 2);
|
||||
desc.Width = std::max(1u, desc.Width / 2);
|
||||
desc.Height = std::max(1u, desc.Height / 2);
|
||||
|
||||
GenerateMIPChainCB cb;
|
||||
cb.outputResolution.x = desc.Width;
|
||||
@@ -7037,8 +7037,8 @@ void GenerateMipChain(const Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_MIPGEN], CB_GETBINDSLOT(GenerateMIPChainCB), threadID);
|
||||
|
||||
device->Dispatch(
|
||||
max(1, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
max(1, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
6,
|
||||
threadID);
|
||||
|
||||
@@ -7084,8 +7084,8 @@ void GenerateMipChain(const Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
{
|
||||
device->BindUAV(CS, texture, 0, threadID, i + 1);
|
||||
device->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, i);
|
||||
desc.Width = max(1, desc.Width / 2);
|
||||
desc.Height = max(1, desc.Height / 2);
|
||||
desc.Width = std::max(1u, desc.Width / 2);
|
||||
desc.Height = std::max(1u, desc.Height / 2);
|
||||
|
||||
GenerateMIPChainCB cb;
|
||||
cb.outputResolution.x = desc.Width;
|
||||
@@ -7095,8 +7095,8 @@ void GenerateMipChain(const Texture2D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_MIPGEN], CB_GETBINDSLOT(GenerateMIPChainCB), threadID);
|
||||
|
||||
device->Dispatch(
|
||||
max(1, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
max(1, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_2D_BLOCK_SIZE)),
|
||||
1,
|
||||
threadID);
|
||||
|
||||
@@ -7154,9 +7154,9 @@ void GenerateMipChain(const Texture3D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
{
|
||||
device->BindUAV(CS, texture, 0, threadID, i + 1);
|
||||
device->BindResource(CS, texture, TEXSLOT_UNIQUE0, threadID, i);
|
||||
desc.Width = max(1, desc.Width / 2);
|
||||
desc.Height = max(1, desc.Height / 2);
|
||||
desc.Depth = max(1, desc.Depth / 2);
|
||||
desc.Width = std::max(1u, desc.Width / 2);
|
||||
desc.Height = std::max(1u, desc.Height / 2);
|
||||
desc.Depth = std::max(1u, desc.Depth / 2);
|
||||
|
||||
GenerateMIPChainCB cb;
|
||||
cb.outputResolution.x = desc.Width;
|
||||
@@ -7167,9 +7167,9 @@ void GenerateMipChain(const Texture3D* texture, MIPGENFILTER filter, GRAPHICSTHR
|
||||
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_MIPGEN], CB_GETBINDSLOT(GenerateMIPChainCB), threadID);
|
||||
|
||||
device->Dispatch(
|
||||
max(1, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_3D_BLOCK_SIZE)),
|
||||
max(1, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_3D_BLOCK_SIZE)),
|
||||
max(1, (UINT)ceilf((float)desc.Depth / GENERATEMIPCHAIN_3D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Width / GENERATEMIPCHAIN_3D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Height / GENERATEMIPCHAIN_3D_BLOCK_SIZE)),
|
||||
std::max(1u, (UINT)ceilf((float)desc.Depth / GENERATEMIPCHAIN_3D_BLOCK_SIZE)),
|
||||
threadID);
|
||||
}
|
||||
|
||||
@@ -7531,7 +7531,7 @@ void GenerateClouds(const Texture2D* dst, UINT refinementCount, float randomness
|
||||
cb.xRandomness = randomness;
|
||||
if (refinementCount == 0)
|
||||
{
|
||||
cb.xRefinementCount = max(1, (UINT)log2(dst_desc.Width));
|
||||
cb.xRefinementCount = std::max(1u, (UINT)log2(dst_desc.Width));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -7846,7 +7846,7 @@ void RenderObjectLightMap(const ObjectComponent& object, GRAPHICSTHREAD threadID
|
||||
const Texture2D* rts[] = { object.lightmap.get() };
|
||||
device->BindRenderTargets(1, rts, nullptr, threadID);
|
||||
|
||||
const uint32_t lightmapIterationCount = max(1, object.lightmapIterationCount) - 1; // ManageLightMapAtlas incremented before refresh
|
||||
const uint32_t lightmapIterationCount = std::max(1u, object.lightmapIterationCount) - 1; // ManageLightMapAtlas incremented before refresh
|
||||
|
||||
if (lightmapIterationCount == 0)
|
||||
{
|
||||
@@ -8031,7 +8031,7 @@ void UpdateFrameCB(GRAPHICSTHREAD threadID)
|
||||
cb.g_xFrame_VoxelRadianceDataRes = GetVoxelRadianceEnabled() ? (uint)voxelSceneData.res : 0;
|
||||
cb.g_xFrame_VoxelRadianceDataRes_Inverse = 1.0f / (float)cb.g_xFrame_VoxelRadianceDataRes;
|
||||
cb.g_xFrame_VoxelRadianceDataMIPs = voxelSceneData.mips;
|
||||
cb.g_xFrame_VoxelRadianceNumCones = max(min(voxelSceneData.numCones, 16), 1);
|
||||
cb.g_xFrame_VoxelRadianceNumCones = std::max(std::min(voxelSceneData.numCones, 16u), 1u);
|
||||
cb.g_xFrame_VoxelRadianceNumCones_Inverse = 1.0f / (float)cb.g_xFrame_VoxelRadianceNumCones;
|
||||
cb.g_xFrame_VoxelRadianceRayStepSize = voxelSceneData.rayStepSize;
|
||||
cb.g_xFrame_VoxelRadianceReflectionsEnabled = voxelSceneData.reflectionsEnabled;
|
||||
@@ -8121,10 +8121,10 @@ void UpdateFrameCB(GRAPHICSTHREAD threadID)
|
||||
cb.g_xFrame_MainCamera_Up = camera.Up;
|
||||
cb.g_xFrame_MainCamera_ZNearP = camera.zNearP;
|
||||
cb.g_xFrame_MainCamera_ZFarP = camera.zFarP;
|
||||
cb.g_xFrame_MainCamera_ZNearP_Recip = 1.0f / max(0.0001f, cb.g_xFrame_MainCamera_ZNearP);
|
||||
cb.g_xFrame_MainCamera_ZFarP_Recip = 1.0f / max(0.0001f, cb.g_xFrame_MainCamera_ZFarP);
|
||||
cb.g_xFrame_MainCamera_ZNearP_Recip = 1.0f / std::max(0.0001f, cb.g_xFrame_MainCamera_ZNearP);
|
||||
cb.g_xFrame_MainCamera_ZFarP_Recip = 1.0f / std::max(0.0001f, cb.g_xFrame_MainCamera_ZFarP);
|
||||
cb.g_xFrame_MainCamera_ZRange = abs(cb.g_xFrame_MainCamera_ZFarP - cb.g_xFrame_MainCamera_ZNearP);
|
||||
cb.g_xFrame_MainCamera_ZRange_Recip = 1.0f / max(0.0001f, cb.g_xFrame_MainCamera_ZRange);
|
||||
cb.g_xFrame_MainCamera_ZRange_Recip = 1.0f / std::max(0.0001f, cb.g_xFrame_MainCamera_ZRange);
|
||||
cb.g_xFrame_FrustumPlanesWS[0] = camera.frustum.getLeftPlane();
|
||||
cb.g_xFrame_FrustumPlanesWS[1] = camera.frustum.getRightPlane();
|
||||
cb.g_xFrame_FrustumPlanesWS[2] = camera.frustum.getTopPlane();
|
||||
@@ -8229,7 +8229,7 @@ const Texture2D* ComputeLuminance(const Texture2D* sourceImage, GRAPHICSTHREAD t
|
||||
|
||||
while (desc.Width > 1)
|
||||
{
|
||||
desc.Width = max(desc.Width / 16, 1);
|
||||
desc.Width = std::max(desc.Width / 16, 1u);
|
||||
desc.Height = desc.Width;
|
||||
|
||||
Texture2D* tex = new Texture2D;
|
||||
@@ -8415,7 +8415,7 @@ bool GetAdvancedRefractionsEnabled() { return advancedRefractions; }
|
||||
bool IsRequestedReflectionRendering() { return requestReflectionRendering; }
|
||||
void SetEnvironmentMap(wiGraphics::Texture2D* tex) { enviroMap = tex; }
|
||||
const Texture2D* GetEnvironmentMap() { return enviroMap; }
|
||||
void SetGameSpeed(float value) { GameSpeed = max(0, value); }
|
||||
void SetGameSpeed(float value) { GameSpeed = std::max(0.0f, value); }
|
||||
float GetGameSpeed() { return GameSpeed; }
|
||||
void SetOceanEnabled(bool enabled)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "Utility/stb_image.h"
|
||||
#include "Utility/tinyddsloader.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace wiGraphics;
|
||||
|
||||
@@ -242,7 +244,7 @@ const void* wiResourceManager::add(const wiHashString& name, Data_Type newType)
|
||||
desc.Format = FORMAT_R8G8B8A8_UNORM;
|
||||
desc.Height = static_cast<uint32_t>(height);
|
||||
desc.Width = static_cast<uint32_t>(width);
|
||||
desc.MipLevels = (UINT)log2(max(width, height));
|
||||
desc.MipLevels = (UINT)log2(std::max(width, height));
|
||||
desc.MiscFlags = 0;
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
|
||||
@@ -252,7 +254,7 @@ const void* wiResourceManager::add(const wiHashString& name, Data_Type newType)
|
||||
{
|
||||
InitData[mip].pSysMem = rgb;
|
||||
InitData[mip].SysMemPitch = static_cast<UINT>(mipwidth * channelCount);
|
||||
mipwidth = max(1, mipwidth / 2);
|
||||
mipwidth = std::max(1u, mipwidth / 2);
|
||||
}
|
||||
|
||||
Texture2D* image = new Texture2D;
|
||||
|
||||
@@ -1101,30 +1101,30 @@ namespace wiSceneSystem
|
||||
// Entities are unique within a ComponentManager, so the most populated ComponentManager
|
||||
// will actually give us how many entities there are in the scene
|
||||
size_t entityCount = 0;
|
||||
entityCount = max(entityCount, names.GetCount());
|
||||
entityCount = max(entityCount, layers.GetCount());
|
||||
entityCount = max(entityCount, transforms.GetCount());
|
||||
entityCount = max(entityCount, prev_transforms.GetCount());
|
||||
entityCount = max(entityCount, hierarchy.GetCount());
|
||||
entityCount = max(entityCount, materials.GetCount());
|
||||
entityCount = max(entityCount, meshes.GetCount());
|
||||
entityCount = max(entityCount, impostors.GetCount());
|
||||
entityCount = max(entityCount, objects.GetCount());
|
||||
entityCount = max(entityCount, aabb_objects.GetCount());
|
||||
entityCount = max(entityCount, rigidbodies.GetCount());
|
||||
entityCount = max(entityCount, softbodies.GetCount());
|
||||
entityCount = max(entityCount, armatures.GetCount());
|
||||
entityCount = max(entityCount, lights.GetCount());
|
||||
entityCount = max(entityCount, aabb_lights.GetCount());
|
||||
entityCount = max(entityCount, cameras.GetCount());
|
||||
entityCount = max(entityCount, probes.GetCount());
|
||||
entityCount = max(entityCount, aabb_probes.GetCount());
|
||||
entityCount = max(entityCount, forces.GetCount());
|
||||
entityCount = max(entityCount, decals.GetCount());
|
||||
entityCount = max(entityCount, aabb_decals.GetCount());
|
||||
entityCount = max(entityCount, animations.GetCount());
|
||||
entityCount = max(entityCount, emitters.GetCount());
|
||||
entityCount = max(entityCount, hairs.GetCount());
|
||||
entityCount = std::max(entityCount, names.GetCount());
|
||||
entityCount = std::max(entityCount, layers.GetCount());
|
||||
entityCount = std::max(entityCount, transforms.GetCount());
|
||||
entityCount = std::max(entityCount, prev_transforms.GetCount());
|
||||
entityCount = std::max(entityCount, hierarchy.GetCount());
|
||||
entityCount = std::max(entityCount, materials.GetCount());
|
||||
entityCount = std::max(entityCount, meshes.GetCount());
|
||||
entityCount = std::max(entityCount, impostors.GetCount());
|
||||
entityCount = std::max(entityCount, objects.GetCount());
|
||||
entityCount = std::max(entityCount, aabb_objects.GetCount());
|
||||
entityCount = std::max(entityCount, rigidbodies.GetCount());
|
||||
entityCount = std::max(entityCount, softbodies.GetCount());
|
||||
entityCount = std::max(entityCount, armatures.GetCount());
|
||||
entityCount = std::max(entityCount, lights.GetCount());
|
||||
entityCount = std::max(entityCount, aabb_lights.GetCount());
|
||||
entityCount = std::max(entityCount, cameras.GetCount());
|
||||
entityCount = std::max(entityCount, probes.GetCount());
|
||||
entityCount = std::max(entityCount, aabb_probes.GetCount());
|
||||
entityCount = std::max(entityCount, forces.GetCount());
|
||||
entityCount = std::max(entityCount, decals.GetCount());
|
||||
entityCount = std::max(entityCount, aabb_decals.GetCount());
|
||||
entityCount = std::max(entityCount, animations.GetCount());
|
||||
entityCount = std::max(entityCount, emitters.GetCount());
|
||||
entityCount = std::max(entityCount, hairs.GetCount());
|
||||
return entityCount;
|
||||
}
|
||||
|
||||
@@ -1529,7 +1529,7 @@ namespace wiSceneSystem
|
||||
keyRight--;
|
||||
|
||||
// Left keyframe is just near right:
|
||||
keyLeft = max(0, keyRight - 1);
|
||||
keyLeft = std::max(0, keyRight - 1);
|
||||
}
|
||||
|
||||
float left = sampler.keyframe_times[keyLeft];
|
||||
@@ -1911,7 +1911,7 @@ namespace wiSceneSystem
|
||||
XMStoreFloat3(&decal.position, T);
|
||||
XMFLOAT3 scale;
|
||||
XMStoreFloat3(&scale, S);
|
||||
decal.range = max(scale.x, max(scale.y, scale.z)) * 2;
|
||||
decal.range = std::max(scale.x, std::max(scale.y, scale.z)) * 2;
|
||||
|
||||
AABB& aabb = aabb_decals[args.jobIndex];
|
||||
aabb.createFromHalfWidth(XMFLOAT3(0, 0, 0), XMFLOAT3(1, 1, 1));
|
||||
@@ -1947,7 +1947,7 @@ namespace wiSceneSystem
|
||||
XMMatrixDecompose(&S, &R, &T, W);
|
||||
XMFLOAT3 scale;
|
||||
XMStoreFloat3(&scale, S);
|
||||
probe.range = max(scale.x, max(scale.y, scale.z)) * 2;
|
||||
probe.range = std::max(scale.x, std::max(scale.y, scale.z)) * 2;
|
||||
|
||||
AABB& aabb = aabb_probes[args.jobIndex];
|
||||
aabb.createFromHalfWidth(XMFLOAT3(0, 0, 0), XMFLOAT3(1, 1, 1));
|
||||
@@ -1972,7 +1972,7 @@ namespace wiSceneSystem
|
||||
XMStoreFloat3(&force.position, T);
|
||||
XMStoreFloat3(&force.direction, XMVector3Normalize(XMVector3TransformNormal(XMVectorSet(0, -1, 0, 0), W)));
|
||||
|
||||
force.range_global = force.range_local * max(XMVectorGetX(S), max(XMVectorGetY(S), XMVectorGetZ(S)));
|
||||
force.range_global = force.range_local * std::max(XMVectorGetX(S), std::max(XMVectorGetY(S), XMVectorGetZ(S)));
|
||||
});
|
||||
}
|
||||
void RunLightUpdateSystem(
|
||||
@@ -1998,7 +1998,7 @@ namespace wiSceneSystem
|
||||
XMStoreFloat4(&light.rotation, R);
|
||||
XMStoreFloat3(&light.direction, XMVector3TransformNormal(XMVectorSet(0, 1, 0, 0), W));
|
||||
|
||||
light.range_global = light.range_local * max(XMVectorGetX(S), max(XMVectorGetY(S), XMVectorGetZ(S)));
|
||||
light.range_global = light.range_local * std::max(XMVectorGetX(S), std::max(XMVectorGetY(S), XMVectorGetZ(S)));
|
||||
|
||||
switch (light.type)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 26;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 22;
|
||||
const int revision = 23;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
@@ -649,7 +649,7 @@ void wiTextInputField::DeleteFromInput()
|
||||
|
||||
|
||||
wiSlider::wiSlider(float start, float end, float defaultValue, float step, const std::string& name) :wiWidget()
|
||||
, start(start), end(end), value(defaultValue), step(max(step, 1))
|
||||
, start(start), end(end), value(defaultValue), step(std::max(step, 1.0f))
|
||||
{
|
||||
SetName(name);
|
||||
SetText(fastName.GetString());
|
||||
@@ -662,8 +662,8 @@ wiSlider::wiSlider(float start, float end, float defaultValue, float step, const
|
||||
valueInputField->SetValue(end);
|
||||
valueInputField->OnInputAccepted([&](wiEventArgs args) {
|
||||
this->value = args.fValue;
|
||||
this->start = min(this->start, args.fValue);
|
||||
this->end = max(this->end, args.fValue);
|
||||
this->start = std::min(this->start, args.fValue);
|
||||
this->end = std::max(this->end, args.fValue);
|
||||
onSlide(args);
|
||||
});
|
||||
valueInputField->parent = this;
|
||||
@@ -984,7 +984,7 @@ wiComboBox::~wiComboBox()
|
||||
}
|
||||
const float wiComboBox::_GetItemOffset(int index) const
|
||||
{
|
||||
index = max(firstItemVisible, index) - firstItemVisible;
|
||||
index = std::max(firstItemVisible, index) - firstItemVisible;
|
||||
return scale.y * (index + 1) + 1;
|
||||
}
|
||||
void wiComboBox::Update(wiGUI* gui, float dt)
|
||||
@@ -1073,7 +1073,7 @@ void wiComboBox::Update(wiGUI* gui, float dt)
|
||||
{
|
||||
int scroll = (int)wiInputManager::getpointer().z;
|
||||
firstItemVisible -= scroll;
|
||||
firstItemVisible = max(0, min((int)items.size() - maxVisibleItemCount, firstItemVisible));
|
||||
firstItemVisible = std::max(0, std::min((int)items.size() - maxVisibleItemCount, firstItemVisible));
|
||||
|
||||
hovered = -1;
|
||||
for (size_t i = 0; i < items.size(); ++i)
|
||||
@@ -1463,7 +1463,7 @@ void wiWindow::Render(const wiGUI* gui) const
|
||||
}
|
||||
|
||||
wiRenderer::GetDevice()->BindScissorRects(1, &scissorRect, gui->GetGraphicsThread());
|
||||
wiFont(text, wiFontParams((int)(translation.x + resizeDragger_UpperLeft->scale.x + 2), (int)(translation.y), WIFONTSIZE_DEFAULT, WIFALIGN_LEFT, WIFALIGN_TOP, 0, 0,
|
||||
wiFont(text, wiFontParams((int)(translation.x + resizeDragger_UpperLeft->scale.x + 2), (int)(translation.y + resizeDragger_UpperLeft->scale.y * 0.5f), WIFONTSIZE_DEFAULT, WIFALIGN_LEFT, WIFALIGN_CENTER, 0, 0,
|
||||
textColor, textShadowColor)).Draw(gui->GetGraphicsThread());
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user