mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 15:43:24 +02:00
remove stubbery, make physics lib depend on model
This commit is contained in:
parent
8d3f592e68
commit
d59c997e64
4 changed files with 36 additions and 25 deletions
|
@ -130,7 +130,7 @@ protected:
|
|||
void evalVertexStream();
|
||||
|
||||
};
|
||||
typedef std::shared_ptr< Mesh > MeshPointer;
|
||||
using MeshPointer = std::shared_ptr< Mesh >;
|
||||
|
||||
|
||||
class Geometry {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set(TARGET_NAME physics)
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared fbx entities)
|
||||
link_hifi_libraries(shared fbx entities model)
|
||||
|
||||
target_bullet()
|
||||
|
|
|
@ -9,16 +9,31 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "CollisionRenderMeshCache.h"
|
||||
|
||||
#include <cassert>
|
||||
//#include <glm/gtx/norm.hpp>
|
||||
|
||||
//#include "ShapeFactory.h"
|
||||
#include "CollisionRenderMeshCache.h"
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
|
||||
int foo = 0;
|
||||
|
||||
MeshPointer createMeshFromShape(CollisionRenderMeshCache::Key key) {
|
||||
return std::make_shared<int>(++foo);
|
||||
model::MeshPointer createMeshFromShape(const btCollisionShape* shape) {
|
||||
if (!shape) {
|
||||
return std::make_shared<model::Mesh>();
|
||||
}
|
||||
int32_t shapeType = shape->getShapeType();
|
||||
if (shapeType == (int32_t)COMPOUND_SHAPE_PROXYTYPE) {
|
||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
|
||||
int32_t numSubShapes = compoundShape->getNumChildShapes();
|
||||
for (int i = 0; i < numSubShapes; ++i) {
|
||||
const btCollisionShape* childShape = compoundShape->getChildShape(i);
|
||||
std::cout << "adebug " << i << " " << (void*)(childShape) << std::endl; // adebug
|
||||
}
|
||||
} else if (shape->isConvex()) {
|
||||
std::cout << "adebug " << (void*)(shape)<< std::endl; // adebug
|
||||
}
|
||||
return std::make_shared<model::Mesh>();
|
||||
}
|
||||
|
||||
CollisionRenderMeshCache::CollisionRenderMeshCache() {
|
||||
|
@ -29,21 +44,19 @@ CollisionRenderMeshCache::~CollisionRenderMeshCache() {
|
|||
_pendingGarbage.clear();
|
||||
}
|
||||
|
||||
MeshPointer CollisionRenderMeshCache::getMesh(CollisionRenderMeshCache::Key key) {
|
||||
if (!key) {
|
||||
return MeshPointer();
|
||||
}
|
||||
MeshPointer geometry = 0;
|
||||
|
||||
CollisionMeshMap::const_iterator itr = _geometryMap.find(key);
|
||||
if (itr != _geometryMap.end()) {
|
||||
// make geometry and add it to map
|
||||
geometry = createMeshFromShape(key);
|
||||
if (geometry) {
|
||||
_geometryMap.insert(std::make_pair(key, geometry));
|
||||
model::MeshPointer CollisionRenderMeshCache::getMesh(CollisionRenderMeshCache::Key key) {
|
||||
model::MeshPointer mesh;
|
||||
if (key) {
|
||||
CollisionMeshMap::const_iterator itr = _geometryMap.find(key);
|
||||
if (itr != _geometryMap.end()) {
|
||||
// make mesh and add it to map
|
||||
mesh = createMeshFromShape(key);
|
||||
if (mesh) {
|
||||
_geometryMap.insert(std::make_pair(key, mesh));
|
||||
}
|
||||
}
|
||||
}
|
||||
return geometry;
|
||||
return mesh;
|
||||
}
|
||||
|
||||
bool CollisionRenderMeshCache::releaseMesh(CollisionRenderMeshCache::Key key) {
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
class btCollisionShape;
|
||||
#include <model/Geometry.h>
|
||||
|
||||
// BEGIN TEST HACK
|
||||
using MeshPointer = std::shared_ptr<int>;
|
||||
// END TEST HACK
|
||||
class btCollisionShape;
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
|
@ -39,7 +37,7 @@ public:
|
|||
~CollisionRenderMeshCache();
|
||||
|
||||
/// \return pointer to geometry
|
||||
MeshPointer getMesh(Key key);
|
||||
model::MeshPointer getMesh(Key key);
|
||||
|
||||
/// \return true if geometry was found and released
|
||||
bool releaseMesh(Key key);
|
||||
|
@ -52,7 +50,7 @@ public:
|
|||
bool hasMesh(Key key) const { return _geometryMap.find(key) == _geometryMap.end(); }
|
||||
|
||||
private:
|
||||
using CollisionMeshMap = std::unordered_map<Key, MeshPointer>;
|
||||
using CollisionMeshMap = std::unordered_map<Key, model::MeshPointer>;
|
||||
CollisionMeshMap _geometryMap;
|
||||
std::vector<Key> _pendingGarbage;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue