moved ShapeInfoUtil to be ShapeFactory

This commit is contained in:
Andrew Meadows 2015-05-21 15:53:16 -07:00
parent 2e3973dfdd
commit f6721aa6eb
6 changed files with 16 additions and 18 deletions

View file

@ -12,7 +12,6 @@
#include "PhysicalEntitySimulation.h" #include "PhysicalEntitySimulation.h"
#include "PhysicsHelpers.h" #include "PhysicsHelpers.h"
#include "PhysicsLogging.h" #include "PhysicsLogging.h"
#include "ShapeInfoUtil.h"
#include "ShapeManager.h" #include "ShapeManager.h"
PhysicalEntitySimulation::PhysicalEntitySimulation() { PhysicalEntitySimulation::PhysicalEntitySimulation() {

View file

@ -1,5 +1,5 @@
// //
// ShapeInfoUtil.cpp // ShapeFactory.cpp
// libraries/physcis/src // libraries/physcis/src
// //
// Created by Andrew Meadows 2014.12.01 // Created by Andrew Meadows 2014.12.01
@ -11,12 +11,12 @@
#include <SharedUtil.h> // for MILLIMETERS_PER_METER #include <SharedUtil.h> // for MILLIMETERS_PER_METER
#include "ShapeInfoUtil.h" #include "ShapeFactory.h"
#include "BulletUtil.h" #include "BulletUtil.h"
btConvexHullShape* ShapeInfoUtil::createConvexHull(const QVector<glm::vec3>& points) { btConvexHullShape* ShapeFactory::createConvexHull(const QVector<glm::vec3>& points) {
assert(points.size() > 0); assert(points.size() > 0);
btConvexHullShape* hull = new btConvexHullShape(); btConvexHullShape* hull = new btConvexHullShape();
@ -57,7 +57,7 @@ btConvexHullShape* ShapeInfoUtil::createConvexHull(const QVector<glm::vec3>& poi
return hull; return hull;
} }
btCollisionShape* ShapeInfoUtil::createShapeFromInfo(const ShapeInfo& info) { btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info) {
btCollisionShape* shape = NULL; btCollisionShape* shape = NULL;
switch(info.getType()) { switch(info.getType()) {
case SHAPE_TYPE_BOX: { case SHAPE_TYPE_BOX: {

View file

@ -1,5 +1,5 @@
// //
// ShapeInfoUtil.h // ShapeFactory.h
// libraries/physcis/src // libraries/physcis/src
// //
// Created by Andrew Meadows 2014.12.01 // Created by Andrew Meadows 2014.12.01
@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#ifndef hifi_ShapeInfoUtil_h #ifndef hifi_ShapeFactory_h
#define hifi_ShapeInfoUtil_h #define hifi_ShapeFactory_h
#include <btBulletDynamicsCommon.h> #include <btBulletDynamicsCommon.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
@ -20,11 +20,11 @@
// translates between ShapeInfo and btShape // translates between ShapeInfo and btShape
// TODO: rename this to ShapeFactory // TODO: rename this to ShapeFactory
namespace ShapeInfoUtil { namespace ShapeFactory {
btConvexHullShape* createConvexHull(const QVector<glm::vec3>& points); btConvexHullShape* createConvexHull(const QVector<glm::vec3>& points);
btCollisionShape* createShapeFromInfo(const ShapeInfo& info); btCollisionShape* createShapeFromInfo(const ShapeInfo& info);
}; };
#endif // hifi_ShapeInfoUtil_h #endif // hifi_ShapeFactory_h

View file

@ -13,7 +13,7 @@
#include <glm/gtx/norm.hpp> #include <glm/gtx/norm.hpp>
#include "ShapeInfoUtil.h" #include "ShapeFactory.h"
#include "ShapeManager.h" #include "ShapeManager.h"
ShapeManager::ShapeManager() { ShapeManager::ShapeManager() {
@ -46,7 +46,7 @@ btCollisionShape* ShapeManager::getShape(const ShapeInfo& info) {
shapeRef->refCount++; shapeRef->refCount++;
return shapeRef->shape; return shapeRef->shape;
} }
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info); btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
if (shape) { if (shape) {
ShapeReference newRef; ShapeReference newRef;
newRef.refCount = 1; newRef.refCount = 1;

View file

@ -16,7 +16,7 @@
#include <DoubleHashKey.h> #include <DoubleHashKey.h>
#include <ShapeInfo.h> #include <ShapeInfo.h>
#include <ShapeInfoUtil.h> #include <ShapeFactory.h>
#include <StreamUtils.h> #include <StreamUtils.h>
#include "ShapeInfoTests.h" #include "ShapeInfoTests.h"
@ -142,7 +142,7 @@ void ShapeInfoTests::testBoxShape() {
info.setBox(halfExtents); info.setBox(halfExtents);
DoubleHashKey key = info.getHash(); DoubleHashKey key = info.getHash();
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info); btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
if (!shape) { if (!shape) {
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: NULL Box shape" << std::endl; std::cout << __FILE__ << ":" << __LINE__ << " ERROR: NULL Box shape" << std::endl;
} }
@ -168,7 +168,7 @@ void ShapeInfoTests::testSphereShape() {
info.setSphere(radius); info.setSphere(radius);
DoubleHashKey key = info.getHash(); DoubleHashKey key = info.getHash();
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info); btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
ShapeInfo otherInfo = info; ShapeInfo otherInfo = info;
DoubleHashKey otherKey = otherInfo.getHash(); DoubleHashKey otherKey = otherInfo.getHash();
@ -192,7 +192,7 @@ void ShapeInfoTests::testCylinderShape() {
info.setCylinder(radius, height); info.setCylinder(radius, height);
DoubleHashKey key = info.getHash(); DoubleHashKey key = info.getHash();
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info); btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
ShapeInfo otherInfo = info; ShapeInfo otherInfo = info;
DoubleHashKey otherKey = otherInfo.getHash(); DoubleHashKey otherKey = otherInfo.getHash();
@ -217,7 +217,7 @@ void ShapeInfoTests::testCapsuleShape() {
info.setCapsule(radius, height); info.setCapsule(radius, height);
DoubleHashKey key = info.getHash(); DoubleHashKey key = info.getHash();
btCollisionShape* shape = ShapeInfoUtil::createShapeFromInfo(info); btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
ShapeInfo otherInfo = info; ShapeInfo otherInfo = info;
DoubleHashKey otherKey = otherInfo.getHash(); DoubleHashKey otherKey = otherInfo.getHash();

View file

@ -10,7 +10,6 @@
// //
#include <iostream> #include <iostream>
#include <ShapeInfoUtil.h>
#include <ShapeManager.h> #include <ShapeManager.h>
#include <StreamUtils.h> #include <StreamUtils.h>