Clean up some code

Former-commit-id: 01788d37c2da84116c14d43ca318e5be4134d86f [formerly 5a4bd2b503f8ace2de3199e446123d2ebfebcc5e] [formerly e08e7b4831f4221b8a424d7a023e6e31081c2f63 [formerly 412302cba9aeeb89cb2d4b31a7b711c789ad8444]]
Former-commit-id: 09c0406c65994e0f153eb472cc715839eef33ef4 [formerly fd5a153e97d8dc353b744367571b97396eec2cf8]
Former-commit-id: ee4ef949183459a4067c5cbe2290c555c3753617
This commit is contained in:
Lynix 2016-09-04 20:40:02 +02:00
parent bcb05f13f8
commit 842063b1cd
3 changed files with 9 additions and 16 deletions

View File

@ -134,7 +134,7 @@ namespace Nz
class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom class NAZARA_PHYSICS_API CompoundGeom : public PhysGeom
{ {
public: public:
CompoundGeom(PhysGeom** geoms, unsigned int geomCount); CompoundGeom(PhysGeom** geoms, std::size_t geomCount);
const std::vector<PhysGeomRef>& GetGeoms() const; const std::vector<PhysGeomRef>& GetGeoms() const;
GeomType GetType() const override; GeomType GetType() const override;

View File

@ -56,7 +56,7 @@ namespace Nz
std::array<char, NI_MAXHOST> hostnameBuffer; std::array<char, NI_MAXHOST> hostnameBuffer;
std::array<char, NI_MAXSERV> serviceBuffer; std::array<char, NI_MAXSERV> serviceBuffer;
int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast<std::size_t>(hostnameBuffer.size()), serviceBuffer.data(), static_cast<std::size_t>(serviceBuffer.size()), flags); int result = getnameinfo(socketAddress, socketLen, hostnameBuffer.data(), static_cast<DWORD>(hostnameBuffer.size()), serviceBuffer.data(), static_cast<DWORD>(serviceBuffer.size()), flags);
if (result == 0) if (result == 0)
{ {
if (hostname) if (hostname)

View File

@ -125,16 +125,7 @@ namespace Nz
PhysGeomRef PhysGeom::Build(const PrimitiveList& list) PhysGeomRef PhysGeom::Build(const PrimitiveList& list)
{ {
unsigned int primitiveCount = list.GetSize(); std::size_t primitiveCount = list.GetSize();
#if NAZARA_PHYSICS_SAFE
if (primitiveCount == 0)
{
NazaraError("PrimitiveList must have at least one primitive");
return nullptr;
}
#endif
if (primitiveCount > 1) if (primitiveCount > 1)
{ {
std::vector<PhysGeom*> geoms(primitiveCount); std::vector<PhysGeom*> geoms(primitiveCount);
@ -144,8 +135,10 @@ namespace Nz
return CompoundGeom::New(&geoms[0], primitiveCount); return CompoundGeom::New(&geoms[0], primitiveCount);
} }
else else if (primitiveCount > 0)
return CreateGeomFromPrimitive(list.GetPrimitive(0)); return CreateGeomFromPrimitive(list.GetPrimitive(0));
else
return NullGeom::New();
} }
bool PhysGeom::Initialize() bool PhysGeom::Initialize()
@ -246,10 +239,10 @@ namespace Nz
/******************************* CompoundGeom ********************************/ /******************************* CompoundGeom ********************************/
CompoundGeom::CompoundGeom(PhysGeom** geoms, unsigned int geomCount) CompoundGeom::CompoundGeom(PhysGeom** geoms, std::size_t geomCount)
{ {
m_geoms.reserve(geomCount); m_geoms.reserve(geomCount);
for (unsigned int i = 0; i < geomCount; ++i) for (std::size_t i = 0; i < geomCount; ++i)
m_geoms.emplace_back(geoms[i]); m_geoms.emplace_back(geoms[i]);
} }
@ -349,7 +342,7 @@ namespace Nz
NewtonCollision* ConvexHullGeom::CreateHandle(PhysWorld* world) const NewtonCollision* ConvexHullGeom::CreateHandle(PhysWorld* world) const
{ {
return NewtonCreateConvexHull(world->GetHandle(), m_vertices.size(), reinterpret_cast<const float*>(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix); return NewtonCreateConvexHull(world->GetHandle(), static_cast<int>(m_vertices.size()), reinterpret_cast<const float*>(m_vertices.data()), sizeof(Vector3f), m_tolerance, 0, m_matrix);
} }
/******************************* CylinderGeom ********************************/ /******************************* CylinderGeom ********************************/