mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Merge branch 'master' of github.com:bkaradzic/bgfx
This commit is contained in:
commit
e94ac9d655
2 changed files with 27 additions and 24 deletions
|
@ -12,7 +12,7 @@
|
||||||
namespace bgfx
|
namespace bgfx
|
||||||
{
|
{
|
||||||
template<typename IndexT>
|
template<typename IndexT>
|
||||||
static uint32_t toplogyConvertTriListFlipWinding(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
static uint32_t topologyConvertTriListFlipWinding(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
||||||
{
|
{
|
||||||
if (NULL == _dst)
|
if (NULL == _dst)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ namespace bgfx
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename IndexT, typename SortT>
|
template<typename IndexT, typename SortT>
|
||||||
static uint32_t toplogyConvertTriListToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices, IndexT* _temp, SortT* _tempSort)
|
static uint32_t topologyConvertTriListToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices, IndexT* _temp, SortT* _tempSort)
|
||||||
{
|
{
|
||||||
// Create all line pairs and sort indices.
|
// Create all line pairs and sort indices.
|
||||||
IndexT* dst = _temp;
|
IndexT* dst = _temp;
|
||||||
|
@ -107,17 +107,17 @@ namespace bgfx
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename IndexT, typename SortT>
|
template<typename IndexT, typename SortT>
|
||||||
static uint32_t toplogyConvertTriListToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices, bx::AllocatorI* _allocator)
|
static uint32_t topologyConvertTriListToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices, bx::AllocatorI* _allocator)
|
||||||
{
|
{
|
||||||
IndexT* temp = (IndexT*)BX_ALLOC(_allocator, _numIndices*2*sizeof(IndexT)*2);
|
IndexT* temp = (IndexT*)BX_ALLOC(_allocator, _numIndices*2*sizeof(IndexT)*2);
|
||||||
SortT* tempSort = (SortT*)&temp[_numIndices*2];
|
SortT* tempSort = (SortT*)&temp[_numIndices*2];
|
||||||
uint32_t num = toplogyConvertTriListToLineList(_dst, _dstSize, _indices, _numIndices, temp, tempSort);
|
uint32_t num = topologyConvertTriListToLineList(_dst, _dstSize, _indices, _numIndices, temp, tempSort);
|
||||||
BX_FREE(_allocator, temp);
|
BX_FREE(_allocator, temp);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename IndexT>
|
template<typename IndexT>
|
||||||
static uint32_t toplogyConvertTriStripToTriList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
static uint32_t topologyConvertTriStripToTriList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
||||||
{
|
{
|
||||||
IndexT* dst = (IndexT*)_dst;
|
IndexT* dst = (IndexT*)_dst;
|
||||||
IndexT* end = &dst[_dstSize/sizeof(IndexT)];
|
IndexT* end = &dst[_dstSize/sizeof(IndexT)];
|
||||||
|
@ -141,7 +141,7 @@ namespace bgfx
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename IndexT>
|
template<typename IndexT>
|
||||||
static uint32_t toplogyConvertLineStripToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
static uint32_t topologyConvertLineStripToLineList(void* _dst, uint32_t _dstSize, const IndexT* _indices, uint32_t _numIndices)
|
||||||
{
|
{
|
||||||
IndexT* dst = (IndexT*)_dst;
|
IndexT* dst = (IndexT*)_dst;
|
||||||
IndexT* end = &dst[_dstSize/sizeof(IndexT)];
|
IndexT* end = &dst[_dstSize/sizeof(IndexT)];
|
||||||
|
@ -164,25 +164,25 @@ namespace bgfx
|
||||||
return uint32_t(dst - (IndexT*)_dst);
|
return uint32_t(dst - (IndexT*)_dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t toplogyConvert(TopologyConvert::Enum _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32, bx::AllocatorI* _allocator)
|
uint32_t topologyConvert(TopologyConvert::Enum _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32, bx::AllocatorI* _allocator)
|
||||||
{
|
{
|
||||||
switch (_conversion)
|
switch (_conversion)
|
||||||
{
|
{
|
||||||
case TopologyConvert::TriStripToTriList:
|
case TopologyConvert::TriStripToTriList:
|
||||||
if (_index32)
|
if (_index32)
|
||||||
{
|
{
|
||||||
return toplogyConvertTriStripToTriList(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
return topologyConvertTriStripToTriList(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toplogyConvertTriStripToTriList(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
return topologyConvertTriStripToTriList(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
||||||
|
|
||||||
case TopologyConvert::TriListFlipWinding:
|
case TopologyConvert::TriListFlipWinding:
|
||||||
if (_index32)
|
if (_index32)
|
||||||
{
|
{
|
||||||
return toplogyConvertTriListFlipWinding(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
return topologyConvertTriListFlipWinding(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toplogyConvertTriListFlipWinding(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
return topologyConvertTriListFlipWinding(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
||||||
|
|
||||||
case TopologyConvert::TriListToLineList:
|
case TopologyConvert::TriListToLineList:
|
||||||
if (NULL == _allocator)
|
if (NULL == _allocator)
|
||||||
|
@ -192,18 +192,18 @@ namespace bgfx
|
||||||
|
|
||||||
if (_index32)
|
if (_index32)
|
||||||
{
|
{
|
||||||
return toplogyConvertTriListToLineList<uint32_t, uint64_t>(_dst, _dstSize, (const uint32_t*)_indices, _numIndices, _allocator);
|
return topologyConvertTriListToLineList<uint32_t, uint64_t>(_dst, _dstSize, (const uint32_t*)_indices, _numIndices, _allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toplogyConvertTriListToLineList<uint16_t, uint32_t>(_dst, _dstSize, (const uint16_t*)_indices, _numIndices, _allocator);
|
return topologyConvertTriListToLineList<uint16_t, uint32_t>(_dst, _dstSize, (const uint16_t*)_indices, _numIndices, _allocator);
|
||||||
|
|
||||||
case TopologyConvert::LineStripToLineList:
|
case TopologyConvert::LineStripToLineList:
|
||||||
if (_index32)
|
if (_index32)
|
||||||
{
|
{
|
||||||
return toplogyConvertLineStripToLineList(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
return topologyConvertLineStripToLineList(_dst, _dstSize, (const uint32_t*)_indices, _numIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
return toplogyConvertLineStripToLineList(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
return topologyConvertLineStripToLineList(_dst, _dstSize, (const uint16_t*)_indices, _numIndices);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,18 +25,21 @@ namespace bgfx
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Converts topology from triangle list to line list.
|
/// Convert index buffer for use with different primitive topologies.
|
||||||
///
|
///
|
||||||
/// @param[in] _conversion
|
/// @param[in] _conversion Conversion type, see `TopologyConvert::Enum`.
|
||||||
/// @param[in] _dst
|
/// @param[in] _dst Destination index buffer. If this argument it NULL
|
||||||
/// @param[in] _dstSize
|
/// function will return number of indices after conversion.
|
||||||
/// @param[in] _indices
|
/// @param[in] _dstSize Destination index buffer in bytes. It must be
|
||||||
/// @param[in] _numIndices
|
/// large enough to contain output indices. If destionation size is
|
||||||
/// @param[in] _index32
|
/// insufficent index buffer will be truncated.
|
||||||
|
/// @param[in] _indices Source indices.
|
||||||
|
/// @param[in] _numIndices Number of input indices.
|
||||||
|
/// @param[in] _index32 Set to `true` if input indices are 32-bit.
|
||||||
///
|
///
|
||||||
/// @returns
|
/// @returns Number of output indices after conversion.
|
||||||
///
|
///
|
||||||
uint32_t toplogyConvert(TopologyConvert::Enum _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32, bx::AllocatorI* _allocator);
|
uint32_t topologyConvert(TopologyConvert::Enum _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32, bx::AllocatorI* _allocator);
|
||||||
|
|
||||||
} // namespace bgfx
|
} // namespace bgfx
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue