Clean up some code

Former-commit-id: d1d166225cc95474130e59645f9397b6a4130267 [formerly 10b948f0d7e08992d86cecb54a1931de50d0abd4] [formerly a23d07003f7c7583a900b532119d9402a77b1830 [formerly 8418fb742937775772c79e6546b617382f0cb22a]]
Former-commit-id: e628a175a930f2390cedfd3b26831826514b265f [formerly fa8c6a19f29e64e4cd90b212e01a5acf97f1740f]
Former-commit-id: 795328aea7f39068b6575c948b5c51fc5adf9f12
This commit is contained in:
Lynix 2016-09-04 20:40:02 +02:00
parent 68d67cc9da
commit 8a36442c38
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 ********************************/