Skip to content

Commit

Permalink
Added noexcept annotation to public functions and fixed -Wmicrosoft-e…
Browse files Browse the repository at this point in the history
…xception-spec
  • Loading branch information
walbourn committed Dec 12, 2019
1 parent c2d67b8 commit 9a8cc96
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 61 deletions.
26 changes: 13 additions & 13 deletions UVAtlas/inc/UVAtlas.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <functional>
#include <vector>

#define UVATLAS_VERSION 160
#define UVATLAS_VERSION 170

namespace DirectX
{
Expand Down Expand Up @@ -149,7 +149,7 @@ namespace DirectX
_Inout_opt_ std::vector<uint32_t>* pvFacePartitioning = nullptr,
_Inout_opt_ std::vector<uint32_t>* pvVertexRemapArray = nullptr,
_Out_opt_ float *maxStretchOut = nullptr,
_Out_opt_ size_t *numChartsOut = nullptr);
_Out_opt_ size_t *numChartsOut = nullptr) noexcept;

// This has the same exact arguments as Create, except that it does not perform the
// final packing step. This method allows one to get a partitioning out, and possibly
Expand Down Expand Up @@ -196,7 +196,7 @@ namespace DirectX
_Inout_opt_ std::vector<uint32_t>* pvVertexRemapArray,
_Inout_ std::vector<uint32_t>& vPartitionResultAdjacency,
_Out_opt_ float *maxStretchOut = nullptr,
_Out_opt_ size_t *numChartsOut = nullptr);
_Out_opt_ size_t *numChartsOut = nullptr) noexcept;

// This takes the face partitioning result from Partition and packs it into an
// atlas of the given size. pPartitionResultAdjacency should be derived from
Expand All @@ -210,7 +210,7 @@ namespace DirectX
_In_ float gutter,
_In_ const std::vector<uint32_t>& vPartitionResultAdjacency,
_In_opt_ std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
_In_ float callbackFrequency);
_In_ float callbackFrequency) noexcept;


//============================================================================
Expand Down Expand Up @@ -252,7 +252,7 @@ namespace DirectX
_In_ size_t signalDimension,
_In_ size_t signalStride,
_In_opt_ std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
_Out_writes_(nFaces * 3) float* pIMTArray);
_Out_writes_(nFaces * 3) float* pIMTArray) noexcept;

// This function is used to calculate the IMT from data that varies over the
// surface of the mesh (generally at a higher frequency than vertex data).
Expand Down Expand Up @@ -285,7 +285,7 @@ namespace DirectX
signalCallback,
_In_opt_ void *userData,
_In_opt_ std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
_Out_writes_(nFaces * 3) float* pIMTArray);
_Out_writes_(nFaces * 3) float* pIMTArray) noexcept;

// This function is used to calculate the IMT from texture data. Given a texture
// that maps over the surface of the mesh, the algorithm computes the IMT for
Expand All @@ -309,7 +309,7 @@ namespace DirectX
_In_ size_t height,
_In_ DWORD options,
_In_opt_ std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
_Out_writes_(nFaces * 3) float* pIMTArray);
_Out_writes_(nFaces * 3) float* pIMTArray) noexcept;

// This function is very similar to UVAtlasComputeIMTFromTexture, but it can
// calculate higher dimensional values than 4.
Expand All @@ -325,29 +325,29 @@ namespace DirectX
_In_reads_(nVerts) const XMFLOAT3* positions,
_In_reads_(nVerts) const XMFLOAT2* texcoords,
_In_ size_t nVerts,
_When_(indexFormat == DXGI_FORMAT_R16_UINT, _In_reads_bytes_(nFaces*sizeof(uint16_t)))
_When_(indexFormat != DXGI_FORMAT_R16_UINT, _In_reads_bytes_(nFaces*sizeof(uint32_t))) const void* indices,
_When_(indexFormat == DXGI_FORMAT_R16_UINT, _In_reads_bytes_(nFaces * sizeof(uint16_t)))
_When_(indexFormat != DXGI_FORMAT_R16_UINT, _In_reads_bytes_(nFaces * sizeof(uint32_t))) const void* indices,
_In_ DXGI_FORMAT indexFormat,
_In_ size_t nFaces,
_In_reads_(width*height*nComponents) const float *pTexelSignal,
_In_reads_(width* height* nComponents) const float* pTexelSignal,
_In_ size_t width,
_In_ size_t height,
_In_ size_t signalDimension,
_In_ size_t nComponents,
_In_ DWORD options,
_In_opt_ std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
_Out_writes_(nFaces * 3) float* pIMTArray);
_Out_writes_(nFaces * 3) float* pIMTArray) noexcept;

// This function is for applying the a vertex remap array from UVAtlasCreate/UVAtlasPartition to a vertex buffer
//
// vbin - This is the original vertex buffer and is nVerts*stride in size
// vbout - This is the output vertex buffer and is nNewVerts*stride in size
// nNewVerts - This should be >= nVerts
HRESULT __cdecl UVAtlasApplyRemap(
_In_reads_bytes_(nVerts*stride) const void* vbin,
_In_reads_bytes_(nVerts* stride) const void* vbin,
_In_ size_t stride,
_In_ size_t nVerts,
_In_ size_t nNewVerts,
_In_reads_(nNewVerts) const uint32_t* vertexRemap,
_Out_writes_bytes_(nNewVerts*stride) void* vbout );
_Out_writes_bytes_(nNewVerts* stride) void* vbout) noexcept;
}
16 changes: 8 additions & 8 deletions UVAtlas/isochart/UVAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ HRESULT __cdecl DirectX::UVAtlasPartition(
std::vector<uint32_t>* pvVertexRemapArray,
std::vector<uint32_t>& vPartitionResultAdjacency,
float *maxStretchOut,
size_t *numChartsOut)
size_t *numChartsOut) noexcept
{
return UVAtlasPartitionInt(positions,
nVerts,
Expand Down Expand Up @@ -626,7 +626,7 @@ HRESULT __cdecl DirectX::UVAtlasPack(
float gutter,
const std::vector<uint32_t>& vPartitionResultAdjacency,
std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
float callbackFrequency)
float callbackFrequency) noexcept
{
return UVAtlasPackInt(vMeshVertexBuffer,
vMeshIndexBuffer,
Expand Down Expand Up @@ -666,7 +666,7 @@ HRESULT __cdecl DirectX::UVAtlasCreate(
std::vector<uint32_t>* pvFacePartitioning,
std::vector<uint32_t>* pvVertexRemapArray,
float *maxStretchOut,
size_t *numChartsOut)
size_t *numChartsOut) noexcept
{
std::vector<uint32_t> vFacePartitioning;
std::vector<uint32_t> vAdjacencyOut;
Expand Down Expand Up @@ -733,7 +733,7 @@ HRESULT __cdecl DirectX::UVAtlasComputeIMTFromPerVertexSignal(
size_t signalDimension,
size_t signalStride,
std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
float* pIMTArray)
float* pIMTArray) noexcept
{
if (!positions || !nVerts || !indices || !nFaces || !pVertexSignal || !pIMTArray)
return E_INVALIDARG;
Expand Down Expand Up @@ -855,7 +855,7 @@ HRESULT __cdecl DirectX::UVAtlasComputeIMTFromSignal(
std::function<HRESULT __cdecl(const DirectX::XMFLOAT2 *uv, size_t primitiveID, size_t signalDimension, void* userData, float* signalOut)> signalCallback,
void *userData,
std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
float* pIMTArray)
float* pIMTArray) noexcept
{
if (!positions || !texcoords || !nVerts || !indices || !nFaces || !pIMTArray)
return E_INVALIDARG;
Expand Down Expand Up @@ -1241,7 +1241,7 @@ HRESULT __cdecl DirectX::UVAtlasComputeIMTFromTexture(
size_t height,
DWORD options,
std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
float* pIMTArray)
float* pIMTArray) noexcept
{
if (!positions || !texcoords || !nVerts || !indices || !nFaces || !pTexture || !pIMTArray)
return E_INVALIDARG;
Expand Down Expand Up @@ -1644,7 +1644,7 @@ HRESULT __cdecl DirectX::UVAtlasComputeIMTFromPerTexelSignal(
size_t nComponents,
DWORD options,
std::function<HRESULT __cdecl(float percentComplete)> statusCallBack,
float* pIMTArray)
float* pIMTArray) noexcept
{
if (!positions || !texcoords || !nVerts || !indices || !nFaces || !pTexelSignal || !pIMTArray)
return E_INVALIDARG;
Expand Down Expand Up @@ -1780,7 +1780,7 @@ HRESULT __cdecl DirectX::UVAtlasApplyRemap(
size_t nVerts,
size_t nNewVerts,
const uint32_t* vertexRemap,
void* vbout )
void* vbout ) noexcept
{
if ( !vbin || !stride || !nVerts || !nNewVerts || !vertexRemap || !vbout )
return E_INVALIDARG;
Expand Down
32 changes: 15 additions & 17 deletions UVAtlas/isochart/isochart.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class IIsochartEngine
static IIsochartEngine* CreateIsochartEngine();
static void ReleaseIsochartEngine(IIsochartEngine* pIsochartEngine);

STDMETHOD(Initialize)(
virtual HRESULT Initialize(
const void* pVertexArray,
size_t VertexCount,
size_t VertexStride,
Expand All @@ -126,50 +126,48 @@ class IIsochartEngine
const FLOAT3* pIMTArray,
const uint32_t* pOriginalAjacency,
const uint32_t* pSplitHint,
DWORD dwOptions) PURE;
DWORD dwOptions) noexcept = 0;

STDMETHOD(Free)() PURE;
virtual HRESULT Free() noexcept = 0;

STDMETHOD(Partition)(
virtual HRESULT Partition(
size_t MaxChartNumber,
float Stretch,
size_t& ChartNumberOut,
float& MaxChartStretchOut,
uint32_t* pFaceAttributeIDOut) PURE;
uint32_t* pFaceAttributeIDOut) noexcept = 0;

STDMETHOD(Pack)(
virtual HRESULT Pack(
size_t Width,
size_t Height,
float Gutter,
const void* pOrigIndexBuffer,
std::vector<DirectX::UVAtlasVertex>* pvVertexArrayOut,
std::vector<uint8_t>* pvFaceIndexArrayOut,
std::vector<uint32_t>* pvVertexRemapArrayOut,
_In_opt_ std::vector<uint32_t>* pvAttributeID) PURE;
_In_opt_ std::vector<uint32_t>* pvAttributeID) noexcept = 0;

STDMETHOD(SetCallback)(
virtual HRESULT SetCallback(
LPISOCHARTCALLBACK pCallback,
float Frequency) PURE;
float Frequency) noexcept = 0;

STDMETHOD(SetStage)(
virtual HRESULT SetStage(
unsigned int TotalStageCount,
unsigned int DoneStageCount) PURE;

unsigned int DoneStageCount) noexcept = 0;

STDMETHOD (ExportPartitionResult)(
virtual HRESULT ExportPartitionResult(
std::vector<DirectX::UVAtlasVertex>* pvVertexArrayOut,
std::vector<uint8_t>* pvFaceIndexArrayOut,
std::vector<uint32_t>* pvVertexRemapArrayOut,
std::vector<uint32_t>* pvAttributeIDOut,
std::vector<uint32_t>* pvAdjacencyOut) PURE;

std::vector<uint32_t>* pvAdjacencyOut) noexcept = 0;

STDMETHOD (InitializePacking)(
virtual HRESULT InitializePacking(
std::vector<DirectX::UVAtlasVertex>* pvVertexBuffer,
size_t VertexCount,
std::vector<uint8_t>* pvFaceIndexBuffer,
size_t FaceCount,
const uint32_t* pdwFaceAdjacentArrayIn) PURE;
const uint32_t* pdwFaceAdjacentArrayIn) noexcept = 0;
};

/////////////////////////////////////////////////////////////////////////
Expand Down
16 changes: 8 additions & 8 deletions UVAtlas/isochart/isochartengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ HRESULT CIsochartEngine::Initialize(
const FLOAT3* pIMTArray,
const uint32_t* pOriginalAjacency,
const uint32_t* pSplitHint,
DWORD dwOptions)
DWORD dwOptions) noexcept
{
DPF(1, "Initialize...");

Expand Down Expand Up @@ -168,7 +168,7 @@ HRESULT CIsochartEngine::Initialize(
}

// Release all buffers and reset CIsochartEngine
HRESULT CIsochartEngine::Free()
HRESULT CIsochartEngine::Free() noexcept
{
HRESULT hr = S_OK;

Expand Down Expand Up @@ -202,7 +202,7 @@ HRESULT CIsochartEngine::Partition(
float Stretch,
size_t& ChartNumberOut,
float& MaxChartStretchOut,
uint32_t* pFaceAttributeIDOut)
uint32_t* pFaceAttributeIDOut) noexcept
{
DPF(1, "Partition....");

Expand Down Expand Up @@ -711,7 +711,7 @@ HRESULT CIsochartEngine::Pack(
std::vector<UVAtlasVertex>* pvVertexArrayOut,
std::vector<uint8_t>* pvFaceIndexArrayOut,
std::vector<uint32_t>* pvVertexRemapArrayOut,
_In_opt_ std::vector<uint32_t>* pvAttributeID)
_In_opt_ std::vector<uint32_t>* pvAttributeID) noexcept
{
DPF(1, "Packing Charts...");
if (!CheckPackParameters(
Expand Down Expand Up @@ -841,7 +841,7 @@ void CIsochartEngine::ExportPackResultToOrgMesh(
//
HRESULT CIsochartEngine::SetCallback(
LPISOCHARTCALLBACK pCallback,
float Frequency)
float Frequency) noexcept
{
if (!CheckSetCallbackParameters(
pCallback,
Expand Down Expand Up @@ -869,7 +869,7 @@ HRESULT CIsochartEngine::SetCallback(

HRESULT CIsochartEngine::SetStage(
unsigned int TotalStageCount,
unsigned int DoneStageCount)
unsigned int DoneStageCount) noexcept
{
if (TotalStageCount < DoneStageCount)
{
Expand Down Expand Up @@ -899,7 +899,7 @@ HRESULT CIsochartEngine::ExportPartitionResult(
std::vector<uint8_t>* pvFaceIndexArrayOut,
std::vector<uint32_t>* pvVertexRemapArrayOut,
std::vector<uint32_t>* pvAttributeIDOut,
std::vector<uint32_t>* pvAdjacencyOut)
std::vector<uint32_t>* pvAdjacencyOut) noexcept
{

if (!CheckExportPartitionResultParameters(
Expand Down Expand Up @@ -936,7 +936,7 @@ HRESULT CIsochartEngine::InitializePacking(
size_t VertexCount,
std::vector<uint8_t>* pvFaceIndexBuffer,
size_t FaceCount,
const uint32_t* pdwFaceAdjacentArrayIn)
const uint32_t* pdwFaceAdjacentArrayIn) noexcept
{
if (!CheckInitializePackingParameters(
pvVertexBuffer,
Expand Down
30 changes: 15 additions & 15 deletions UVAtlas/isochart/isochartengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CIsochartEngine : public IIsochartEngine
virtual ~CIsochartEngine() override;

// IIsochartEngine
STDMETHODIMP Initialize(
virtual HRESULT Initialize(
const void* pVertexArray,
size_t VertexCount,
size_t VertexStride,
Expand All @@ -36,48 +36,48 @@ class CIsochartEngine : public IIsochartEngine
const FLOAT3* pIMTArray,
const uint32_t* pOriginalAjacency,
const uint32_t* pSplitHint,
DWORD dwOptions) override;
DWORD dwOptions) noexcept override;

STDMETHODIMP Free() override;
virtual HRESULT Free() noexcept override;

STDMETHODIMP Partition(
virtual HRESULT Partition(
size_t MaxChartNumber,
float Stretch,
size_t& ChartNumberOut,
float& MaxChartStretchOut,
uint32_t* pFaceAttributeIDOut) override;
uint32_t* pFaceAttributeIDOut) noexcept override;

STDMETHODIMP Pack(
virtual HRESULT Pack(
size_t Width,
size_t Height,
float Gutter,
const void* pOrigIndexBuffer,
std::vector<DirectX::UVAtlasVertex>* pvVertexArrayOut,
std::vector<uint8_t>* pvFaceIndexArrayOut,
std::vector<uint32_t>* pvVertexRemapArrayOut,
_In_opt_ std::vector<uint32_t>* pvAttributeID) override;
_In_opt_ std::vector<uint32_t>* pvAttributeID) noexcept override;

STDMETHODIMP SetCallback(
virtual HRESULT SetCallback(
LPISOCHARTCALLBACK pCallback,
float Frequency) override;
float Frequency) noexcept override;

STDMETHODIMP SetStage(
virtual HRESULT SetStage(
unsigned int TotalStageCount,
unsigned int DoneStageCount) override;
unsigned int DoneStageCount) noexcept override;

STDMETHODIMP ExportPartitionResult(
virtual HRESULT ExportPartitionResult(
std::vector<DirectX::UVAtlasVertex>* pvVertexArrayOut,
std::vector<uint8_t>* pvFaceIndexArrayOut,
std::vector<uint32_t>* pvVertexRemapArrayOut,
std::vector<uint32_t>* pvAttributeIDOut,
std::vector<uint32_t>* pvAdjacencyOut) override;
std::vector<uint32_t>* pvAdjacencyOut) noexcept override;

STDMETHODIMP InitializePacking(
virtual HRESULT InitializePacking(
std::vector<DirectX::UVAtlasVertex>* pvVertexBuffer,
size_t VertexCount,
std::vector<uint8_t>* pvFaceIndexBuffer,
size_t FaceCount,
const uint32_t* pdwFaceAdjacentArrayIn) override;
const uint32_t* pdwFaceAdjacentArrayIn) noexcept override;

HRESULT CreateEngineMutex();
private:
Expand Down

0 comments on commit 9a8cc96

Please sign in to comment.