Skip to content

Commit

Permalink
update bgfx to API 127, update playrho.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Apr 23, 2024
1 parent 8aadfc4 commit 82de49e
Show file tree
Hide file tree
Showing 70 changed files with 421 additions and 383 deletions.
1 change: 0 additions & 1 deletion Project/Android/Dora/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ add_library(main SHARED
src/main/cpp/3rdParty/playrho/d2/DynamicTree.cpp
src/main/cpp/3rdParty/playrho/d2/DistanceProxy.cpp
src/main/cpp/3rdParty/playrho/d2/RopeJointConf.cpp
src/main/cpp/3rdParty/playrho/d2/ClipList.cpp
src/main/cpp/3rdParty/playrho/d2/WorldContact.cpp
src/main/cpp/3rdParty/playrho/d2/WorldBody.cpp
src/main/cpp/3rdParty/playrho/d2/TimeOfImpact.cpp
Expand Down
1 change: 0 additions & 1 deletion Project/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ add_executable(dora-ssr
../../Source/3rdParty/playrho/d2/DynamicTree.cpp
../../Source/3rdParty/playrho/d2/DistanceProxy.cpp
../../Source/3rdParty/playrho/d2/RopeJointConf.cpp
../../Source/3rdParty/playrho/d2/ClipList.cpp
../../Source/3rdParty/playrho/d2/WorldContact.cpp
../../Source/3rdParty/playrho/d2/WorldBody.cpp
../../Source/3rdParty/playrho/d2/TimeOfImpact.cpp
Expand Down
5 changes: 0 additions & 5 deletions Project/Windows/Dora/Dora.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\Source\3rdParty\playrho\d2\ClipList.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\Source\3rdParty\playrho\d2\CodeDumper.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
Expand Down Expand Up @@ -1508,7 +1504,6 @@
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\BodyConf.hpp" />
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\BodyConstraint.hpp" />
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\ChainShapeConf.hpp" />
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\ClipList.hpp" />
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\CodeDumper.hpp" />
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\ContactImpulsesFunction.hpp" />
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\ContactImpulsesList.hpp" />
Expand Down
6 changes: 0 additions & 6 deletions Project/Windows/Dora/Dora.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1299,9 +1299,6 @@
<ClCompile Include="..\..\..\Source\3rdParty\playrho\d2\ChainShapeConf.cpp">
<Filter>3rdParty\playrho\d2</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Source\3rdParty\playrho\d2\ClipList.cpp">
<Filter>3rdParty\playrho\d2</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Source\3rdParty\playrho\d2\CodeDumper.cpp">
<Filter>3rdParty\playrho\d2</Filter>
</ClCompile>
Expand Down Expand Up @@ -2864,9 +2861,6 @@
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\ChainShapeConf.hpp">
<Filter>3rdParty\playrho\d2</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\ClipList.hpp">
<Filter>3rdParty\playrho\d2</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\3rdParty\playrho\d2\CodeDumper.hpp">
<Filter>3rdParty\playrho\d2</Filter>
</ClInclude>
Expand Down
8 changes: 0 additions & 8 deletions Project/iOS/Dora.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@
3CA7802D2AE66FB000B7BADA /* DistanceProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F542AE66FAD00B7BADA /* DistanceProxy.cpp */; };
3CA7802E2AE66FB000B7BADA /* RopeJointConf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F552AE66FAD00B7BADA /* RopeJointConf.cpp */; };
3CA7802F2AE66FB000B7BADA /* RopeJointConf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F552AE66FAD00B7BADA /* RopeJointConf.cpp */; };
3CA780302AE66FB000B7BADA /* ClipList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F562AE66FAD00B7BADA /* ClipList.cpp */; };
3CA780312AE66FB000B7BADA /* ClipList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F562AE66FAD00B7BADA /* ClipList.cpp */; };
3CA780322AE66FB000B7BADA /* WorldContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F572AE66FAD00B7BADA /* WorldContact.cpp */; };
3CA780332AE66FB000B7BADA /* WorldContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F572AE66FAD00B7BADA /* WorldContact.cpp */; };
3CA780342AE66FB000B7BADA /* WorldBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77F5B2AE66FAD00B7BADA /* WorldBody.cpp */; };
Expand Down Expand Up @@ -1422,7 +1420,6 @@
3CA77F532AE66FAD00B7BADA /* WorldManifold.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldManifold.hpp; sourceTree = "<group>"; };
3CA77F542AE66FAD00B7BADA /* DistanceProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DistanceProxy.cpp; sourceTree = "<group>"; };
3CA77F552AE66FAD00B7BADA /* RopeJointConf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RopeJointConf.cpp; sourceTree = "<group>"; };
3CA77F562AE66FAD00B7BADA /* ClipList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipList.cpp; sourceTree = "<group>"; };
3CA77F572AE66FAD00B7BADA /* WorldContact.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorldContact.cpp; sourceTree = "<group>"; };
3CA77F582AE66FAD00B7BADA /* Velocity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Velocity.hpp; sourceTree = "<group>"; };
3CA77F592AE66FAD00B7BADA /* ConvexHull.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConvexHull.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1458,7 +1455,6 @@
3CA77F772AE66FAD00B7BADA /* WorldConf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldConf.hpp; sourceTree = "<group>"; };
3CA77F782AE66FAD00B7BADA /* WorldContact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldContact.hpp; sourceTree = "<group>"; };
3CA77F792AE66FAD00B7BADA /* RopeJointConf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RopeJointConf.hpp; sourceTree = "<group>"; };
3CA77F7A2AE66FAD00B7BADA /* ClipList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ClipList.hpp; sourceTree = "<group>"; };
3CA77F7B2AE66FAD00B7BADA /* ConvexHull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvexHull.cpp; sourceTree = "<group>"; };
3CA77F7C2AE66FAD00B7BADA /* Velocity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Velocity.cpp; sourceTree = "<group>"; };
3CA77F7D2AE66FAD00B7BADA /* BodyConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BodyConstraint.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3062,7 +3058,6 @@
3CA77F532AE66FAD00B7BADA /* WorldManifold.hpp */,
3CA77F542AE66FAD00B7BADA /* DistanceProxy.cpp */,
3CA77F552AE66FAD00B7BADA /* RopeJointConf.cpp */,
3CA77F562AE66FAD00B7BADA /* ClipList.cpp */,
3CA77F572AE66FAD00B7BADA /* WorldContact.cpp */,
3CA77F582AE66FAD00B7BADA /* Velocity.hpp */,
3CA77F592AE66FAD00B7BADA /* ConvexHull.hpp */,
Expand Down Expand Up @@ -3098,7 +3093,6 @@
3CA77F772AE66FAD00B7BADA /* WorldConf.hpp */,
3CA77F782AE66FAD00B7BADA /* WorldContact.hpp */,
3CA77F792AE66FAD00B7BADA /* RopeJointConf.hpp */,
3CA77F7A2AE66FAD00B7BADA /* ClipList.hpp */,
3CA77F7B2AE66FAD00B7BADA /* ConvexHull.cpp */,
3CA77F7C2AE66FAD00B7BADA /* Velocity.cpp */,
3CA77F7D2AE66FAD00B7BADA /* BodyConstraint.hpp */,
Expand Down Expand Up @@ -3972,7 +3966,6 @@
3CA780772AE66FB000B7BADA /* StatsResource.cpp in Sources */,
3C6E8024272A404A00E9F115 /* soloud_openmpt.cpp in Sources */,
3CFEA159285B873B002D106F /* m3_code.c in Sources */,
3CA780312AE66FB000B7BADA /* ClipList.cpp in Sources */,
3CFEA15D285B873B002D106F /* m3_module.c in Sources */,
3CF110052874C81C00940268 /* BoneData.cpp in Sources */,
3CA7807D2AE66FB000B7BADA /* ConstraintSolverConf.cpp in Sources */,
Expand Down Expand Up @@ -4403,7 +4396,6 @@
3CA780762AE66FB000B7BADA /* StatsResource.cpp in Sources */,
3C5399F62998DEF800E9125C /* ljson.c in Sources */,
3C4BC6681E17F1B500292200 /* tolua_push.cpp in Sources */,
3CA780302AE66FB000B7BADA /* ClipList.cpp in Sources */,
3CF10FC62874C81C00940268 /* PathConstraintData.cpp in Sources */,
3CD3284A1E4C431B0036906C /* TouchDispather.cpp in Sources */,
3CA7807C2AE66FB000B7BADA /* ConstraintSolverConf.cpp in Sources */,
Expand Down
6 changes: 0 additions & 6 deletions Project/macOS/Dora.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
3CA77EF22AE665C100B7BADA /* DynamicTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E502AE665C000B7BADA /* DynamicTree.cpp */; };
3CA77EF32AE665C100B7BADA /* DistanceProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E522AE665C000B7BADA /* DistanceProxy.cpp */; };
3CA77EF42AE665C100B7BADA /* RopeJointConf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E532AE665C000B7BADA /* RopeJointConf.cpp */; };
3CA77EF52AE665C100B7BADA /* ClipList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E542AE665C000B7BADA /* ClipList.cpp */; };
3CA77EF62AE665C100B7BADA /* WorldContact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E552AE665C000B7BADA /* WorldContact.cpp */; };
3CA77EF72AE665C100B7BADA /* WorldBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E592AE665C000B7BADA /* WorldBody.cpp */; };
3CA77EF82AE665C100B7BADA /* TimeOfImpact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CA77E5C2AE665C000B7BADA /* TimeOfImpact.cpp */; };
Expand Down Expand Up @@ -993,7 +992,6 @@
3CA77E512AE665C000B7BADA /* WorldManifold.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldManifold.hpp; sourceTree = "<group>"; };
3CA77E522AE665C000B7BADA /* DistanceProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DistanceProxy.cpp; sourceTree = "<group>"; };
3CA77E532AE665C000B7BADA /* RopeJointConf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RopeJointConf.cpp; sourceTree = "<group>"; };
3CA77E542AE665C000B7BADA /* ClipList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipList.cpp; sourceTree = "<group>"; };
3CA77E552AE665C000B7BADA /* WorldContact.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorldContact.cpp; sourceTree = "<group>"; };
3CA77E562AE665C000B7BADA /* Velocity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Velocity.hpp; sourceTree = "<group>"; };
3CA77E572AE665C000B7BADA /* ConvexHull.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ConvexHull.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1029,7 +1027,6 @@
3CA77E752AE665C000B7BADA /* WorldConf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldConf.hpp; sourceTree = "<group>"; };
3CA77E762AE665C000B7BADA /* WorldContact.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WorldContact.hpp; sourceTree = "<group>"; };
3CA77E772AE665C000B7BADA /* RopeJointConf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RopeJointConf.hpp; sourceTree = "<group>"; };
3CA77E782AE665C000B7BADA /* ClipList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ClipList.hpp; sourceTree = "<group>"; };
3CA77E792AE665C000B7BADA /* ConvexHull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvexHull.cpp; sourceTree = "<group>"; };
3CA77E7A2AE665C000B7BADA /* Velocity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Velocity.cpp; sourceTree = "<group>"; };
3CA77E7B2AE665C000B7BADA /* BodyConstraint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BodyConstraint.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2509,7 +2506,6 @@
3CA77E512AE665C000B7BADA /* WorldManifold.hpp */,
3CA77E522AE665C000B7BADA /* DistanceProxy.cpp */,
3CA77E532AE665C000B7BADA /* RopeJointConf.cpp */,
3CA77E542AE665C000B7BADA /* ClipList.cpp */,
3CA77E552AE665C000B7BADA /* WorldContact.cpp */,
3CA77E562AE665C000B7BADA /* Velocity.hpp */,
3CA77E572AE665C000B7BADA /* ConvexHull.hpp */,
Expand Down Expand Up @@ -2545,7 +2541,6 @@
3CA77E752AE665C000B7BADA /* WorldConf.hpp */,
3CA77E762AE665C000B7BADA /* WorldContact.hpp */,
3CA77E772AE665C000B7BADA /* RopeJointConf.hpp */,
3CA77E782AE665C000B7BADA /* ClipList.hpp */,
3CA77E792AE665C000B7BADA /* ConvexHull.cpp */,
3CA77E7A2AE665C000B7BADA /* Velocity.cpp */,
3CA77E7B2AE665C000B7BADA /* BodyConstraint.hpp */,
Expand Down Expand Up @@ -3485,7 +3480,6 @@
3C1A3AF6272A850F003A2829 /* loslib.c in Sources */,
3C6E7F39272A30E700E9F115 /* soloud_speech.cpp in Sources */,
3CE9D7F51E7FC2A6003AAECB /* BodyDef.cpp in Sources */,
3CA77EF52AE665C100B7BADA /* ClipList.cpp in Sources */,
3CA77F162AE665C100B7BADA /* PoolMemoryResource.cpp in Sources */,
3CA77F1F2AE665C100B7BADA /* Math.cpp in Sources */,
3C46E8592614227300DC9D4F /* Database.cpp in Sources */,
Expand Down
27 changes: 19 additions & 8 deletions Source/3rdParty/bgfx/Header/bgfx/bgfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1053,13 +1053,16 @@ namespace bgfx
///
struct Encoder
{
/// Sets a debug marker. This allows you to group
/// graphics calls together for easy browsing in
/// graphics debugging tools.
/// Sets a debug marker. This allows you to group graphics calls together for easy
/// browsing in graphics debugging tools.
///
/// @param[in] _name Marker name.
/// @param[in] _len Marker name length (if length is INT32_MAX, it's expected that _name
/// is zero terminated string.
///
/// @attention C99's equivalent binding is `bgfx_encoder_set_marker`.
///
void setMarker(const char* _marker);
void setMarker(const char* _name, int32_t _len = INT32_MAX);

/// Set render states for draw primitive.
///
Expand Down Expand Up @@ -1547,7 +1550,7 @@ namespace bgfx
, uint32_t _start
, IndexBufferHandle _numHandle
, uint32_t _numIndex = 0
, uint16_t _numMax = UINT16_MAX
, uint32_t _numMax = UINT32_MAX
, uint32_t _depth = 0
, uint8_t _flags = BGFX_DISCARD_ALL
);
Expand Down Expand Up @@ -3337,6 +3340,8 @@ namespace bgfx
///
/// @param[in] _id View id.
/// @param[in] _name View name.
/// @param[in] _len View name length (if length is INT32_MAX, it's expected that _name
/// is zero terminated string.
///
/// @remarks
/// This is debug only feature.
Expand All @@ -3354,6 +3359,7 @@ namespace bgfx
void setViewName(
ViewId _id
, const char* _name
, int32_t _len = INT32_MAX
);

/// Set view rectangle. Draw primitive outside view will be clipped.
Expand Down Expand Up @@ -3534,11 +3540,16 @@ namespace bgfx
///
void resetView(ViewId _id);

/// Sets debug marker.
/// Sets a debug marker. This allows you to group graphics calls together for easy
/// browsing in graphics debugging tools.
///
/// @param[in] _name Marker name.
/// @param[in] _len Marker name length (if length is INT32_MAX, it's expected that _name
/// is zero terminated string.
///
/// @attention C99's equivalent binding is `bgfx_set_marker`.
///
void setMarker(const char* _marker);
void setMarker(const char* _name, int32_t _len = INT32_MAX);

/// Set render states for draw primitive.
///
Expand Down Expand Up @@ -4024,7 +4035,7 @@ namespace bgfx
, uint32_t _start
, IndexBufferHandle _numHandle
, uint32_t _numIndex = 0
, uint16_t _numMax = UINT16_MAX
, uint32_t _numMax = UINT32_MAX
, uint32_t _depth = 0
, uint8_t _flags = BGFX_DISCARD_ALL
);
Expand Down
2 changes: 1 addition & 1 deletion Source/3rdParty/bgfx/Header/bgfx/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD

#define BGFX_API_VERSION UINT32_C(125)
#define BGFX_API_VERSION UINT32_C(127)

/**
* Color RGB/alpha/depth write. When it's not specified write will be disabled.
Expand Down
13 changes: 9 additions & 4 deletions Source/3rdParty/bgfx/Header/bx/bx.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <alloca.h> // alloca
#include <stdarg.h> // va_list
#include <stddef.h> // ptrdiff_t
#include <stdint.h> // uint32_t
#include <stdlib.h> // size_t
#include <stddef.h> // ptrdiff_t

#include "platform.h"
#include "config.h"
Expand Down Expand Up @@ -214,9 +214,14 @@ namespace bx
template<typename Ty>
constexpr bool isPowerOf2(Ty _a);

/// Returns a value of type To by reinterpreting the object representation of From.
template <typename To, typename From>
constexpr To bit_cast(const From& value) noexcept;
/// Returns a value of type `Ty` by reinterpreting the object representation of `FromT`.
template <typename Ty, typename FromT>
constexpr Ty bitCast(const FromT& _from);

/// Performs `static_cast` of value `_from`, and in debug build runtime verifies/asserts
/// that the value didn't change.
template<typename Ty, typename FromT>
constexpr Ty narrowCast(const FromT& _from, Location _location = Location::current() );

/// Copy memory block.
///
Expand Down
3 changes: 2 additions & 1 deletion Source/3rdParty/bgfx/Header/bx/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#ifndef BX_DEBUG_H_HEADER_GUARD
#define BX_DEBUG_H_HEADER_GUARD

#include "bx.h"
#include <stdint.h> // uint32_t
#include <stdarg.h> // va_list

namespace bx
{
Expand Down
32 changes: 24 additions & 8 deletions Source/3rdParty/bgfx/Header/bx/inline/bx.inl
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,30 @@ namespace bx
return _a && !(_a & (_a - 1) );
}

template <typename To, typename From>
inline constexpr To bit_cast(const From& value) noexcept
{
BX_STATIC_ASSERT(sizeof(To) == sizeof(From), "To and From must be the same size.");
BX_STATIC_ASSERT(isTriviallyConstructible<To>(), "Destination target must be trivially constructible.");
To result;
bx::memCopy(&result, &value, sizeof(To));
return result;
template <typename Ty, typename FromT>
inline constexpr Ty bitCast(const FromT& _from)
{
static_assert(sizeof(Ty) == sizeof(FromT)
, "bx::bitCast failed! Ty and FromT must be the same size."
);
static_assert(isTriviallyConstructible<Ty>()
, "bx::bitCast failed! Destination target must be trivially constructible."
);

Ty to;
memCopy(&to, &_from, sizeof(Ty) );

return to;
}

template<typename Ty, typename FromT>
inline constexpr Ty narrowCast(const FromT& _from, Location _location)
{
Ty to = static_cast<Ty>(_from);
BX_ASSERT_LOC(_location, static_cast<FromT>(to) == _from
, "bx::narrowCast failed! Value is truncated!"
);
return to;
}

} // namespace bx
2 changes: 1 addition & 1 deletion Source/3rdParty/bgfx/Header/bx/inline/readerwriter.inl
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace bx
memSet(temp, _byte, blockSize);

int32_t size = 0;
while (0 < _size)
while (0 < _size && _err->isOk() )
{
int32_t bytes = write(_writer, temp, uint32_min(blockSize, _size), _err);
size += bytes;
Expand Down
Loading

0 comments on commit 82de49e

Please sign in to comment.