[DEV] continue removing stl
This commit is contained in:
parent
8b4f2f2865
commit
d22ad84b61
@ -168,7 +168,7 @@ void CollisionDetection::computeNarrowPhase() {
|
||||
(shape1->getCollisionCategoryBits() & shape2->getCollideWithMaskBits()) == 0) ||
|
||||
!m_broadPhaseAlgorithm.testOverlappingShapes(shape1, shape2)) {
|
||||
|
||||
std::map<overlappingpairid, OverlappingPair*>::iterator itToRemove = it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::iterator itToRemove = it;
|
||||
++it;
|
||||
|
||||
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
||||
@ -271,7 +271,7 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* call
|
||||
(shape1->getCollisionCategoryBits() & shape2->getCollideWithMaskBits()) == 0) ||
|
||||
!m_broadPhaseAlgorithm.testOverlappingShapes(shape1, shape2)) {
|
||||
|
||||
std::map<overlappingpairid, OverlappingPair*>::iterator itToRemove = it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::iterator itToRemove = it;
|
||||
++it;
|
||||
|
||||
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
||||
@ -357,7 +357,7 @@ void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* shape1, Pro
|
||||
assert(newPair != NULL);
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::pair<map<overlappingpairid, OverlappingPair*>::iterator, bool> check =
|
||||
etk::Pair<map<overlappingpairid, OverlappingPair*>::iterator, bool> check =
|
||||
#endif
|
||||
m_overlappingPairs.insert(make_pair(pairID, newPair));
|
||||
assert(check.second);
|
||||
@ -371,11 +371,11 @@ void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* shape1, Pro
|
||||
void CollisionDetection::removeProxyCollisionShape(ProxyShape* proxyShape) {
|
||||
|
||||
// Remove all the overlapping pairs involving this proxy shape
|
||||
std::map<overlappingpairid, OverlappingPair*>::iterator it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::iterator it;
|
||||
for (it = m_overlappingPairs.begin(); it != m_overlappingPairs.end(); ) {
|
||||
if (it->second->getShape1()->m_broadPhaseID == proxyShape->m_broadPhaseID||
|
||||
it->second->getShape2()->m_broadPhaseID == proxyShape->m_broadPhaseID) {
|
||||
std::map<overlappingpairid, OverlappingPair*>::iterator itToRemove = it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::iterator itToRemove = it;
|
||||
++it;
|
||||
|
||||
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
||||
@ -431,7 +431,7 @@ void CollisionDetection::createContact(OverlappingPair* overlappingPair,
|
||||
void CollisionDetection::addAllContactManifoldsToBodies() {
|
||||
|
||||
// For each overlapping pairs in contact during the narrow-phase
|
||||
std::map<overlappingpairid, OverlappingPair*>::iterator it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::iterator it;
|
||||
for (it = m_contactOverlappingPairs.begin(); it != m_contactOverlappingPairs.end(); ++it) {
|
||||
|
||||
// Add all the contact manifolds of the pair int32_to the list of contact manifolds
|
||||
@ -479,7 +479,7 @@ void CollisionDetection::addContactManifoldToBody(OverlappingPair* pair) {
|
||||
void CollisionDetection::clearContactPoints() {
|
||||
|
||||
// For each overlapping pair
|
||||
std::map<overlappingpairid, OverlappingPair*>::iterator it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::iterator it;
|
||||
for (it = m_overlappingPairs.begin(); it != m_overlappingPairs.end(); ++it) {
|
||||
it->second->clearContactPoints();
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include <ephysics/collision/narrowphase/DefaultCollisionDispatch.hpp>
|
||||
#include <ephysics/memory/MemoryAllocator.hpp>
|
||||
#include <ephysics/constraint/ContactPoint.hpp>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
@ -51,8 +51,8 @@ namespace ephysics {
|
||||
NarrowPhaseAlgorithm* m_collisionMatrix[NB_COLLISION_SHAPE_TYPES][NB_COLLISION_SHAPE_TYPES]; //!< Collision detection matrix (algorithms to use)
|
||||
MemoryAllocator& m_memoryAllocator; //!< Reference to the memory allocator
|
||||
CollisionWorld* m_world; //!< Pointer to the physics world
|
||||
std::map<overlappingpairid, OverlappingPair*> m_overlappingPairs; //!< Broad-phase overlapping pairs
|
||||
std::map<overlappingpairid, OverlappingPair*> m_contactOverlappingPairs; //!< Overlapping pairs in contact (during the current Narrow-phase collision detection)
|
||||
etk::Map<overlappingpairid, OverlappingPair*> m_overlappingPairs; //!< Broad-phase overlapping pairs
|
||||
etk::Map<overlappingpairid, OverlappingPair*> m_contactOverlappingPairs; //!< Overlapping pairs in contact (during the current Narrow-phase collision detection)
|
||||
BroadPhaseAlgorithm m_broadPhaseAlgorithm; //!< Broad-phase algorithm
|
||||
// TODO : Delete this
|
||||
GJKAlgorithm m_narrowPhaseGJKAlgorithm; //!< Narrow-phase GJK algorithm
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <ephysics/body/CollisionBody.hpp>
|
||||
#include <ephysics/collision/ProxyShape.hpp>
|
||||
#include <ephysics/constraint/ContactPoint.hpp>
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license BSD 3 clauses (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <cassert>
|
||||
#include <ephysics/collision/TriangleVertexArray.hpp>
|
||||
|
||||
@ -18,7 +18,7 @@ namespace ephysics {
|
||||
*/
|
||||
class TriangleMesh {
|
||||
protected:
|
||||
std::vector<TriangleVertexArray*> m_triangleArrays; //!< All the triangle arrays of the mesh (one triangle array per part)
|
||||
etk::Vector<TriangleVertexArray*> m_triangleArrays; //!< All the triangle arrays of the mesh (one triangle array per part)
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -32,7 +32,7 @@ namespace ephysics {
|
||||
* @brief Add a subpart of the mesh
|
||||
*/
|
||||
void addSubpart(TriangleVertexArray* _triangleVertexArray) {
|
||||
m_triangleArrays.push_back(_triangleVertexArray );
|
||||
m_triangleArrays.pushBack(_triangleVertexArray );
|
||||
}
|
||||
/**
|
||||
* @brief Get a pointer to a given subpart (triangle vertex array) of the mesh
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <ephysics/collision/TriangleVertexArray.hpp>
|
||||
|
||||
|
||||
ephysics::TriangleVertexArray::TriangleVertexArray(const std::vector<vec3>& _vertices, std::vector<size_t> _triangles):
|
||||
ephysics::TriangleVertexArray::TriangleVertexArray(const etk::Vector<vec3>& _vertices, etk::Vector<size_t> _triangles):
|
||||
m_vertices(_vertices),
|
||||
m_triangles(_triangles) {
|
||||
|
||||
@ -22,11 +22,11 @@ size_t ephysics::TriangleVertexArray::getNbTriangles() const {
|
||||
return m_triangles.size()/3;
|
||||
}
|
||||
|
||||
const std::vector<vec3>& ephysics::TriangleVertexArray::getVertices() const {
|
||||
const etk::Vector<vec3>& ephysics::TriangleVertexArray::getVertices() const {
|
||||
return m_vertices;
|
||||
}
|
||||
|
||||
const std::vector<size_t>& ephysics::TriangleVertexArray::getIndices() const{
|
||||
const etk::Vector<size_t>& ephysics::TriangleVertexArray::getIndices() const{
|
||||
return m_triangles;
|
||||
}
|
||||
|
||||
|
@ -27,16 +27,16 @@ namespace ephysics {
|
||||
*/
|
||||
class TriangleVertexArray {
|
||||
protected:
|
||||
std::vector<vec3> m_vertices; //!< Vertice list
|
||||
std::vector<size_t> m_triangles; //!< List of triangle (3 pos for each triangle)
|
||||
etk::Vector<vec3> m_vertices; //!< Vertice list
|
||||
etk::Vector<size_t> m_triangles; //!< List of triangle (3 pos for each triangle)
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] _vertices List Of all vertices
|
||||
* @param[in] _triangles List of all linked points
|
||||
*/
|
||||
TriangleVertexArray(const std::vector<vec3>& _vertices,
|
||||
std::vector<size_t> _triangles);
|
||||
TriangleVertexArray(const etk::Vector<vec3>& _vertices,
|
||||
etk::Vector<size_t> _triangles);
|
||||
/**
|
||||
* @brief Get the number of vertices
|
||||
* @return Number of vertices
|
||||
@ -51,12 +51,12 @@ namespace ephysics {
|
||||
* @brief Get The table of the vertices
|
||||
* @return reference on the vertices
|
||||
*/
|
||||
const std::vector<vec3>& getVertices() const;
|
||||
const etk::Vector<vec3>& getVertices() const;
|
||||
/**
|
||||
* @brief Get The table of the triangle indice
|
||||
* @return reference on the triangle indice
|
||||
*/
|
||||
const std::vector<size_t>& getIndices() const;
|
||||
const etk::Vector<size_t>& getIndices() const;
|
||||
/**
|
||||
* @brief Get a triangle at the specific ID
|
||||
* @return Buffer of 3 points
|
||||
|
@ -225,8 +225,8 @@ void BroadPhaseAlgorithm::notifyOverlappingNodes(int32_t node1ID, int32_t node2I
|
||||
}
|
||||
|
||||
// Add the new potential pair int32_to the array of potential overlapping pairs
|
||||
m_potentialPairs[m_numberPotentialPairs].collisionShape1ID = std::min(node1ID, node2ID);
|
||||
m_potentialPairs[m_numberPotentialPairs].collisionShape2ID = std::max(node1ID, node2ID);
|
||||
m_potentialPairs[m_numberPotentialPairs].collisionShape1ID = etk::min(node1ID, node2ID);
|
||||
m_potentialPairs[m_numberPotentialPairs].collisionShape2ID = etk::max(node1ID, node2ID);
|
||||
m_numberPotentialPairs++;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <ephysics/body/CollisionBody.hpp>
|
||||
#include <ephysics/collision/ProxyShape.hpp>
|
||||
#include <ephysics/collision/broadphase/DynamicAABBTree.hpp>
|
||||
|
@ -314,7 +314,7 @@ void DynamicAABBTree::insertLeafNode(int32_t _nodeID) {
|
||||
assert(rightChild != TreeNode::NULL_TREE_NODE);
|
||||
|
||||
// Recompute the height of the node in the tree
|
||||
m_nodes[currentNodeID].height = std::max(m_nodes[leftChild].height,
|
||||
m_nodes[currentNodeID].height = etk::max(m_nodes[leftChild].height,
|
||||
m_nodes[rightChild].height) + 1;
|
||||
assert(m_nodes[currentNodeID].height > 0);
|
||||
|
||||
@ -380,7 +380,7 @@ void DynamicAABBTree::removeLeafNode(int32_t _nodeID) {
|
||||
// Recompute the AABB and the height of the current node
|
||||
m_nodes[currentNodeID].aabb.mergeTwoAABBs(m_nodes[leftChildID].aabb,
|
||||
m_nodes[rightChildID].aabb);
|
||||
m_nodes[currentNodeID].height = std::max(m_nodes[leftChildID].height,
|
||||
m_nodes[currentNodeID].height = etk::max(m_nodes[leftChildID].height,
|
||||
m_nodes[rightChildID].height) + 1;
|
||||
assert(m_nodes[currentNodeID].height > 0);
|
||||
|
||||
@ -468,8 +468,8 @@ int32_t DynamicAABBTree::balanceSubTreeAtNode(int32_t _nodeID) {
|
||||
nodeC->aabb.mergeTwoAABBs(nodeA->aabb, nodeF->aabb);
|
||||
|
||||
// Recompute the height of node A and C
|
||||
nodeA->height = std::max(nodeB->height, nodeG->height) + 1;
|
||||
nodeC->height = std::max(nodeA->height, nodeF->height) + 1;
|
||||
nodeA->height = etk::max(nodeB->height, nodeG->height) + 1;
|
||||
nodeC->height = etk::max(nodeA->height, nodeF->height) + 1;
|
||||
assert(nodeA->height > 0);
|
||||
assert(nodeC->height > 0);
|
||||
}
|
||||
@ -483,8 +483,8 @@ int32_t DynamicAABBTree::balanceSubTreeAtNode(int32_t _nodeID) {
|
||||
nodeC->aabb.mergeTwoAABBs(nodeA->aabb, nodeG->aabb);
|
||||
|
||||
// Recompute the height of node A and C
|
||||
nodeA->height = std::max(nodeB->height, nodeF->height) + 1;
|
||||
nodeC->height = std::max(nodeA->height, nodeG->height) + 1;
|
||||
nodeA->height = etk::max(nodeB->height, nodeF->height) + 1;
|
||||
nodeC->height = etk::max(nodeA->height, nodeG->height) + 1;
|
||||
assert(nodeA->height > 0);
|
||||
assert(nodeC->height > 0);
|
||||
}
|
||||
@ -538,8 +538,8 @@ int32_t DynamicAABBTree::balanceSubTreeAtNode(int32_t _nodeID) {
|
||||
nodeB->aabb.mergeTwoAABBs(nodeA->aabb, nodeF->aabb);
|
||||
|
||||
// Recompute the height of node A and B
|
||||
nodeA->height = std::max(nodeC->height, nodeG->height) + 1;
|
||||
nodeB->height = std::max(nodeA->height, nodeF->height) + 1;
|
||||
nodeA->height = etk::max(nodeC->height, nodeG->height) + 1;
|
||||
nodeB->height = etk::max(nodeA->height, nodeF->height) + 1;
|
||||
assert(nodeA->height > 0);
|
||||
assert(nodeB->height > 0);
|
||||
}
|
||||
@ -553,8 +553,8 @@ int32_t DynamicAABBTree::balanceSubTreeAtNode(int32_t _nodeID) {
|
||||
nodeB->aabb.mergeTwoAABBs(nodeA->aabb, nodeG->aabb);
|
||||
|
||||
// Recompute the height of node A and B
|
||||
nodeA->height = std::max(nodeC->height, nodeF->height) + 1;
|
||||
nodeB->height = std::max(nodeA->height, nodeG->height) + 1;
|
||||
nodeA->height = etk::max(nodeC->height, nodeF->height) + 1;
|
||||
nodeB->height = etk::max(nodeA->height, nodeG->height) + 1;
|
||||
assert(nodeA->height > 0);
|
||||
assert(nodeB->height > 0);
|
||||
}
|
||||
@ -781,7 +781,7 @@ void DynamicAABBTree::checkNode(int32_t _nodeID) const {
|
||||
assert(m_nodes[rightChild].parentID == _nodeID);
|
||||
|
||||
// Check the height of node
|
||||
int32_t height = 1 + std::max(m_nodes[leftChild].height, m_nodes[rightChild].height);
|
||||
int32_t height = 1 + etk::max(m_nodes[leftChild].height, m_nodes[rightChild].height);
|
||||
assert(m_nodes[_nodeID].height == height);
|
||||
|
||||
// Check the AABB of the node
|
||||
@ -816,7 +816,7 @@ int32_t DynamicAABBTree::computeHeight(int32_t _nodeID) {
|
||||
int32_t rightHeight = computeHeight(node->children[1]);
|
||||
|
||||
// Return the height of the node
|
||||
return 1 + std::max(leftHeight, rightHeight);
|
||||
return 1 + etk::max(leftHeight, rightHeight);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -63,7 +63,7 @@ void ConcaveVsConvexAlgorithm::testCollision(const CollisionShapeInfo& shape1Inf
|
||||
// If smooth mesh collision is enabled for the concave mesh
|
||||
if (concaveShape->getIsSmoothMeshCollisionEnabled()) {
|
||||
|
||||
std::vector<SmoothMeshContactInfo> contactPoints;
|
||||
etk::Vector<SmoothMeshContactInfo> contactPoints;
|
||||
|
||||
SmoothCollisionNarrowPhaseCallback smoothNarrowPhaseCallback(contactPoints);
|
||||
|
||||
@ -116,7 +116,7 @@ void ConvexVsTriangleCallback::testTriangle(const vec3* trianglePoints) {
|
||||
// by Pierre Terdiman (http://www.codercorner.com/MeshContacts.pdf). This is used to avoid the collision
|
||||
// issue with some int32_ternal edges.
|
||||
void ConcaveVsConvexAlgorithm::processSmoothMeshCollision(OverlappingPair* overlappingPair,
|
||||
std::vector<SmoothMeshContactInfo> contactPoints,
|
||||
etk::Vector<SmoothMeshContactInfo> contactPoints,
|
||||
NarrowPhaseCallback* narrowPhaseCallback) {
|
||||
|
||||
// Set with the triangle vertices already processed to void further contacts with same triangle
|
||||
@ -126,7 +126,7 @@ void ConcaveVsConvexAlgorithm::processSmoothMeshCollision(OverlappingPair* overl
|
||||
std::sort(contactPoints.begin(), contactPoints.end(), ContactsDepthCompare());
|
||||
|
||||
// For each contact point (from smaller penetration depth to larger)
|
||||
std::vector<SmoothMeshContactInfo>::const_iterator it;
|
||||
etk::Vector<SmoothMeshContactInfo>::const_iterator it;
|
||||
for (it = contactPoints.begin(); it != contactPoints.end(); ++it) {
|
||||
|
||||
const SmoothMeshContactInfo info = *it;
|
||||
@ -268,5 +268,5 @@ void SmoothCollisionNarrowPhaseCallback::notifyContact(OverlappingPair* overlapp
|
||||
|
||||
// Add the narrow-phase contact int32_to the list of contact to process for
|
||||
// smooth mesh collision
|
||||
m_contactPoints.push_back(smoothContactInfo);
|
||||
m_contactPoints.pushBack(smoothContactInfo);
|
||||
}
|
||||
|
@ -94,10 +94,10 @@ namespace ephysics {
|
||||
*/
|
||||
class SmoothCollisionNarrowPhaseCallback : public NarrowPhaseCallback {
|
||||
private:
|
||||
std::vector<SmoothMeshContactInfo>& m_contactPoints;
|
||||
etk::Vector<SmoothMeshContactInfo>& m_contactPoints;
|
||||
public:
|
||||
// Constructor
|
||||
SmoothCollisionNarrowPhaseCallback(std::vector<SmoothMeshContactInfo>& _contactPoints):
|
||||
SmoothCollisionNarrowPhaseCallback(etk::Vector<SmoothMeshContactInfo>& _contactPoints):
|
||||
m_contactPoints(_contactPoints) {
|
||||
|
||||
}
|
||||
@ -119,11 +119,11 @@ namespace ephysics {
|
||||
ConcaveVsConvexAlgorithm& operator=(const ConcaveVsConvexAlgorithm& _algorithm);
|
||||
/// Process the concave triangle mesh collision using the smooth mesh collision algorithm
|
||||
void processSmoothMeshCollision(OverlappingPair* _overlappingPair,
|
||||
std::vector<SmoothMeshContactInfo> _contactPoints,
|
||||
etk::Vector<SmoothMeshContactInfo> _contactPoints,
|
||||
NarrowPhaseCallback* _narrowPhaseCallback);
|
||||
/// Add a triangle vertex int32_to the set of processed triangles
|
||||
void addProcessedVertex(std::unordered_multimap<int32_t, vec3>& _processTriangleVertices, const vec3& _vertex) {
|
||||
_processTriangleVertices.insert(std::make_pair(int32_t(_vertex.x() * _vertex.y() * _vertex.z()), _vertex));
|
||||
_processTriangleVertices.insert(etk::makePair(int32_t(_vertex.x() * _vertex.y() * _vertex.z()), _vertex));
|
||||
}
|
||||
/// Return true if the vertex is in the set of already processed vertices
|
||||
bool hasVertexBeenProcessed(const std::unordered_multimap<int32_t, vec3>& _processTriangleVertices,
|
||||
|
@ -377,7 +377,7 @@ void EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& simple
|
||||
|
||||
// Compute the error
|
||||
float error = wDotv - triangle->getDistSquare();
|
||||
if (error <= std::max(tolerance, REL_ERROR_SQUARE * wDotv) ||
|
||||
if (error <= etk::max(tolerance, REL_ERROR_SQUARE * wDotv) ||
|
||||
points[indexNewVertex] == points[(*triangle)[0]] ||
|
||||
points[indexNewVertex] == points[(*triangle)[1]] ||
|
||||
points[indexNewVertex] == points[(*triangle)[2]]) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
// Libraries
|
||||
#include <ephysics/mathematics/mathematics.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
/// ReactPhysics3D namespace
|
||||
namespace ephysics {
|
||||
|
@ -32,21 +32,21 @@ AABB::AABB(const AABB& _aabb):
|
||||
}
|
||||
|
||||
void AABB::mergeWithAABB(const AABB& _aabb) {
|
||||
m_minCoordinates.setX(std::min(m_minCoordinates.x(), _aabb.m_minCoordinates.x()));
|
||||
m_minCoordinates.setY(std::min(m_minCoordinates.y(), _aabb.m_minCoordinates.y()));
|
||||
m_minCoordinates.setZ(std::min(m_minCoordinates.z(), _aabb.m_minCoordinates.z()));
|
||||
m_maxCoordinates.setX(std::max(m_maxCoordinates.x(), _aabb.m_maxCoordinates.x()));
|
||||
m_maxCoordinates.setY(std::max(m_maxCoordinates.y(), _aabb.m_maxCoordinates.y()));
|
||||
m_maxCoordinates.setZ(std::max(m_maxCoordinates.z(), _aabb.m_maxCoordinates.z()));
|
||||
m_minCoordinates.setX(etk::min(m_minCoordinates.x(), _aabb.m_minCoordinates.x()));
|
||||
m_minCoordinates.setY(etk::min(m_minCoordinates.y(), _aabb.m_minCoordinates.y()));
|
||||
m_minCoordinates.setZ(etk::min(m_minCoordinates.z(), _aabb.m_minCoordinates.z()));
|
||||
m_maxCoordinates.setX(etk::max(m_maxCoordinates.x(), _aabb.m_maxCoordinates.x()));
|
||||
m_maxCoordinates.setY(etk::max(m_maxCoordinates.y(), _aabb.m_maxCoordinates.y()));
|
||||
m_maxCoordinates.setZ(etk::max(m_maxCoordinates.z(), _aabb.m_maxCoordinates.z()));
|
||||
}
|
||||
|
||||
void AABB::mergeTwoAABBs(const AABB& _aabb1, const AABB& _aabb2) {
|
||||
m_minCoordinates.setX(std::min(_aabb1.m_minCoordinates.x(), _aabb2.m_minCoordinates.x()));
|
||||
m_minCoordinates.setY(std::min(_aabb1.m_minCoordinates.y(), _aabb2.m_minCoordinates.y()));
|
||||
m_minCoordinates.setZ(std::min(_aabb1.m_minCoordinates.z(), _aabb2.m_minCoordinates.z()));
|
||||
m_maxCoordinates.setX(std::max(_aabb1.m_maxCoordinates.x(), _aabb2.m_maxCoordinates.x()));
|
||||
m_maxCoordinates.setY(std::max(_aabb1.m_maxCoordinates.y(), _aabb2.m_maxCoordinates.y()));
|
||||
m_maxCoordinates.setZ(std::max(_aabb1.m_maxCoordinates.z(), _aabb2.m_maxCoordinates.z()));
|
||||
m_minCoordinates.setX(etk::min(_aabb1.m_minCoordinates.x(), _aabb2.m_minCoordinates.x()));
|
||||
m_minCoordinates.setY(etk::min(_aabb1.m_minCoordinates.y(), _aabb2.m_minCoordinates.y()));
|
||||
m_minCoordinates.setZ(etk::min(_aabb1.m_minCoordinates.z(), _aabb2.m_minCoordinates.z()));
|
||||
m_maxCoordinates.setX(etk::max(_aabb1.m_maxCoordinates.x(), _aabb2.m_maxCoordinates.x()));
|
||||
m_maxCoordinates.setY(etk::max(_aabb1.m_maxCoordinates.y(), _aabb2.m_maxCoordinates.y()));
|
||||
m_maxCoordinates.setZ(etk::max(_aabb1.m_maxCoordinates.z(), _aabb2.m_maxCoordinates.z()));
|
||||
}
|
||||
|
||||
bool AABB::contains(const AABB& _aabb) const {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <ephysics/collision/shapes/BoxShape.hpp>
|
||||
#include <ephysics/collision/ProxyShape.hpp>
|
||||
#include <ephysics/configuration.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <cassert>
|
||||
|
||||
using namespace ephysics;
|
||||
@ -83,7 +83,7 @@ bool BoxShape::raycast(const Ray& ray, RaycastInfo& raycastInfo, ProxyShape* pro
|
||||
tMin = t1;
|
||||
normalDirection = currentNormal;
|
||||
}
|
||||
tMax = std::min(tMax, t2);
|
||||
tMax = etk::min(tMax, t2);
|
||||
|
||||
// If tMin is larger than the maximum raycasting fraction, we return no hit
|
||||
if (tMin > ray.maxFraction) return false;
|
||||
|
@ -74,12 +74,12 @@ bool ConcaveMeshShape::raycast(const Ray& _ray, RaycastInfo& _raycastInfo, Proxy
|
||||
|
||||
float ConcaveMeshRaycastCallback::raycastBroadPhaseShape(int32_t _nodeId, const Ray& _ray) {
|
||||
// Add the id of the hit AABB node int32_to
|
||||
m_hitAABBNodes.push_back(_nodeId);
|
||||
m_hitAABBNodes.pushBack(_nodeId);
|
||||
return _ray.maxFraction;
|
||||
}
|
||||
|
||||
void ConcaveMeshRaycastCallback::raycastTriangles() {
|
||||
std::vector<int32_t>::const_iterator it;
|
||||
etk::Vector<int32_t>::const_iterator it;
|
||||
float smallestHitFraction = m_ray.maxFraction;
|
||||
for (it = m_hitAABBNodes.begin(); it != m_hitAABBNodes.end(); ++it) {
|
||||
// Get the node data (triangle index and mesh subpart index)
|
||||
|
@ -35,7 +35,7 @@ namespace ephysics {
|
||||
|
||||
class ConcaveMeshRaycastCallback : public DynamicAABBTreeRaycastCallback {
|
||||
private :
|
||||
std::vector<int32_t> m_hitAABBNodes;
|
||||
etk::Vector<int32_t> m_hitAABBNodes;
|
||||
const DynamicAABBTree& m_dynamicAABBTree;
|
||||
const ConcaveMeshShape& m_concaveMeshShape;
|
||||
ProxyShape* m_proxyShape;
|
||||
|
@ -30,7 +30,7 @@ ConvexMeshShape::ConvexMeshShape(const float* arrayVertices, uint32_t nbVertices
|
||||
// Copy all the vertices int32_to the int32_ternal array
|
||||
for (uint32_t i=0; i<m_numberVertices; i++) {
|
||||
const float* newPoint = (const float*) vertexPointer;
|
||||
m_vertices.push_back(vec3(newPoint[0], newPoint[1], newPoint[2]));
|
||||
m_vertices.pushBack(vec3(newPoint[0], newPoint[1], newPoint[2]));
|
||||
vertexPointer += stride;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ ConvexMeshShape::ConvexMeshShape(TriangleVertexArray* _triangleVertexArray, bool
|
||||
m_isEdgesInformationUsed(_isEdgesInformationUsed) {
|
||||
// For each vertex of the mesh
|
||||
for (auto &it: _triangleVertexArray->getVertices()) {
|
||||
m_vertices.push_back(it*m_scaling);
|
||||
m_vertices.pushBack(it*m_scaling);
|
||||
}
|
||||
// If we need to use the edges information of the mesh
|
||||
if (m_isEdgesInformationUsed) {
|
||||
@ -256,7 +256,7 @@ void ConvexMeshShape::computeLocalInertiaTensor(etk::Matrix3x3& tensor, float ma
|
||||
void ConvexMeshShape::addVertex(const vec3& vertex) {
|
||||
|
||||
// Add the vertex in to vertices array
|
||||
m_vertices.push_back(vertex);
|
||||
m_vertices.pushBack(vertex);
|
||||
m_numberVertices++;
|
||||
|
||||
// Update the bounds of the mesh
|
||||
@ -292,12 +292,12 @@ void ConvexMeshShape::addEdge(uint32_t v1, uint32_t v2) {
|
||||
|
||||
// If the entry for vertex v1 does not exist in the adjacency list
|
||||
if (m_edgesAdjacencyList.count(v1) == 0) {
|
||||
m_edgesAdjacencyList.insert(std::make_pair(v1, std::set<uint32_t>()));
|
||||
m_edgesAdjacencyList.insert(etk::makePair(v1, std::set<uint32_t>()));
|
||||
}
|
||||
|
||||
// If the entry for vertex v2 does not exist in the adjacency list
|
||||
if (m_edgesAdjacencyList.count(v2) == 0) {
|
||||
m_edgesAdjacencyList.insert(std::make_pair(v2, std::set<uint32_t>()));
|
||||
m_edgesAdjacencyList.insert(etk::makePair(v2, std::set<uint32_t>()));
|
||||
}
|
||||
|
||||
// Add the edge in the adjacency list
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include <ephysics/mathematics/mathematics.hpp>
|
||||
#include <ephysics/collision/TriangleMesh.hpp>
|
||||
#include <ephysics/collision/narrowphase/GJK/GJKAlgorithm.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <etk/Map.hpp>
|
||||
|
||||
namespace ephysics {
|
||||
class CollisionWorld;
|
||||
@ -33,12 +33,12 @@ namespace ephysics {
|
||||
*/
|
||||
class ConvexMeshShape : public ConvexShape {
|
||||
protected :
|
||||
std::vector<vec3> m_vertices; //!< Array with the vertices of the mesh
|
||||
etk::Vector<vec3> m_vertices; //!< Array with the vertices of the mesh
|
||||
uint32_t m_numberVertices; //!< Number of vertices in the mesh
|
||||
vec3 m_minBounds; //!< Mesh minimum bounds in the three local x, y and z directions
|
||||
vec3 m_maxBounds; //!< Mesh maximum bounds in the three local x, y and z directions
|
||||
bool m_isEdgesInformationUsed; //!< True if the shape contains the edges of the convex mesh in order to make the collision detection faster
|
||||
std::map<uint32_t, std::set<uint32_t> > m_edgesAdjacencyList; //!< Adjacency list representing the edges of the mesh
|
||||
etk::Map<uint32_t, std::set<uint32_t> > m_edgesAdjacencyList; //!< Adjacency list representing the edges of the mesh
|
||||
/// Private copy-constructor
|
||||
ConvexMeshShape(const ConvexMeshShape& _shape);
|
||||
/// Private assignment operator
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace ephysics {
|
||||
// ------------------- Type definitions ------------------- //
|
||||
typedef uint64_t bodyindex;
|
||||
typedef std::pair<bodyindex, bodyindex> bodyindexpair;
|
||||
typedef etk::Pair<bodyindex, bodyindex> bodyindexpair;
|
||||
|
||||
// ------------------- Enumerations ------------------- //
|
||||
|
||||
|
@ -313,7 +313,7 @@ void HingeJoint::solveVelocityConstraint(const ConstraintSolverData& constraintS
|
||||
// Compute the Lagrange multiplier lambda for the lower limit constraint
|
||||
float deltaLambdaLower = m_inverseMassMatrixLimitMotor * (-JvLowerLimit -m_bLowerLimit);
|
||||
float lambdaTemp = m_impulseLowerLimit;
|
||||
m_impulseLowerLimit = std::max(m_impulseLowerLimit + deltaLambdaLower, 0.0f);
|
||||
m_impulseLowerLimit = etk::max(m_impulseLowerLimit + deltaLambdaLower, 0.0f);
|
||||
deltaLambdaLower = m_impulseLowerLimit - lambdaTemp;
|
||||
|
||||
// Compute the impulse P=J^T * lambda for the lower limit constraint of body 1
|
||||
@ -338,7 +338,7 @@ void HingeJoint::solveVelocityConstraint(const ConstraintSolverData& constraintS
|
||||
// Compute the Lagrange multiplier lambda for the upper limit constraint
|
||||
float deltaLambdaUpper = m_inverseMassMatrixLimitMotor * (-JvUpperLimit -m_bUpperLimit);
|
||||
float lambdaTemp = m_impulseUpperLimit;
|
||||
m_impulseUpperLimit = std::max(m_impulseUpperLimit + deltaLambdaUpper, 0.0f);
|
||||
m_impulseUpperLimit = etk::max(m_impulseUpperLimit + deltaLambdaUpper, 0.0f);
|
||||
deltaLambdaUpper = m_impulseUpperLimit - lambdaTemp;
|
||||
|
||||
// Compute the impulse P=J^T * lambda for the upper limit constraint of body 1
|
||||
|
@ -330,7 +330,7 @@ void SliderJoint::solveVelocityConstraint(const ConstraintSolverData& constraint
|
||||
// Compute the Lagrange multiplier lambda for the lower limit constraint
|
||||
float deltaLambdaLower = m_inverseMassMatrixLimit * (-JvLowerLimit -m_bLowerLimit);
|
||||
float lambdaTemp = m_impulseLowerLimit;
|
||||
m_impulseLowerLimit = std::max(m_impulseLowerLimit + deltaLambdaLower, 0.0f);
|
||||
m_impulseLowerLimit = etk::max(m_impulseLowerLimit + deltaLambdaLower, 0.0f);
|
||||
deltaLambdaLower = m_impulseLowerLimit - lambdaTemp;
|
||||
|
||||
// Compute the impulse P=J^T * lambda for the lower limit constraint of body 1
|
||||
@ -360,7 +360,7 @@ void SliderJoint::solveVelocityConstraint(const ConstraintSolverData& constraint
|
||||
// Compute the Lagrange multiplier lambda for the upper limit constraint
|
||||
float deltaLambdaUpper = m_inverseMassMatrixLimit * (-JvUpperLimit -m_bUpperLimit);
|
||||
float lambdaTemp = m_impulseUpperLimit;
|
||||
m_impulseUpperLimit = std::max(m_impulseUpperLimit + deltaLambdaUpper, 0.0f);
|
||||
m_impulseUpperLimit = etk::max(m_impulseUpperLimit + deltaLambdaUpper, 0.0f);
|
||||
deltaLambdaUpper = m_impulseUpperLimit - lambdaTemp;
|
||||
|
||||
// Compute the impulse P=J^T * lambda for the upper limit constraint of body 1
|
||||
|
@ -69,7 +69,7 @@ void CollisionWorld::destroyCollisionBody(CollisionBody* collisionBody) {
|
||||
collisionBody->removeAllCollisionShapes();
|
||||
|
||||
// Add the body ID to the list of free IDs
|
||||
m_freeBodiesIDs.push_back(collisionBody->getID());
|
||||
m_freeBodiesIDs.pushBack(collisionBody->getID());
|
||||
|
||||
// Call the destructor of the collision body
|
||||
collisionBody->~CollisionBody();
|
||||
@ -88,7 +88,7 @@ bodyindex CollisionWorld::computeNextAvailableBodyID() {
|
||||
bodyindex bodyID;
|
||||
if (!m_freeBodiesIDs.empty()) {
|
||||
bodyID = m_freeBodiesIDs.back();
|
||||
m_freeBodiesIDs.pop_back();
|
||||
m_freeBodiesIDs.popBack();
|
||||
}
|
||||
else {
|
||||
bodyID = m_currentBodyID;
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
@ -32,7 +32,7 @@ namespace ephysics {
|
||||
CollisionDetection m_collisionDetection; //!< Reference to the collision detection
|
||||
std::set<CollisionBody*> m_bodies; //!< All the bodies (rigid and soft) of the world
|
||||
bodyindex m_currentBodyID; //!< Current body ID
|
||||
std::vector<uint64_t> m_freeBodiesIDs; //!< List of free ID for rigid bodies
|
||||
etk::Vector<uint64_t> m_freeBodiesIDs; //!< List of free ID for rigid bodies
|
||||
MemoryAllocator m_memoryAllocator; //!< Memory allocator
|
||||
EventListener* m_eventListener; //!< Pointer to an event listener object
|
||||
/// Private copy-constructor
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
using namespace ephysics;
|
||||
|
||||
ConstraintSolver::ConstraintSolver(const std::map<RigidBody*, uint32_t>& _mapBodyToVelocityIndex):
|
||||
ConstraintSolver::ConstraintSolver(const etk::Map<RigidBody*, uint32_t>& _mapBodyToVelocityIndex):
|
||||
m_mapBodyToConstrainedVelocityIndex(_mapBodyToVelocityIndex),
|
||||
m_isWarmStartingActive(true),
|
||||
m_constraintSolverData(_mapBodyToVelocityIndex) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <ephysics/mathematics/mathematics.hpp>
|
||||
#include <ephysics/constraint/Joint.hpp>
|
||||
#include <ephysics/engine/Island.hpp>
|
||||
#include <map>
|
||||
#include <etk/Map.hpp>
|
||||
#include <set>
|
||||
|
||||
namespace ephysics {
|
||||
@ -24,10 +24,10 @@ namespace ephysics {
|
||||
vec3* angularVelocities; //!< Array with the bodies angular velocities
|
||||
vec3* positions; //!< Reference to the bodies positions
|
||||
etk::Quaternion* orientations; //!< Reference to the bodies orientations
|
||||
const std::map<RigidBody*, uint32_t>& mapBodyToConstrainedVelocityIndex; //!< Reference to the map that associates rigid body to their index in the constrained velocities array
|
||||
const etk::Map<RigidBody*, uint32_t>& mapBodyToConstrainedVelocityIndex; //!< Reference to the map that associates rigid body to their index in the constrained velocities array
|
||||
bool isWarmStartingActive; //!< True if warm starting of the solver is active
|
||||
/// Constructor
|
||||
ConstraintSolverData(const std::map<RigidBody*, uint32_t>& refMapBodyToConstrainedVelocityIndex)
|
||||
ConstraintSolverData(const etk::Map<RigidBody*, uint32_t>& refMapBodyToConstrainedVelocityIndex)
|
||||
:linearVelocities(NULL), angularVelocities(NULL),
|
||||
positions(NULL), orientations(NULL),
|
||||
mapBodyToConstrainedVelocityIndex(refMapBodyToConstrainedVelocityIndex){
|
||||
@ -105,13 +105,13 @@ namespace ephysics {
|
||||
*/
|
||||
class ConstraintSolver {
|
||||
private :
|
||||
const std::map<RigidBody*, uint32_t>& m_mapBodyToConstrainedVelocityIndex; //!< Reference to the map that associates rigid body to their index in the constrained velocities array
|
||||
const etk::Map<RigidBody*, uint32_t>& m_mapBodyToConstrainedVelocityIndex; //!< Reference to the map that associates rigid body to their index in the constrained velocities array
|
||||
float m_timeStep; //!< Current time step
|
||||
bool m_isWarmStartingActive; //!< True if the warm starting of the solver is active
|
||||
ConstraintSolverData m_constraintSolverData; //!< Constraint solver data used to initialize and solve the constraints
|
||||
public :
|
||||
/// Constructor
|
||||
ConstraintSolver(const std::map<RigidBody*, uint32_t>& _mapBodyToVelocityIndex);
|
||||
ConstraintSolver(const etk::Map<RigidBody*, uint32_t>& _mapBodyToVelocityIndex);
|
||||
/// Initialize the constraint solver for a given island
|
||||
void initializeForIsland(float _dt, Island* _island);
|
||||
/// Solve the constraints
|
||||
|
@ -20,7 +20,7 @@ const float ContactSolver::BETA_SPLIT_IMPULSE = float(0.2);
|
||||
const float ContactSolver::SLOP= float(0.01);
|
||||
|
||||
// Constructor
|
||||
ContactSolver::ContactSolver(const std::map<RigidBody*, uint32_t>& mapBodyToVelocityIndex)
|
||||
ContactSolver::ContactSolver(const etk::Map<RigidBody*, uint32_t>& mapBodyToVelocityIndex)
|
||||
:m_splitLinearVelocities(nullptr), m_splitAngularVelocities(nullptr),
|
||||
m_contactConstraints(nullptr), m_linearVelocities(nullptr), m_angularVelocities(nullptr),
|
||||
m_mapBodyToConstrainedVelocityIndex(mapBodyToVelocityIndex),
|
||||
@ -534,7 +534,7 @@ void ContactSolver::solve() {
|
||||
deltaLambda = - (Jv + b) * contactPoint.inversePenetrationMass;
|
||||
}
|
||||
lambdaTemp = contactPoint.penetrationImpulse;
|
||||
contactPoint.penetrationImpulse = std::max(contactPoint.penetrationImpulse +
|
||||
contactPoint.penetrationImpulse = etk::max(contactPoint.penetrationImpulse +
|
||||
deltaLambda, 0.0f);
|
||||
deltaLambda = contactPoint.penetrationImpulse - lambdaTemp;
|
||||
|
||||
@ -561,7 +561,7 @@ void ContactSolver::solve() {
|
||||
float deltaLambdaSplit = - (JvSplit + biasPenetrationDepth) *
|
||||
contactPoint.inversePenetrationMass;
|
||||
float lambdaTempSplit = contactPoint.penetrationSplitImpulse;
|
||||
contactPoint.penetrationSplitImpulse = std::max(
|
||||
contactPoint.penetrationSplitImpulse = etk::max(
|
||||
contactPoint.penetrationSplitImpulse +
|
||||
deltaLambdaSplit, 0.0f);
|
||||
deltaLambda = contactPoint.penetrationSplitImpulse - lambdaTempSplit;
|
||||
@ -588,8 +588,8 @@ void ContactSolver::solve() {
|
||||
float frictionLimit = contactManifold.frictionCoefficient *
|
||||
contactPoint.penetrationImpulse;
|
||||
lambdaTemp = contactPoint.friction1Impulse;
|
||||
contactPoint.friction1Impulse = std::max(-frictionLimit,
|
||||
std::min(contactPoint.friction1Impulse
|
||||
contactPoint.friction1Impulse = etk::max(-frictionLimit,
|
||||
etk::min(contactPoint.friction1Impulse
|
||||
+ deltaLambda, frictionLimit));
|
||||
deltaLambda = contactPoint.friction1Impulse - lambdaTemp;
|
||||
|
||||
@ -612,8 +612,8 @@ void ContactSolver::solve() {
|
||||
frictionLimit = contactManifold.frictionCoefficient *
|
||||
contactPoint.penetrationImpulse;
|
||||
lambdaTemp = contactPoint.friction2Impulse;
|
||||
contactPoint.friction2Impulse = std::max(-frictionLimit,
|
||||
std::min(contactPoint.friction2Impulse
|
||||
contactPoint.friction2Impulse = etk::max(-frictionLimit,
|
||||
etk::min(contactPoint.friction2Impulse
|
||||
+ deltaLambda, frictionLimit));
|
||||
deltaLambda = contactPoint.friction2Impulse - lambdaTemp;
|
||||
|
||||
@ -663,8 +663,8 @@ void ContactSolver::solve() {
|
||||
float deltaLambda = -Jv * contactManifold.inverseFriction1Mass;
|
||||
float frictionLimit = contactManifold.frictionCoefficient * sum_penetrationImpulse;
|
||||
lambdaTemp = contactManifold.friction1Impulse;
|
||||
contactManifold.friction1Impulse = std::max(-frictionLimit,
|
||||
std::min(contactManifold.friction1Impulse +
|
||||
contactManifold.friction1Impulse = etk::max(-frictionLimit,
|
||||
etk::min(contactManifold.friction1Impulse +
|
||||
deltaLambda, frictionLimit));
|
||||
deltaLambda = contactManifold.friction1Impulse - lambdaTemp;
|
||||
|
||||
@ -690,8 +690,8 @@ void ContactSolver::solve() {
|
||||
deltaLambda = -Jv * contactManifold.inverseFriction2Mass;
|
||||
frictionLimit = contactManifold.frictionCoefficient * sum_penetrationImpulse;
|
||||
lambdaTemp = contactManifold.friction2Impulse;
|
||||
contactManifold.friction2Impulse = std::max(-frictionLimit,
|
||||
std::min(contactManifold.friction2Impulse +
|
||||
contactManifold.friction2Impulse = etk::max(-frictionLimit,
|
||||
etk::min(contactManifold.friction2Impulse +
|
||||
deltaLambda, frictionLimit));
|
||||
deltaLambda = contactManifold.friction2Impulse - lambdaTemp;
|
||||
|
||||
@ -715,8 +715,8 @@ void ContactSolver::solve() {
|
||||
deltaLambda = -Jv * (contactManifold.inverseTwistFrictionMass);
|
||||
frictionLimit = contactManifold.frictionCoefficient * sum_penetrationImpulse;
|
||||
lambdaTemp = contactManifold.frictionTwistImpulse;
|
||||
contactManifold.frictionTwistImpulse = std::max(-frictionLimit,
|
||||
std::min(contactManifold.frictionTwistImpulse
|
||||
contactManifold.frictionTwistImpulse = etk::max(-frictionLimit,
|
||||
etk::min(contactManifold.frictionTwistImpulse
|
||||
+ deltaLambda, frictionLimit));
|
||||
deltaLambda = contactManifold.frictionTwistImpulse - lambdaTemp;
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <ephysics/collision/ContactManifold.hpp>
|
||||
#include <ephysics/engine/Island.hpp>
|
||||
#include <ephysics/engine/Impulse.hpp>
|
||||
#include <map>
|
||||
#include <etk/Map.hpp>
|
||||
#include <set>
|
||||
|
||||
namespace ephysics {
|
||||
@ -168,7 +168,7 @@ namespace ephysics {
|
||||
uint32_t m_numberContactManifolds; //!< Number of contact constraints
|
||||
vec3* m_linearVelocities; //!< Array of linear velocities
|
||||
vec3* m_angularVelocities; //!< Array of angular velocities
|
||||
const std::map<RigidBody*, uint32_t>& m_mapBodyToConstrainedVelocityIndex; //!< Reference to the map of rigid body to their index in the constrained velocities array
|
||||
const etk::Map<RigidBody*, uint32_t>& m_mapBodyToConstrainedVelocityIndex; //!< Reference to the map of rigid body to their index in the constrained velocities array
|
||||
bool m_isWarmStartingActive; //!< True if the warm starting of the solver is active
|
||||
bool m_isSplitImpulseActive; //!< True if the split impulse position correction is active
|
||||
bool m_isSolveFrictionAtContactManifoldCenterActive; //!< True if we solve 3 friction constraints at the contact manifold center only instead of 2 friction constraints at each contact point
|
||||
@ -208,7 +208,7 @@ namespace ephysics {
|
||||
const ContactPointSolver& contactPoint) const;
|
||||
public:
|
||||
/// Constructor
|
||||
ContactSolver(const std::map<RigidBody*, uint32_t>& mapBodyToVelocityIndex);
|
||||
ContactSolver(const etk::Map<RigidBody*, uint32_t>& mapBodyToVelocityIndex);
|
||||
/// Destructor
|
||||
virtual ~ContactSolver();
|
||||
/// Initialize the constraint solver for a given island
|
||||
|
@ -267,7 +267,7 @@ void DynamicsWorld::initVelocityArrays() {
|
||||
for (it = m_rigidBodies.begin(); it != m_rigidBodies.end(); ++it) {
|
||||
|
||||
// Add the body int32_to the map
|
||||
m_mapBodyToConstrainedVelocityIndex.insert(std::make_pair(*it, indexBody));
|
||||
m_mapBodyToConstrainedVelocityIndex.insert(etk::makePair(*it, indexBody));
|
||||
indexBody++;
|
||||
}
|
||||
}
|
||||
@ -457,7 +457,7 @@ void DynamicsWorld::destroyRigidBody(RigidBody* rigidBody) {
|
||||
rigidBody->removeAllCollisionShapes();
|
||||
|
||||
// Add the body ID to the list of free IDs
|
||||
m_freeBodiesIDs.push_back(rigidBody->getID());
|
||||
m_freeBodiesIDs.pushBack(rigidBody->getID());
|
||||
|
||||
// Destroy all the joints in which the rigid body to be destroyed is involved
|
||||
JointListElement* element;
|
||||
@ -960,12 +960,12 @@ void DynamicsWorld::testCollision(CollisionCallback* callback) {
|
||||
}
|
||||
|
||||
/// Return the list of all contacts of the world
|
||||
std::vector<const ContactManifold*> DynamicsWorld::getContactsList() const {
|
||||
etk::Vector<const ContactManifold*> DynamicsWorld::getContactsList() const {
|
||||
|
||||
std::vector<const ContactManifold*> contactManifolds;
|
||||
etk::Vector<const ContactManifold*> contactManifolds;
|
||||
|
||||
// For each currently overlapping pair of bodies
|
||||
std::map<overlappingpairid, OverlappingPair*>::const_iterator it;
|
||||
etk::Map<overlappingpairid, OverlappingPair*>::const_iterator it;
|
||||
for (it = m_collisionDetection.m_overlappingPairs.begin();
|
||||
it != m_collisionDetection.m_overlappingPairs.end(); ++it) {
|
||||
|
||||
@ -978,7 +978,7 @@ std::vector<const ContactManifold*> DynamicsWorld::getContactsList() const {
|
||||
ContactManifold* manifold = manifoldSet.getContactManifold(i);
|
||||
|
||||
// Get the contact manifold
|
||||
contactManifolds.push_back(manifold);
|
||||
contactManifolds.pushBack(manifold);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace ephysics {
|
||||
vec3* m_splitAngularVelocities; //!< Split angular velocities for the position contact solver (split impulse)
|
||||
vec3* m_constrainedPositions; //!< Array of constrained rigid bodies position (for position error correction)
|
||||
etk::Quaternion* m_constrainedOrientations; //!< Array of constrained rigid bodies orientation (for position error correction)
|
||||
std::map<RigidBody*, uint32_t> m_mapBodyToConstrainedVelocityIndex; //!< Map body to their index in the constrained velocities array
|
||||
etk::Map<RigidBody*, uint32_t> m_mapBodyToConstrainedVelocityIndex; //!< Map body to their index in the constrained velocities array
|
||||
uint32_t m_numberIslands; //!< Number of islands in the world
|
||||
uint32_t m_numberIslandsCapacity; //!< Current allocated capacity for the islands
|
||||
Island** m_islands; //!< Array with all the islands of awaken bodies
|
||||
@ -155,7 +155,7 @@ namespace ephysics {
|
||||
/// Test and report collisions between all shapes of the world
|
||||
virtual void testCollision(CollisionCallback* _callback) override;
|
||||
/// Return the list of all contacts of the world
|
||||
std::vector<const ContactManifold*> getContactsList() const;
|
||||
etk::Vector<const ContactManifold*> getContactsList() const;
|
||||
friend class RigidBody;
|
||||
};
|
||||
|
||||
|
@ -64,8 +64,8 @@ overlappingpairid OverlappingPair::computeID(ProxyShape* _shape1, ProxyShape* _s
|
||||
|
||||
// Construct the pair of body index
|
||||
overlappingpairid pairID = _shape1->m_broadPhaseID < _shape2->m_broadPhaseID ?
|
||||
std::make_pair(_shape1->m_broadPhaseID, _shape2->m_broadPhaseID) :
|
||||
std::make_pair(_shape2->m_broadPhaseID, _shape1->m_broadPhaseID);
|
||||
etk::makePair(_shape1->m_broadPhaseID, _shape2->m_broadPhaseID) :
|
||||
etk::makePair(_shape2->m_broadPhaseID, _shape1->m_broadPhaseID);
|
||||
assert(pairID.first != pairID.second);
|
||||
return pairID;
|
||||
}
|
||||
@ -76,8 +76,8 @@ bodyindexpair OverlappingPair::computeBodiesIndexPair(CollisionBody* _body1,
|
||||
|
||||
// Construct the pair of body index
|
||||
bodyindexpair indexPair = _body1->getID() < _body2->getID() ?
|
||||
std::make_pair(_body1->getID(), _body2->getID()) :
|
||||
std::make_pair(_body2->getID(), _body1->getID());
|
||||
etk::makePair(_body1->getID(), _body2->getID()) :
|
||||
etk::makePair(_body2->getID(), _body1->getID());
|
||||
assert(indexPair.first != indexPair.second);
|
||||
return indexPair;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace ephysics {
|
||||
// Type for the overlapping pair ID
|
||||
typedef std::pair<uint32_t, uint32_t> overlappingpairid;
|
||||
typedef etk::Pair<uint32_t, uint32_t> overlappingpairid;
|
||||
/**
|
||||
* @brief This class represents a pair of two proxy collision shapes that are overlapping
|
||||
* during the broad-phase collision detection. It is created when
|
||||
|
@ -171,7 +171,7 @@ void Profiler::reset() {
|
||||
}
|
||||
|
||||
// Print32_t the report of the profiler in a given output stream
|
||||
void Profiler::print32_tReport(std::ostream& outputStream) {
|
||||
void Profiler::print32_tReport(etk::Stream& outputStream) {
|
||||
ProfileNodeIterator* iterator = Profiler::getIterator();
|
||||
|
||||
// Recursively print32_t the report of each node of the profiler tree
|
||||
@ -184,7 +184,7 @@ void Profiler::print32_tReport(std::ostream& outputStream) {
|
||||
// Recursively print32_t the report of a given node of the profiler tree
|
||||
void Profiler::print32_tRecursiveNodeReport(ProfileNodeIterator* iterator,
|
||||
int32_t spacing,
|
||||
std::ostream& outputStream) {
|
||||
etk::Stream& outputStream) {
|
||||
iterator->first();
|
||||
|
||||
// If we are at the end of a branch in the profiler tree
|
||||
|
@ -99,7 +99,7 @@ namespace ephysics {
|
||||
private:
|
||||
static void print32_tRecursiveNodeReport(ProfileNodeIterator* iterator,
|
||||
int32_t spacing,
|
||||
std::ostream& outputStream);
|
||||
etk::Stream& outputStream);
|
||||
public :
|
||||
/// Method called when we want to start profiling a block of code.
|
||||
static void startProfilingBlock(const char *name);
|
||||
@ -117,7 +117,7 @@ namespace ephysics {
|
||||
/// Return an iterator over the profiler tree starting at the root
|
||||
static ProfileNodeIterator* getIterator();
|
||||
/// Print32_t the report of the profiler in a given output stream
|
||||
static void print32_tReport(std::ostream& outputStream);
|
||||
static void print32_tReport(etk::Stream& outputStream);
|
||||
/// Destroy a previously allocated iterator
|
||||
static void destroyIterator(ProfileNodeIterator* iterator);
|
||||
/// Destroy the profiler (release the memory)
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <ephysics/mathematics/Ray.hpp>
|
||||
#include <ephysics/configuration.hpp>
|
||||
#include <ephysics/mathematics/mathematics_functions.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
@ -28,24 +28,24 @@ inline bool approxEqual(float a, float b, float epsilon = MACHINE_EPSILON) {
|
||||
/// two others values "lowerLimit" and "upperLimit"
|
||||
inline int32_t clamp(int32_t value, int32_t lowerLimit, int32_t upperLimit) {
|
||||
assert(lowerLimit <= upperLimit);
|
||||
return std::min(std::max(value, lowerLimit), upperLimit);
|
||||
return etk::min(etk::max(value, lowerLimit), upperLimit);
|
||||
}
|
||||
|
||||
/// Function that returns the result of the "value" clamped by
|
||||
/// two others values "lowerLimit" and "upperLimit"
|
||||
inline float clamp(float value, float lowerLimit, float upperLimit) {
|
||||
assert(lowerLimit <= upperLimit);
|
||||
return std::min(std::max(value, lowerLimit), upperLimit);
|
||||
return etk::min(etk::max(value, lowerLimit), upperLimit);
|
||||
}
|
||||
|
||||
/// Return the minimum value among three values
|
||||
inline float min3(float a, float b, float c) {
|
||||
return std::min(std::min(a, b), c);
|
||||
return etk::min(etk::min(a, b), c);
|
||||
}
|
||||
|
||||
/// Return the maximum value among three values
|
||||
inline float max3(float a, float b, float c) {
|
||||
return std::max(std::max(a, b), c);
|
||||
return etk::max(etk::max(a, b), c);
|
||||
}
|
||||
|
||||
/// Return true if two values have the same sign
|
||||
|
@ -31,7 +31,7 @@
|
||||
using namespace ephysics;
|
||||
|
||||
/// Constructor
|
||||
Test::Test(const std::string& name, std::ostream* stream)
|
||||
Test::Test(const etk::String& name, etk::Stream* stream)
|
||||
: m_name(name), mNbPassedTests(0), mNbFailedTests(0), mOutputStream(stream) {
|
||||
|
||||
}
|
||||
@ -43,7 +43,7 @@ Test::~Test() {
|
||||
|
||||
// Called to test a boolean condition.
|
||||
// This method should not be called directly in your test but you should call test() instead (macro)
|
||||
void Test::applyTest(bool condition, const std::string& testText,
|
||||
void Test::applyTest(bool condition, const etk::String& testText,
|
||||
const char* filename, long lineNumber) {
|
||||
|
||||
// If the boolean condition is true
|
||||
@ -61,7 +61,7 @@ void Test::applyTest(bool condition, const std::string& testText,
|
||||
|
||||
// Called when a test has failed.
|
||||
// This method should not be called directly in your test buy you should call fail() instead (macro)
|
||||
void Test::applyFail(const std::string& testText, const char* filename, long lineNumber) {
|
||||
void Test::applyFail(const etk::String& testText, const char* filename, long lineNumber) {
|
||||
|
||||
if (mOutputStream) {
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define TEST_H
|
||||
|
||||
// Libraries
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
@ -51,7 +51,7 @@ class Test {
|
||||
// ---------- Attributes ---------- //
|
||||
|
||||
/// Name of the test
|
||||
std::string m_name;
|
||||
etk::String m_name;
|
||||
|
||||
/// Number of tests that passed
|
||||
long mNbPassedTests;
|
||||
@ -60,7 +60,7 @@ class Test {
|
||||
long mNbFailedTests;
|
||||
|
||||
/// Output stream
|
||||
std::ostream* mOutputStream;
|
||||
etk::Stream* mOutputStream;
|
||||
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
@ -77,20 +77,20 @@ class Test {
|
||||
/// Called to test a boolean condition.
|
||||
/// This method should not be called directly in your test but you should
|
||||
/// call test() instead (macro)
|
||||
void applyTest(bool condition, const std::string& testText,
|
||||
void applyTest(bool condition, const etk::String& testText,
|
||||
const char* filename, long lineNumber);
|
||||
|
||||
/// Called when a test has failed.
|
||||
/// This method should not be called directly in your test buy you should
|
||||
/// call fail() instead (macro)
|
||||
void applyFail(const std::string& testText, const char* filename, long lineNumber);
|
||||
void applyFail(const etk::String& testText, const char* filename, long lineNumber);
|
||||
|
||||
public :
|
||||
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Test(const std::string& name, std::ostream* stream = &std::cout);
|
||||
Test(const etk::String& name, etk::Stream* stream = &std::cout);
|
||||
|
||||
/// Destructor
|
||||
virtual ~Test();
|
||||
@ -102,10 +102,10 @@ class Test {
|
||||
long getNbFailedTests() const;
|
||||
|
||||
/// Return the output stream
|
||||
const std::ostream* getOutputStream() const;
|
||||
const etk::Stream* getOutputStream() const;
|
||||
|
||||
/// Set the output stream
|
||||
void setOutputStream(std::ostream *stream);
|
||||
void setOutputStream(etk::Stream *stream);
|
||||
|
||||
/// Run the unit test
|
||||
virtual void run() = 0;
|
||||
@ -142,12 +142,12 @@ inline long Test::getNbFailedTests() const {
|
||||
}
|
||||
|
||||
// Return the output stream
|
||||
inline const std::ostream* Test::getOutputStream() const {
|
||||
inline const etk::Stream* Test::getOutputStream() const {
|
||||
return mOutputStream;
|
||||
}
|
||||
|
||||
// Set the output stream
|
||||
inline void Test::setOutputStream(std::ostream* stream) {
|
||||
inline void Test::setOutputStream(etk::Stream* stream) {
|
||||
mOutputStream = stream;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
using namespace ephysics;
|
||||
|
||||
// Constructor
|
||||
TestSuite::TestSuite(const std::string& name, std::ostream* outputStream)
|
||||
TestSuite::TestSuite(const etk::String& name, etk::Stream* outputStream)
|
||||
: m_name(name), mOutputStream(outputStream) {
|
||||
|
||||
}
|
||||
@ -69,7 +69,7 @@ void TestSuite::addTest(Test* test) {
|
||||
}
|
||||
|
||||
// Add the test to the suite
|
||||
mTests.push_back(test);
|
||||
mTests.pushBack(test);
|
||||
|
||||
// Reset the added test
|
||||
test->reset();
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
// Libraries
|
||||
#include <test/Test.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
/// Reactphysics3D namespace
|
||||
@ -48,13 +48,13 @@ class TestSuite {
|
||||
// ---------- Attributes ---------- //
|
||||
|
||||
/// Name of the test suite
|
||||
std::string m_name;
|
||||
etk::String m_name;
|
||||
|
||||
/// Output stream
|
||||
std::ostream* mOutputStream;
|
||||
etk::Stream* mOutputStream;
|
||||
|
||||
/// All the tests of the test suite
|
||||
std::vector<Test*> mTests;
|
||||
etk::Vector<Test*> mTests;
|
||||
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
@ -72,10 +72,10 @@ class TestSuite {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestSuite(const std::string& name, std::ostream* outputStream = &std::cout);
|
||||
TestSuite(const etk::String& name, etk::Stream* outputStream = &std::cout);
|
||||
|
||||
/// Return the name of the test suite
|
||||
std::string getName() const;
|
||||
etk::String getName() const;
|
||||
|
||||
/// Return the number of passed tests
|
||||
long getNbPassedTests() const;
|
||||
@ -84,10 +84,10 @@ class TestSuite {
|
||||
long getNbFailedTests() const;
|
||||
|
||||
/// Return the output stream
|
||||
const std::ostream* getOutputStream() const;
|
||||
const etk::Stream* getOutputStream() const;
|
||||
|
||||
/// Set the output stream
|
||||
void setOutputStream(std::ostream* outputStream);
|
||||
void setOutputStream(etk::Stream* outputStream);
|
||||
|
||||
/// Add a unit test in the test suite
|
||||
void addTest(Test* test);
|
||||
@ -107,17 +107,17 @@ class TestSuite {
|
||||
};
|
||||
|
||||
// Return the name of the test suite
|
||||
inline std::string TestSuite::getName() const {
|
||||
inline etk::String TestSuite::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
// Return the output stream
|
||||
inline const std::ostream* TestSuite::getOutputStream() const {
|
||||
inline const etk::Stream* TestSuite::getOutputStream() const {
|
||||
return mOutputStream;
|
||||
}
|
||||
|
||||
// Set the output stream
|
||||
inline void TestSuite::setOutputStream(std::ostream* outputStream) {
|
||||
inline void TestSuite::setOutputStream(etk::Stream* outputStream) {
|
||||
mOutputStream = outputStream;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class TestAABB : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestAABB(const std::string& name) : Test(name) {
|
||||
TestAABB(const etk::String& name) : Test(name) {
|
||||
|
||||
m_AABB1.setMin(vec3(-10, -10, -10));
|
||||
m_AABB1.setMax(vec3(10, 10, 10));
|
||||
|
@ -133,7 +133,7 @@ class TestCollisionWorld : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestCollisionWorld(const std::string& name) : Test(name) {
|
||||
TestCollisionWorld(const etk::String& name) : Test(name) {
|
||||
|
||||
// Create the world
|
||||
m_world = new CollisionWorld();
|
||||
|
@ -29,7 +29,7 @@
|
||||
// Libraries
|
||||
#include <test/Test.hpp>
|
||||
#include <ephysics/collision/broadphase/DynamicAABBTree.hpp>
|
||||
#include <vector>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
/// Reactphysics3D namespace
|
||||
namespace ephysics {
|
||||
@ -38,12 +38,12 @@ class OverlapCallback : public DynamicAABBTreeOverlapCallback {
|
||||
|
||||
public :
|
||||
|
||||
std::vector<int32_t> mOverlapNodes;
|
||||
etk::Vector<int32_t> mOverlapNodes;
|
||||
|
||||
// Called when a overlapping node has been found during the call to
|
||||
// DynamicAABBTree:reportAllShapesOverlappingWithAABB()
|
||||
virtual void notifyOverlappingNode(int32_t nodeId) {
|
||||
mOverlapNodes.push_back(nodeId);
|
||||
mOverlapNodes.pushBack(nodeId);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
@ -59,11 +59,11 @@ class DynamicTreeRaycastCallback : public DynamicAABBTreeRaycastCallback {
|
||||
|
||||
public:
|
||||
|
||||
std::vector<int32_t> mHitNodes;
|
||||
etk::Vector<int32_t> mHitNodes;
|
||||
|
||||
// Called when the AABB of a leaf node is hit by a ray
|
||||
virtual float raycastBroadPhaseShape(int32_t nodeId, const Ray& ray) {
|
||||
mHitNodes.push_back(nodeId);
|
||||
mHitNodes.pushBack(nodeId);
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class TestDynamicAABBTree : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestDynamicAABBTree(const std::string& name): Test(name) {
|
||||
TestDynamicAABBTree(const etk::String& name): Test(name) {
|
||||
|
||||
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class TestPointInside : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestPointInside(const std::string& name) : Test(name) {
|
||||
TestPointInside(const etk::String& name) : Test(name) {
|
||||
|
||||
// Create the world
|
||||
m_world = new CollisionWorld();
|
||||
|
@ -155,8 +155,8 @@ class TestRaycast : public Test {
|
||||
// Triangle meshes
|
||||
TriangleMesh mConcaveTriangleMesh;
|
||||
|
||||
std::vector<vec3> mConcaveMeshVertices;
|
||||
std::vector<uint32_t> mConcaveMeshIndices;
|
||||
etk::Vector<vec3> mConcaveMeshVertices;
|
||||
etk::Vector<uint32_t> mConcaveMeshIndices;
|
||||
TriangleVertexArray* mConcaveMeshVertexArray;
|
||||
float m_heightFieldData[100];
|
||||
|
||||
@ -165,7 +165,7 @@ class TestRaycast : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestRaycast(const std::string& name) : Test(name) {
|
||||
TestRaycast(const etk::String& name) : Test(name) {
|
||||
|
||||
epsilon = float(0.0001);
|
||||
|
||||
@ -267,27 +267,27 @@ class TestRaycast : public Test {
|
||||
mCompoundSphereProxyShape = mCompoundBody->addCollisionShape(mSphereShape, shapeTransform2);
|
||||
|
||||
// Concave Mesh shape
|
||||
mConcaveMeshVertices.push_back(vec3(-2, -3, -4));
|
||||
mConcaveMeshVertices.push_back(vec3(2, -3, -4));
|
||||
mConcaveMeshVertices.push_back(vec3(2, -3, 4));
|
||||
mConcaveMeshVertices.push_back(vec3(-2, -3, 4));
|
||||
mConcaveMeshVertices.push_back(vec3(-2, 3, -4));
|
||||
mConcaveMeshVertices.push_back(vec3(2, 3, -4));
|
||||
mConcaveMeshVertices.push_back(vec3(2, 3, 4));
|
||||
mConcaveMeshVertices.push_back(vec3(-2, 3, 4));
|
||||
mConcaveMeshVertices.pushBack(vec3(-2, -3, -4));
|
||||
mConcaveMeshVertices.pushBack(vec3(2, -3, -4));
|
||||
mConcaveMeshVertices.pushBack(vec3(2, -3, 4));
|
||||
mConcaveMeshVertices.pushBack(vec3(-2, -3, 4));
|
||||
mConcaveMeshVertices.pushBack(vec3(-2, 3, -4));
|
||||
mConcaveMeshVertices.pushBack(vec3(2, 3, -4));
|
||||
mConcaveMeshVertices.pushBack(vec3(2, 3, 4));
|
||||
mConcaveMeshVertices.pushBack(vec3(-2, 3, 4));
|
||||
|
||||
mConcaveMeshIndices.push_back(0); mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(2);
|
||||
mConcaveMeshIndices.push_back(0); mConcaveMeshIndices.push_back(2); mConcaveMeshIndices.push_back(3);
|
||||
mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(2);
|
||||
mConcaveMeshIndices.push_back(2); mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(6);
|
||||
mConcaveMeshIndices.push_back(2); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(3);
|
||||
mConcaveMeshIndices.push_back(2); mConcaveMeshIndices.push_back(6); mConcaveMeshIndices.push_back(7);
|
||||
mConcaveMeshIndices.push_back(0); mConcaveMeshIndices.push_back(3); mConcaveMeshIndices.push_back(4);
|
||||
mConcaveMeshIndices.push_back(3); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(4);
|
||||
mConcaveMeshIndices.push_back(0); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(1);
|
||||
mConcaveMeshIndices.push_back(1); mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(5);
|
||||
mConcaveMeshIndices.push_back(5); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(6);
|
||||
mConcaveMeshIndices.push_back(4); mConcaveMeshIndices.push_back(7); mConcaveMeshIndices.push_back(5);
|
||||
mConcaveMeshIndices.pushBack(0); mConcaveMeshIndices.pushBack(1); mConcaveMeshIndices.push_back(2);
|
||||
mConcaveMeshIndices.pushBack(0); mConcaveMeshIndices.pushBack(2); mConcaveMeshIndices.push_back(3);
|
||||
mConcaveMeshIndices.pushBack(1); mConcaveMeshIndices.pushBack(5); mConcaveMeshIndices.push_back(2);
|
||||
mConcaveMeshIndices.pushBack(2); mConcaveMeshIndices.pushBack(5); mConcaveMeshIndices.push_back(6);
|
||||
mConcaveMeshIndices.pushBack(2); mConcaveMeshIndices.pushBack(7); mConcaveMeshIndices.push_back(3);
|
||||
mConcaveMeshIndices.pushBack(2); mConcaveMeshIndices.pushBack(6); mConcaveMeshIndices.push_back(7);
|
||||
mConcaveMeshIndices.pushBack(0); mConcaveMeshIndices.pushBack(3); mConcaveMeshIndices.push_back(4);
|
||||
mConcaveMeshIndices.pushBack(3); mConcaveMeshIndices.pushBack(7); mConcaveMeshIndices.push_back(4);
|
||||
mConcaveMeshIndices.pushBack(0); mConcaveMeshIndices.pushBack(4); mConcaveMeshIndices.push_back(1);
|
||||
mConcaveMeshIndices.pushBack(1); mConcaveMeshIndices.pushBack(4); mConcaveMeshIndices.push_back(5);
|
||||
mConcaveMeshIndices.pushBack(5); mConcaveMeshIndices.pushBack(7); mConcaveMeshIndices.push_back(6);
|
||||
mConcaveMeshIndices.pushBack(4); mConcaveMeshIndices.pushBack(7); mConcaveMeshIndices.push_back(5);
|
||||
TriangleVertexArray::VertexDataType vertexType = sizeof(float) == 4 ? TriangleVertexArray::VERTEX_FLOAT_TYPE :
|
||||
TriangleVertexArray::VERTEX_DOUBLE_TYPE;
|
||||
mConcaveMeshVertexArray =
|
||||
|
@ -50,7 +50,7 @@ class TestMathematicsFunctions : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
TestMathematicsFunctions(const std::string& name): Test(name) {}
|
||||
TestMathematicsFunctions(const etk::String& name): Test(name) {}
|
||||
|
||||
/// Run the tests
|
||||
void run() {
|
||||
|
@ -54,7 +54,7 @@ class Testetk::Matrix2x2 : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Testetk::Matrix2x2(const std::string& name)
|
||||
Testetk::Matrix2x2(const etk::String& name)
|
||||
: Test(name), mIdentity(etk::Matrix2x2::identity()), mMatrix1(2, 24, -4, 5) {
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class Testetk::Matrix3x3 : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Testetk::Matrix3x3(const std::string& name)
|
||||
Testetk::Matrix3x3(const etk::String& name)
|
||||
: Test(name), mIdentity(etk::Matrix3x3::identity()),
|
||||
mMatrix1(2, 24, 4, 5, -6, 234, -15, 11, 66) {
|
||||
|
||||
|
@ -54,7 +54,7 @@ class Testetk::Quaternion : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Testetk::Quaternion(const std::string& name) : Test(name), mIdentity(Quaternion::identity()) {
|
||||
Testetk::Quaternion(const etk::String& name) : Test(name), mIdentity(Quaternion::identity()) {
|
||||
|
||||
float sinA = sin(float(PI/8.0));
|
||||
float cosA = cos(float(PI/8.0));
|
||||
|
@ -57,7 +57,7 @@ class Testetk::Transform3D : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Testetk::Transform3D(const std::string& name) : Test(name) {
|
||||
Testetk::Transform3D(const etk::String& name) : Test(name) {
|
||||
|
||||
mIdentityetk::Transform3D.setToIdentity();
|
||||
|
||||
|
@ -54,7 +54,7 @@ class Testvec2 : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Testvec2(const std::string& name) : Test(name), mVectorZero(0, 0), mvec34(3, 4) {}
|
||||
Testvec2(const etk::String& name) : Test(name), mVectorZero(0, 0), mvec34(3, 4) {}
|
||||
|
||||
/// Run the tests
|
||||
void run() {
|
||||
|
@ -54,7 +54,7 @@ class Testvec3 : public Test {
|
||||
// ---------- Methods ---------- //
|
||||
|
||||
/// Constructor
|
||||
Testvec3(const std::string& name): Test(name),mVectorZero(0, 0, 0),mvec345(3, 4, 5) {}
|
||||
Testvec3(const etk::String& name): Test(name),mVectorZero(0, 0, 0),mvec345(3, 4, 5) {}
|
||||
|
||||
/// Run the tests
|
||||
void run() {
|
||||
|
@ -36,7 +36,7 @@ int32_t Capsule::totalNbCapsules = 0;
|
||||
// Constructor
|
||||
Capsule::Capsule(float radius, float height, const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
||||
|
||||
// Load the mesh from a file
|
||||
@ -85,7 +85,7 @@ Capsule::Capsule(float radius, float height, const openglframework::vec3& positi
|
||||
// Constructor
|
||||
Capsule::Capsule(float radius, float height, const openglframework::vec3& position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
||||
|
||||
// Load the mesh from a file
|
||||
|
@ -83,12 +83,12 @@ class Capsule : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
Capsule(float radius, float height, const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world, const std::string& meshFolderPath);
|
||||
ephysics::CollisionWorld* world, const etk::String& meshFolderPath);
|
||||
|
||||
/// Constructor
|
||||
Capsule(float radius, float height, const openglframework::vec3& position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshFolderPath);
|
||||
const etk::String& meshFolderPath);
|
||||
|
||||
/// Destructor
|
||||
~Capsule();
|
||||
|
@ -29,7 +29,7 @@
|
||||
// Constructor
|
||||
ConcaveMesh::ConcaveMesh(const openglframework::vec3 &position,
|
||||
ephysics::CollisionWorld* world,
|
||||
const std::string& meshPath)
|
||||
const etk::String& meshPath)
|
||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||
@ -86,7 +86,7 @@ ConcaveMesh::ConcaveMesh(const openglframework::vec3 &position,
|
||||
// Constructor
|
||||
ConcaveMesh::ConcaveMesh(const openglframework::vec3 &position, float mass,
|
||||
ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshPath)
|
||||
const etk::String& meshPath)
|
||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||
|
@ -77,11 +77,11 @@ class ConcaveMesh : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
ConcaveMesh(const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world, const std::string& meshPath);
|
||||
ephysics::CollisionWorld* world, const etk::String& meshPath);
|
||||
|
||||
/// Constructor
|
||||
ConcaveMesh(const openglframework::vec3& position, float mass,
|
||||
ephysics::DynamicsWorld* dynamicsWorld, const std::string& meshPath);
|
||||
ephysics::DynamicsWorld* dynamicsWorld, const etk::String& meshPath);
|
||||
|
||||
/// Destructor
|
||||
~ConcaveMesh();
|
||||
|
@ -36,7 +36,7 @@ int32_t Cone::totalNbCones = 0;
|
||||
// Constructor
|
||||
Cone::Cone(float radius, float height, const openglframework::vec3 &position,
|
||||
ephysics::CollisionWorld* world,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
||||
|
||||
// Load the mesh from a file
|
||||
@ -84,7 +84,7 @@ Cone::Cone(float radius, float height, const openglframework::vec3 &position,
|
||||
// Constructor
|
||||
Cone::Cone(float radius, float height, const openglframework::vec3 &position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
||||
|
||||
// Load the mesh from a file
|
||||
|
@ -83,11 +83,11 @@ class Cone : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
Cone(float radius, float height, const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world, const std::string& meshFolderPath);
|
||||
ephysics::CollisionWorld* world, const etk::String& meshFolderPath);
|
||||
|
||||
/// Constructor
|
||||
Cone(float radius, float height, const openglframework::vec3& position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld, const std::string& meshFolderPath);
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld, const etk::String& meshFolderPath);
|
||||
|
||||
/// Destructor
|
||||
~Cone();
|
||||
|
@ -29,7 +29,7 @@
|
||||
// Constructor
|
||||
ConvexMesh::ConvexMesh(const openglframework::vec3 &position,
|
||||
ephysics::CollisionWorld* world,
|
||||
const std::string& meshPath)
|
||||
const etk::String& meshPath)
|
||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||
@ -80,7 +80,7 @@ ConvexMesh::ConvexMesh(const openglframework::vec3 &position,
|
||||
// Constructor
|
||||
ConvexMesh::ConvexMesh(const openglframework::vec3 &position, float mass,
|
||||
ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshPath)
|
||||
const etk::String& meshPath)
|
||||
: openglframework::Mesh(), mVBOVertices(GL_ARRAY_BUFFER),
|
||||
mVBONormals(GL_ARRAY_BUFFER), mVBOTextureCoords(GL_ARRAY_BUFFER),
|
||||
mVBOIndices(GL_ELEMENT_ARRAY_BUFFER) {
|
||||
|
@ -76,11 +76,11 @@ class ConvexMesh : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
ConvexMesh(const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world, const std::string& meshPath);
|
||||
ephysics::CollisionWorld* world, const etk::String& meshPath);
|
||||
|
||||
/// Constructor
|
||||
ConvexMesh(const openglframework::vec3& position, float mass,
|
||||
ephysics::DynamicsWorld* dynamicsWorld, const std::string& meshPath);
|
||||
ephysics::DynamicsWorld* dynamicsWorld, const etk::String& meshPath);
|
||||
|
||||
/// Destructor
|
||||
~ConvexMesh();
|
||||
|
@ -36,7 +36,7 @@ int32_t Cylinder::totalNbCylinders = 0;
|
||||
// Constructor
|
||||
Cylinder::Cylinder(float radius, float height, const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
||||
|
||||
// Load the mesh from a file
|
||||
@ -84,7 +84,7 @@ Cylinder::Cylinder(float radius, float height, const openglframework::vec3& posi
|
||||
// Constructor
|
||||
Cylinder::Cylinder(float radius, float height, const openglframework::vec3& position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius), mHeight(height) {
|
||||
|
||||
// Load the mesh from a file
|
||||
|
@ -83,11 +83,11 @@ class Cylinder : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
Cylinder(float radius, float height, const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world, const std::string &meshFolderPath);
|
||||
ephysics::CollisionWorld* world, const etk::String &meshFolderPath);
|
||||
|
||||
/// Constructor
|
||||
Cylinder(float radius, float height, const openglframework::vec3& position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld, const std::string &meshFolderPath);
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld, const etk::String &meshFolderPath);
|
||||
|
||||
/// Destructor
|
||||
~Cylinder();
|
||||
|
@ -35,7 +35,7 @@ int32_t Dumbbell::totalNbDumbbells = 0;
|
||||
|
||||
// Constructor
|
||||
Dumbbell::Dumbbell(const openglframework::vec3 &position,
|
||||
ephysics::DynamicsWorld* dynamicsWorld, const std::string& meshFolderPath)
|
||||
ephysics::DynamicsWorld* dynamicsWorld, const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh() {
|
||||
|
||||
// Load the mesh from a file
|
||||
@ -106,7 +106,7 @@ Dumbbell::Dumbbell(const openglframework::vec3 &position,
|
||||
|
||||
// Constructor
|
||||
Dumbbell::Dumbbell(const openglframework::vec3 &position,
|
||||
ephysics::CollisionWorld* world, const std::string& meshFolderPath)
|
||||
ephysics::CollisionWorld* world, const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh() {
|
||||
|
||||
// Load the mesh from a file
|
||||
|
@ -83,11 +83,11 @@ class Dumbbell : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
Dumbbell(const openglframework::vec3& position, ephysics::DynamicsWorld* dynamicsWorld,
|
||||
const std::string& meshFolderPath);
|
||||
const etk::String& meshFolderPath);
|
||||
|
||||
/// Constructor
|
||||
Dumbbell(const openglframework::vec3& position, ephysics::CollisionWorld* world,
|
||||
const std::string& meshFolderPath);
|
||||
const etk::String& meshFolderPath);
|
||||
|
||||
|
||||
/// Destructor
|
||||
|
@ -224,7 +224,7 @@ void HeightField::generateHeightField() {
|
||||
// Generate the graphics mesh to render the height field
|
||||
void HeightField::generateGraphicsMesh() {
|
||||
|
||||
std::vector<uint32_t> indices;
|
||||
etk::Vector<uint32_t> indices;
|
||||
int32_t vertexId = 0;
|
||||
|
||||
for (int32_t i=0; i<NB_POINTS_WIDTH; i++) {
|
||||
@ -234,7 +234,7 @@ void HeightField::generateGraphicsMesh() {
|
||||
float height = originHeight + mHeightData[j * NB_POINTS_WIDTH + i];
|
||||
openglframework::vec3 vertex(-(NB_POINTS_WIDTH - 1) * 0.5f + i, height, -(NB_POINTS_LENGTH - 1) * 0.5f + j);
|
||||
|
||||
m_vertices.push_back(vertex);
|
||||
m_vertices.pushBack(vertex);
|
||||
|
||||
// Triangle indices
|
||||
if ((i < NB_POINTS_WIDTH - 1) && (j < NB_POINTS_LENGTH - 1)) {
|
||||
@ -245,21 +245,21 @@ void HeightField::generateGraphicsMesh() {
|
||||
uint32_t v4 = vertexId + NB_POINTS_LENGTH + 1;
|
||||
|
||||
// First triangle
|
||||
indices.push_back(v1);
|
||||
indices.push_back(v2);
|
||||
indices.push_back(v3);
|
||||
indices.pushBack(v1);
|
||||
indices.pushBack(v2);
|
||||
indices.pushBack(v3);
|
||||
|
||||
// Second triangle
|
||||
indices.push_back(v2);
|
||||
indices.push_back(v4);
|
||||
indices.push_back(v3);
|
||||
indices.pushBack(v2);
|
||||
indices.pushBack(v4);
|
||||
indices.pushBack(v3);
|
||||
}
|
||||
|
||||
vertexId++;
|
||||
}
|
||||
}
|
||||
|
||||
mIndices.push_back(indices);
|
||||
mIndices.pushBack(indices);
|
||||
|
||||
calculateNormals();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ int32_t Sphere::totalNbSpheres = 0;
|
||||
// Constructor
|
||||
Sphere::Sphere(float radius, const openglframework::vec3 &position,
|
||||
ephysics::CollisionWorld* world,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius) {
|
||||
|
||||
// Load the mesh from a file
|
||||
@ -85,7 +85,7 @@ Sphere::Sphere(float radius, const openglframework::vec3 &position,
|
||||
// Constructor
|
||||
Sphere::Sphere(float radius, const openglframework::vec3 &position,
|
||||
float mass, ephysics::DynamicsWorld* world,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: openglframework::Mesh(), mRadius(radius) {
|
||||
|
||||
// Load the mesh from a file
|
||||
|
@ -80,11 +80,11 @@ class Sphere : public openglframework::Mesh, public PhysicsObject {
|
||||
|
||||
/// Constructor
|
||||
Sphere(float radius, const openglframework::vec3& position,
|
||||
ephysics::CollisionWorld* world, const std::string& meshFolderPath);
|
||||
ephysics::CollisionWorld* world, const etk::String& meshFolderPath);
|
||||
|
||||
/// Constructor
|
||||
Sphere(float radius, const openglframework::vec3& position,
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld, const std::string& meshFolderPath);
|
||||
float mass, ephysics::DynamicsWorld* dynamicsWorld, const etk::String& meshFolderPath);
|
||||
|
||||
/// Destructor
|
||||
~Sphere();
|
||||
|
@ -37,7 +37,7 @@ bool VisualContactPoint::mStaticDataCreated = false;
|
||||
|
||||
// Constructor
|
||||
VisualContactPoint::VisualContactPoint(const openglframework::vec3& position,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: mColor(1.0f, 0.0f, 0.0f, 1.0f) {
|
||||
|
||||
// Initialize the position where the mesh will be rendered
|
||||
@ -50,7 +50,7 @@ VisualContactPoint::~VisualContactPoint() {
|
||||
}
|
||||
|
||||
// Load and initialize the mesh for all the contact points
|
||||
void VisualContactPoint::createStaticData(const std::string& meshFolderPath) {
|
||||
void VisualContactPoint::createStaticData(const etk::String& meshFolderPath) {
|
||||
|
||||
if (mStaticDataCreated) return;
|
||||
|
||||
|
@ -73,13 +73,13 @@ class VisualContactPoint : public openglframework::Object3D {
|
||||
|
||||
/// Constructor
|
||||
VisualContactPoint(const openglframework::vec3& position,
|
||||
const std::string &meshFolderPath);
|
||||
const etk::String &meshFolderPath);
|
||||
|
||||
/// Destructor
|
||||
~VisualContactPoint();
|
||||
|
||||
/// Load and initialize the mesh for all the contact points
|
||||
static void createStaticData(const std::string& meshFolderPath);
|
||||
static void createStaticData(const etk::String& meshFolderPath);
|
||||
|
||||
/// Destroy the mesh for the contact points
|
||||
static void destroyStaticData();
|
||||
|
@ -91,7 +91,7 @@ void Mesh::calculateNormals() {
|
||||
// Compute the tangents of the mesh
|
||||
void Mesh::calculateTangents() {
|
||||
|
||||
mTangents = std::vector<vec3>(getNbVertices(), vec3(0, 0, 0));
|
||||
mTangents = etk::Vector<vec3>(getNbVertices(), vec3(0, 0, 0));
|
||||
|
||||
// For each face
|
||||
for (uint32_t i=0; i<getNbFaces(); i++) {
|
||||
@ -144,7 +144,7 @@ void Mesh::calculateBoundingBox(vec3& min, vec3& max) const {
|
||||
min = m_vertices[0];
|
||||
max = m_vertices[0];
|
||||
|
||||
std::vector<vec3>::const_iterator it(m_vertices.begin());
|
||||
etk::Vector<vec3>::const_iterator it(m_vertices.begin());
|
||||
|
||||
// For each vertex of the mesh
|
||||
for (; it != m_vertices.end(); ++it) {
|
||||
|
@ -27,9 +27,9 @@
|
||||
#define MESH_H
|
||||
|
||||
// Libraries
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <ephysics/definitions.hpp>
|
||||
#include <ephysics/maths/vec2.hpp>
|
||||
#include <ephysics/maths/vec3.hpp>
|
||||
@ -49,25 +49,25 @@ class Mesh : public Object3D {
|
||||
// -------------------- Attributes -------------------- //
|
||||
|
||||
// A triplet of vertex indices for each triangle
|
||||
std::vector<std::vector<uint32_t> > mIndices;
|
||||
etk::Vector<etk::Vector<uint32_t> > mIndices;
|
||||
|
||||
// Vertices coordinates (local space)
|
||||
std::vector<vec3> m_vertices;
|
||||
etk::Vector<vec3> m_vertices;
|
||||
|
||||
// Normals coordinates
|
||||
std::vector<vec3> mNormals;
|
||||
etk::Vector<vec3> mNormals;
|
||||
|
||||
// Tangents coordinates
|
||||
std::vector<vec3> mTangents;
|
||||
etk::Vector<vec3> mTangents;
|
||||
|
||||
// Color for each vertex
|
||||
std::vector<Color> mColors;
|
||||
etk::Vector<Color> mColors;
|
||||
|
||||
// UV texture coordinates
|
||||
std::vector<vec2> mUVs;
|
||||
etk::Vector<vec2> mUVs;
|
||||
|
||||
// Textures of the mesh (one for each part of the mesh)
|
||||
std::map<uint32_t, Texture2D> mTextures;
|
||||
etk::Map<uint32_t, Texture2D> mTextures;
|
||||
|
||||
public:
|
||||
|
||||
@ -104,28 +104,28 @@ class Mesh : public Object3D {
|
||||
uint32_t getNbParts() const;
|
||||
|
||||
// Return a reference to the vertices
|
||||
const std::vector<vec3>& getVertices() const;
|
||||
const etk::Vector<vec3>& getVertices() const;
|
||||
|
||||
// Set the vertices of the mesh
|
||||
void setVertices(std::vector<vec3>& vertices);
|
||||
void setVertices(etk::Vector<vec3>& vertices);
|
||||
|
||||
// Return a reference to the normals
|
||||
const std::vector<vec3>& getNormals() const;
|
||||
const etk::Vector<vec3>& getNormals() const;
|
||||
|
||||
// set the normals of the mesh
|
||||
void setNormals(std::vector<vec3>& normals);
|
||||
void setNormals(etk::Vector<vec3>& normals);
|
||||
|
||||
// Return a reference to the UVs
|
||||
const std::vector<vec2>& getUVs() const;
|
||||
const etk::Vector<vec2>& getUVs() const;
|
||||
|
||||
// Set the UV texture coordinates of the mesh
|
||||
void setUVs(std::vector<vec2>& uvs);
|
||||
void setUVs(etk::Vector<vec2>& uvs);
|
||||
|
||||
// Return a reference to the vertex indices
|
||||
const std::vector<uint32_t>& getIndices(uint32_t part = 0) const;
|
||||
const etk::Vector<uint32_t>& getIndices(uint32_t part = 0) const;
|
||||
|
||||
// Set the vertices indices of the mesh
|
||||
void setIndices(std::vector<std::vector<uint32_t> >& indices);
|
||||
void setIndices(etk::Vector<etk::Vector<uint32_t> >& indices);
|
||||
|
||||
// Return the coordinates of a given vertex
|
||||
const vec3& getVertex(uint32_t i) const;
|
||||
@ -218,42 +218,42 @@ inline uint32_t Mesh::getNbParts() const {
|
||||
}
|
||||
|
||||
// Return a reference to the vertices
|
||||
inline const std::vector<vec3>& Mesh::getVertices() const {
|
||||
inline const etk::Vector<vec3>& Mesh::getVertices() const {
|
||||
return m_vertices;
|
||||
}
|
||||
|
||||
// Set the vertices of the mesh
|
||||
inline void Mesh::setVertices(std::vector<vec3>& vertices) {
|
||||
inline void Mesh::setVertices(etk::Vector<vec3>& vertices) {
|
||||
m_vertices = vertices;
|
||||
}
|
||||
|
||||
// Return a reference to the normals
|
||||
inline const std::vector<vec3>& Mesh::getNormals() const {
|
||||
inline const etk::Vector<vec3>& Mesh::getNormals() const {
|
||||
return mNormals;
|
||||
}
|
||||
|
||||
// set the normals of the mesh
|
||||
inline void Mesh::setNormals(std::vector<vec3>& normals) {
|
||||
inline void Mesh::setNormals(etk::Vector<vec3>& normals) {
|
||||
mNormals = normals;
|
||||
}
|
||||
|
||||
// Return a reference to the UVs
|
||||
inline const std::vector<vec2>& Mesh::getUVs() const {
|
||||
inline const etk::Vector<vec2>& Mesh::getUVs() const {
|
||||
return mUVs;
|
||||
}
|
||||
|
||||
// Set the UV texture coordinates of the mesh
|
||||
inline void Mesh::setUVs(std::vector<vec2>& uvs) {
|
||||
inline void Mesh::setUVs(etk::Vector<vec2>& uvs) {
|
||||
mUVs = uvs;
|
||||
}
|
||||
|
||||
// Return a reference to the vertex indices
|
||||
inline const std::vector<uint32_t>& Mesh::getIndices(uint32_t part) const {
|
||||
inline const etk::Vector<uint32_t>& Mesh::getIndices(uint32_t part) const {
|
||||
return mIndices[part];
|
||||
}
|
||||
|
||||
// Set the vertices indices of the mesh
|
||||
inline void Mesh::setIndices(std::vector<std::vector<uint32_t> >& indices) {
|
||||
inline void Mesh::setIndices(etk::Vector<etk::Vector<uint32_t> >& indices) {
|
||||
mIndices = indices;
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ inline void Mesh::setVertexColor(uint32_t i, const Color& color) {
|
||||
if (mColors.size() != m_vertices.size()) {
|
||||
|
||||
// Create the color array with the same size
|
||||
mColors = std::vector<Color>(m_vertices.size());
|
||||
mColors = etk::Vector<Color>(m_vertices.size());
|
||||
}
|
||||
|
||||
mColors[i] = color;
|
||||
@ -309,7 +309,7 @@ inline void Mesh::setColorToAllVertices(const Color& color) {
|
||||
if (mColors.size() != m_vertices.size()) {
|
||||
|
||||
// Create the color array with the same size
|
||||
mColors = std::vector<Color>(m_vertices.size());
|
||||
mColors = etk::Vector<Color>(m_vertices.size());
|
||||
}
|
||||
|
||||
for (size_t v=0; v<m_vertices.size(); v++) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <sstream>
|
||||
#include <locale>
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <etk/Map.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace openglframework;
|
||||
@ -41,7 +41,7 @@ MeshReaderWriter::MeshReaderWriter() {
|
||||
}
|
||||
|
||||
// Load a mesh from a file and returns true if the mesh has been sucessfully loaded
|
||||
void MeshReaderWriter::loadMeshFromFile(const std::string& filename, Mesh& meshToCreate) {
|
||||
void MeshReaderWriter::loadMeshFromFile(const etk::String& filename, Mesh& meshToCreate) {
|
||||
|
||||
// Get the extension of the file
|
||||
uint32_t startPosExtension = filename.find_last_of(".");
|
||||
@ -62,7 +62,7 @@ void MeshReaderWriter::loadMeshFromFile(const std::string& filename, Mesh& meshT
|
||||
}
|
||||
|
||||
// Write a mesh to a file
|
||||
void MeshReaderWriter::writeMeshToFile(const std::string& filename, const Mesh& meshToWrite) {
|
||||
void MeshReaderWriter::writeMeshToFile(const etk::String& filename, const Mesh& meshToWrite) {
|
||||
|
||||
// Get the extension of the file
|
||||
uint32_t startPosExtension = filename.find_last_of(".");
|
||||
@ -97,20 +97,20 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
throw runtime_error(errorMessage);
|
||||
}
|
||||
|
||||
std::string buffer;
|
||||
etk::String buffer;
|
||||
string line, tmp;
|
||||
int32_t id1, id2, id3, id4;
|
||||
int32_t nId1, nId2, nId3, nId4;
|
||||
int32_t tId1, tId2, tId3, tId4;
|
||||
float v1, v2, v3;
|
||||
size_t found1, found2;
|
||||
std::vector<bool> isQuad;
|
||||
std::vector<vec3> vertices;
|
||||
std::vector<vec3> normals;
|
||||
std::vector<vec2> uvs;
|
||||
std::vector<uint32_t> verticesIndices;
|
||||
std::vector<uint32_t> normalsIndices;
|
||||
std::vector<uint32_t> uvsIndices;
|
||||
etk::Vector<bool> isQuad;
|
||||
etk::Vector<vec3> vertices;
|
||||
etk::Vector<vec3> normals;
|
||||
etk::Vector<vec2> uvs;
|
||||
etk::Vector<uint32_t> verticesIndices;
|
||||
etk::Vector<uint32_t> normalsIndices;
|
||||
etk::Vector<uint32_t> uvsIndices;
|
||||
|
||||
// ---------- Collect the data from the file ---------- //
|
||||
|
||||
@ -118,7 +118,7 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
while(std::getline(meshFile, buffer)) {
|
||||
|
||||
std::istringstream lineStream(buffer);
|
||||
std::string word;
|
||||
etk::String word;
|
||||
lineStream >> word;
|
||||
std::transform(word.begin(), word.end(), word.begin(), ::tolower);
|
||||
if(word == "usemtl") { // Material definition
|
||||
@ -128,15 +128,15 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
}
|
||||
else if(word == "v") { // Vertex position
|
||||
sscanf(buffer.c_str(), "%*s %f %f %f", &v1, &v2, &v3);
|
||||
vertices.push_back(vec3(v1, v2, v3));
|
||||
vertices.pushBack(vec3(v1, v2, v3));
|
||||
}
|
||||
else if(word == "vt") { // Vertex texture coordinate
|
||||
sscanf(buffer.c_str(), "%*s %f %f", &v1, &v2);
|
||||
uvs.push_back(vec2(v1,v2));
|
||||
uvs.pushBack(vec2(v1,v2));
|
||||
}
|
||||
else if(word == "vn") { // Vertex normal
|
||||
sscanf(buffer.c_str(), "%*s %f %f %f", &v1, &v2, &v3);
|
||||
normals.push_back(vec3(v1 ,v2, v3));
|
||||
normals.pushBack(vec3(v1 ,v2, v3));
|
||||
}
|
||||
else if (word == "f") { // Face
|
||||
line = buffer;
|
||||
@ -166,10 +166,10 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
if(found2 == string::npos) {
|
||||
int32_t n = sscanf(buffer.c_str(), "%*s %d/%d %d/%d %d/%d %d/%d", &id1, &tId1, &id2, &tId2, &id3, &tId3, &id4, &tId4);
|
||||
if (n == 8) isFaceQuad = true;
|
||||
uvsIndices.push_back(tId1-1);
|
||||
uvsIndices.push_back(tId2-1);
|
||||
uvsIndices.push_back(tId3-1);
|
||||
if (isFaceQuad) uvsIndices.push_back(tId4-1);
|
||||
uvsIndices.pushBack(tId1-1);
|
||||
uvsIndices.pushBack(tId2-1);
|
||||
uvsIndices.pushBack(tId3-1);
|
||||
if (isFaceQuad) uvsIndices.pushBack(tId4-1);
|
||||
}
|
||||
else {
|
||||
tmp = line.substr(found1+1);
|
||||
@ -184,22 +184,22 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
else {
|
||||
int32_t n = sscanf(buffer.c_str(), "%*s %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d", &id1, &tId1, &nId1, &id2, &tId2, &nId2, &id3, &tId3, &nId3, &id4, &tId4, &nId4);
|
||||
if (n == 12) isFaceQuad = true;
|
||||
uvsIndices.push_back(tId1-1);
|
||||
uvsIndices.push_back(tId2-1);
|
||||
uvsIndices.push_back(tId3-1);
|
||||
if (isFaceQuad) uvsIndices.push_back(tId4-1);
|
||||
uvsIndices.pushBack(tId1-1);
|
||||
uvsIndices.pushBack(tId2-1);
|
||||
uvsIndices.pushBack(tId3-1);
|
||||
if (isFaceQuad) uvsIndices.pushBack(tId4-1);
|
||||
}
|
||||
normalsIndices.push_back(nId1-1);
|
||||
normalsIndices.push_back(nId2-1);
|
||||
normalsIndices.push_back(nId3-1);
|
||||
if (isFaceQuad) normalsIndices.push_back(nId4-1);
|
||||
normalsIndices.pushBack(nId1-1);
|
||||
normalsIndices.pushBack(nId2-1);
|
||||
normalsIndices.pushBack(nId3-1);
|
||||
if (isFaceQuad) normalsIndices.pushBack(nId4-1);
|
||||
}
|
||||
}
|
||||
verticesIndices.push_back(id1-1);
|
||||
verticesIndices.push_back(id2-1);
|
||||
verticesIndices.push_back(id3-1);
|
||||
if (isFaceQuad) verticesIndices.push_back((id4-1));
|
||||
isQuad.push_back(isFaceQuad);
|
||||
verticesIndices.pushBack(id1-1);
|
||||
verticesIndices.pushBack(id2-1);
|
||||
verticesIndices.pushBack(id3-1);
|
||||
if (isFaceQuad) verticesIndices.pushBack((id4-1));
|
||||
isQuad.pushBack(isFaceQuad);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
meshToCreate.destroy();
|
||||
|
||||
// Mesh data
|
||||
vector<std::vector<uint32_t> > meshIndices;
|
||||
vector<etk::Vector<uint32_t> > meshIndices;
|
||||
vector<vec3> meshNormals;
|
||||
if (!normals.empty()) meshNormals = vector<vec3>(vertices.size(), vec3(0, 0, 0));
|
||||
vector<vec2> meshUVs;
|
||||
@ -225,7 +225,7 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
|
||||
// Fill in the vertex indices
|
||||
// We also triangulate each quad face
|
||||
meshIndices.push_back(std::vector<uint32_t>());
|
||||
meshIndices.pushBack(etk::Vector<uint32_t>());
|
||||
for(size_t i = 0, j = 0; i < verticesIndices.size(); j++) {
|
||||
|
||||
// Get the current vertex IDs
|
||||
@ -251,9 +251,9 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
if (!isQuad[j]) {
|
||||
|
||||
// Add the vertex indices
|
||||
meshIndices[meshPart].push_back(i1);
|
||||
meshIndices[meshPart].push_back(i2);
|
||||
meshIndices[meshPart].push_back(i3);
|
||||
meshIndices[meshPart].pushBack(i1);
|
||||
meshIndices[meshPart].pushBack(i2);
|
||||
meshIndices[meshPart].pushBack(i3);
|
||||
|
||||
i+=3;
|
||||
}
|
||||
@ -272,20 +272,20 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
float a1 = v13.dot(v12);
|
||||
float a2 = v13.dot(v14);
|
||||
if((a1 >= 0 && a2 <= 0) || (a1 <= 0 && a2 >= 0)) {
|
||||
meshIndices[meshPart].push_back(i1);
|
||||
meshIndices[meshPart].push_back(i2);
|
||||
meshIndices[meshPart].push_back(i3);
|
||||
meshIndices[meshPart].push_back(i1);
|
||||
meshIndices[meshPart].push_back(i3);
|
||||
meshIndices[meshPart].push_back(i4);
|
||||
meshIndices[meshPart].pushBack(i1);
|
||||
meshIndices[meshPart].pushBack(i2);
|
||||
meshIndices[meshPart].pushBack(i3);
|
||||
meshIndices[meshPart].pushBack(i1);
|
||||
meshIndices[meshPart].pushBack(i3);
|
||||
meshIndices[meshPart].pushBack(i4);
|
||||
}
|
||||
else {
|
||||
meshIndices[meshPart].push_back(i1);
|
||||
meshIndices[meshPart].push_back(i2);
|
||||
meshIndices[meshPart].push_back(i4);
|
||||
meshIndices[meshPart].push_back(i2);
|
||||
meshIndices[meshPart].push_back(i3);
|
||||
meshIndices[meshPart].push_back(i4);
|
||||
meshIndices[meshPart].pushBack(i1);
|
||||
meshIndices[meshPart].pushBack(i2);
|
||||
meshIndices[meshPart].pushBack(i4);
|
||||
meshIndices[meshPart].pushBack(i2);
|
||||
meshIndices[meshPart].pushBack(i3);
|
||||
meshIndices[meshPart].pushBack(i4);
|
||||
}
|
||||
|
||||
// Add the vertex normal
|
||||
@ -313,13 +313,13 @@ void MeshReaderWriter::loadOBJFile(const string &filename, Mesh& meshToCreate) {
|
||||
}
|
||||
|
||||
// Store a mesh int32_to a OBJ file
|
||||
void MeshReaderWriter::writeOBJFile(const std::string& filename, const Mesh& meshToWrite) {
|
||||
void MeshReaderWriter::writeOBJFile(const etk::String& filename, const Mesh& meshToWrite) {
|
||||
std::ofstream file(filename.c_str());
|
||||
|
||||
// Geth the mesh data
|
||||
const std::vector<vec3>& vertices = meshToWrite.getVertices();
|
||||
const std::vector<vec3>& normals = meshToWrite.getNormals();
|
||||
const std::vector<vec2>& uvs = meshToWrite.getUVs();
|
||||
const etk::Vector<vec3>& vertices = meshToWrite.getVertices();
|
||||
const etk::Vector<vec3>& normals = meshToWrite.getNormals();
|
||||
const etk::Vector<vec2>& uvs = meshToWrite.getUVs();
|
||||
|
||||
// If we can open the file
|
||||
if (file.is_open()) {
|
||||
@ -363,7 +363,7 @@ void MeshReaderWriter::writeOBJFile(const std::string& filename, const Mesh& mes
|
||||
for (uint32_t p=0; p<meshToWrite.getNbParts(); p++) {
|
||||
|
||||
// Get the indices of the part
|
||||
const std::vector<uint32_t>& indices = meshToWrite.getIndices(p);
|
||||
const etk::Vector<uint32_t>& indices = meshToWrite.getIndices(p);
|
||||
|
||||
// For each index of the part
|
||||
for (uint32_t i=0; i<indices.size(); i+=3) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define MESH_LOADER_H
|
||||
|
||||
// Libraries
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <stdexcept>
|
||||
#include <ephysics/Mesh.hpp>
|
||||
|
||||
@ -47,20 +47,20 @@ class MeshReaderWriter {
|
||||
MeshReaderWriter();
|
||||
|
||||
// Load an OBJ file with a triangular or quad mesh
|
||||
static void loadOBJFile(const std::string& filename, Mesh& meshToCreate);
|
||||
static void loadOBJFile(const etk::String& filename, Mesh& meshToCreate);
|
||||
|
||||
// Store a mesh int32_to a OBJ file
|
||||
static void writeOBJFile(const std::string& filename, const Mesh &meshToWrite);
|
||||
static void writeOBJFile(const etk::String& filename, const Mesh &meshToWrite);
|
||||
|
||||
public :
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
// Read a mesh from a file
|
||||
static void loadMeshFromFile(const std::string& filename, Mesh& meshToCreate);
|
||||
static void loadMeshFromFile(const etk::String& filename, Mesh& meshToCreate);
|
||||
|
||||
// Write a mesh to a file
|
||||
static void writeMeshToFile(const std::string& filename, const Mesh& meshToWrite);
|
||||
static void writeMeshToFile(const etk::String& filename, const Mesh& meshToWrite);
|
||||
};
|
||||
|
||||
// Class VertexMergingData
|
||||
|
@ -39,7 +39,7 @@ Shader::Shader() : mProgramObjectID(0) {
|
||||
}
|
||||
|
||||
// Constructor with arguments
|
||||
Shader::Shader(const std::string vertexShaderFilename, const std::string fragmentShaderFilename)
|
||||
Shader::Shader(const etk::String vertexShaderFilename, const etk::String fragmentShaderFilename)
|
||||
: mProgramObjectID(0) {
|
||||
|
||||
// Create the shader
|
||||
@ -52,8 +52,8 @@ Shader::~Shader() {
|
||||
}
|
||||
|
||||
// Create the shader
|
||||
bool Shader::create(const std::string vertexShaderFilename,
|
||||
const std::string fragmentShaderFilename) {
|
||||
bool Shader::create(const etk::String vertexShaderFilename,
|
||||
const etk::String fragmentShaderFilename) {
|
||||
|
||||
// Set the shader filenames
|
||||
mFilenameVertexShader = vertexShaderFilename;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <ephysics/maths/vec2.hpp>
|
||||
#include <ephysics/maths/vec3.hpp>
|
||||
#include <ephysics/maths/Vector4.hpp>
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <exception>
|
||||
@ -51,7 +51,7 @@ class Shader {
|
||||
GLuint32_t mProgramObjectID;
|
||||
|
||||
// Filenames of the vertex and fragment shaders
|
||||
std::string mFilenameVertexShader, mFilenameFragmentShader;
|
||||
etk::String mFilenameVertexShader, mFilenameFragmentShader;
|
||||
|
||||
public :
|
||||
|
||||
@ -61,14 +61,14 @@ class Shader {
|
||||
Shader();
|
||||
|
||||
// Constructor with arguments
|
||||
Shader(const std::string vertexShaderFilename, const std::string fragmentShaderFilename);
|
||||
Shader(const etk::String vertexShaderFilename, const etk::String fragmentShaderFilename);
|
||||
|
||||
// Destructor
|
||||
~Shader();
|
||||
|
||||
// Create the shader
|
||||
bool create(const std::string vertexShaderFilename,
|
||||
const std::string fragmentShaderFilename);
|
||||
bool create(const etk::String vertexShaderFilename,
|
||||
const etk::String fragmentShaderFilename);
|
||||
|
||||
// Clear the shader
|
||||
void destroy();
|
||||
@ -80,57 +80,57 @@ class Shader {
|
||||
void unbind() const;
|
||||
|
||||
// Return the location of a uniform variable inside a shader program
|
||||
GLint32_t getUniformLocation(const std::string& variableName, bool errorIfMissing = true) const;
|
||||
GLint32_t getUniformLocation(const etk::String& variableName, bool errorIfMissing = true) const;
|
||||
|
||||
// Return the location of an attribute variable inside a shader program
|
||||
GLint32_t getAttribLocation(const std::string& variableName, bool errorIfMissing = true) const;
|
||||
GLint32_t getAttribLocation(const etk::String& variableName, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a float uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setFloatUniform(const std::string& variableName, float value, bool errorIfMissing = true) const;
|
||||
void setFloatUniform(const etk::String& variableName, float value, bool errorIfMissing = true) const;
|
||||
|
||||
// Set an int32_t uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setIntUniform(const std::string& variableName, int32_t value, bool errorIfMissing = true) const;
|
||||
void setIntUniform(const etk::String& variableName, int32_t value, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a vector 2 uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setvec2Uniform(const std::string& variableName, const vec2& v, bool errorIfMissing = true) const;
|
||||
void setvec2Uniform(const etk::String& variableName, const vec2& v, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a vector 3 uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setvec3Uniform(const std::string& variableName, const vec3& v, bool errorIfMissing = true) const;
|
||||
void setvec3Uniform(const etk::String& variableName, const vec3& v, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a vector 4 uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setVector4Uniform(const std::string& variableName, const Vector4 &v, bool errorIfMissing = true) const;
|
||||
void setVector4Uniform(const etk::String& variableName, const Vector4 &v, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a 3x3 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setetk::Matrix3x3Uniform(const std::string& variableName, const float* matrix,
|
||||
void setetk::Matrix3x3Uniform(const etk::String& variableName, const float* matrix,
|
||||
bool transpose = false, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a 3x3 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setetk::Matrix3x3Uniform(const std::string& variableName, const Matrix3& matrix, bool errorIfMissing = true) const;
|
||||
void setetk::Matrix3x3Uniform(const etk::String& variableName, const Matrix3& matrix, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a 4x4 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setMatrix4x4Uniform(const std::string& variableName, const float* matrix,
|
||||
void setMatrix4x4Uniform(const etk::String& variableName, const float* matrix,
|
||||
bool transpose = false, bool errorIfMissing = true) const;
|
||||
|
||||
// Set a 4x4 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
void setMatrix4x4Uniform(const std::string& variableName, const Matrix4& matrix, bool errorIfMissing = true) const;
|
||||
void setMatrix4x4Uniform(const etk::String& variableName, const Matrix4& matrix, bool errorIfMissing = true) const;
|
||||
|
||||
// Return the shader object program ID
|
||||
GLuint32_t getProgramObjectId() const;
|
||||
@ -152,7 +152,7 @@ inline void Shader::unbind() const {
|
||||
}
|
||||
|
||||
// Return the location of a uniform variable inside a shader program
|
||||
inline GLint32_t Shader::getUniformLocation(const std::string& variableName, bool errorIfMissing) const {
|
||||
inline GLint32_t Shader::getUniformLocation(const etk::String& variableName, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = glGetUniformLocation(mProgramObjectID, variableName.c_str());
|
||||
if (location == -1 && errorIfMissing) {
|
||||
@ -166,7 +166,7 @@ inline GLint32_t Shader::getUniformLocation(const std::string& variableName, boo
|
||||
}
|
||||
|
||||
// Return the location of an attribute variable inside a shader program
|
||||
inline GLint32_t Shader::getAttribLocation(const std::string& variableName, bool errorIfMissing) const {
|
||||
inline GLint32_t Shader::getAttribLocation(const etk::String& variableName, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = glGetAttribLocation(mProgramObjectID, variableName.c_str());
|
||||
if (location == -1 && errorIfMissing) {
|
||||
@ -190,7 +190,7 @@ inline void Shader::destroy() {
|
||||
// Set a float uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setFloatUniform(const std::string& variableName, float value, bool errorIfMissing) const {
|
||||
inline void Shader::setFloatUniform(const etk::String& variableName, float value, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
if (location != -1) {
|
||||
@ -201,7 +201,7 @@ inline void Shader::setFloatUniform(const std::string& variableName, float value
|
||||
// Set an int32_t uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setIntUniform(const std::string& variableName, int32_t value, bool errorIfMissing) const {
|
||||
inline void Shader::setIntUniform(const etk::String& variableName, int32_t value, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
if (location != -1) {
|
||||
@ -212,7 +212,7 @@ inline void Shader::setIntUniform(const std::string& variableName, int32_t value
|
||||
// Set a vector 2 uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setvec2Uniform(const std::string& variableName, const vec2& v, bool errorIfMissing) const {
|
||||
inline void Shader::setvec2Uniform(const etk::String& variableName, const vec2& v, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
if (location != -1) {
|
||||
@ -223,7 +223,7 @@ inline void Shader::setvec2Uniform(const std::string& variableName, const vec2&
|
||||
// Set a vector 3 uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setvec3Uniform(const std::string& variableName, const vec3 &v, bool errorIfMissing) const {
|
||||
inline void Shader::setvec3Uniform(const etk::String& variableName, const vec3 &v, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
if (location != -1) {
|
||||
@ -234,7 +234,7 @@ inline void Shader::setvec3Uniform(const std::string& variableName, const vec3 &
|
||||
// Set a vector 4 uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setVector4Uniform(const std::string& variableName, const Vector4& v, bool errorIfMissing) const {
|
||||
inline void Shader::setVector4Uniform(const etk::String& variableName, const Vector4& v, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
if (location != -1) {
|
||||
@ -245,7 +245,7 @@ inline void Shader::setVector4Uniform(const std::string& variableName, const Vec
|
||||
// Set a 4x4 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setetk::Matrix3x3Uniform(const std::string& variableName, const float* matrix,
|
||||
inline void Shader::setetk::Matrix3x3Uniform(const etk::String& variableName, const float* matrix,
|
||||
bool transpose, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
@ -257,7 +257,7 @@ inline void Shader::setetk::Matrix3x3Uniform(const std::string& variableName, co
|
||||
// Set a 3x3 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setetk::Matrix3x3Uniform(const std::string& variableName, const Matrix3& matrix, bool errorIfMissing) const {
|
||||
inline void Shader::setetk::Matrix3x3Uniform(const etk::String& variableName, const Matrix3& matrix, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLfloat mat[9];
|
||||
for (int32_t i=0; i<3; i++) {
|
||||
@ -274,7 +274,7 @@ inline void Shader::setetk::Matrix3x3Uniform(const std::string& variableName, co
|
||||
// Set a 4x4 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setMatrix4x4Uniform(const std::string& variableName, const float* matrix,
|
||||
inline void Shader::setMatrix4x4Uniform(const etk::String& variableName, const float* matrix,
|
||||
bool transpose, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLint32_t location = getUniformLocation(variableName, errorIfMissing);
|
||||
@ -286,7 +286,7 @@ inline void Shader::setMatrix4x4Uniform(const std::string& variableName, const f
|
||||
// Set a 4x4 matrix uniform value to this shader (be careful if the uniform is not
|
||||
// used in the shader, the compiler will remove it, then when you will try
|
||||
// to set it, an assert will occur)
|
||||
inline void Shader::setMatrix4x4Uniform(const std::string& variableName, const Matrix4& matrix, bool errorIfMissing) const {
|
||||
inline void Shader::setMatrix4x4Uniform(const etk::String& variableName, const Matrix4& matrix, bool errorIfMissing) const {
|
||||
assert(mProgramObjectID != 0);
|
||||
GLfloat mat[16];
|
||||
for (int32_t i=0; i<4; i++) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <ephysics/Texture2D.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
|
||||
// Namespaces
|
||||
using namespace openglframework;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#define TEXTURE2D_H
|
||||
|
||||
// Libraries
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#include <cassert>
|
||||
#include <ephysics/definitions.hpp>
|
||||
#include <nanogui/opengl.hpp>
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
// Librairies
|
||||
#include <ephysics/TextureReaderWriter.hpp>
|
||||
#include <string>
|
||||
#include <etk/String.hpp>
|
||||
#ifdef USE_JPEG_TEXTURE
|
||||
#include <jpeglib.hpp>
|
||||
#include <jerror.hpp>
|
||||
@ -60,7 +60,7 @@ typedef struct {
|
||||
#pragma pack(pop)
|
||||
|
||||
// Load a texture from a file
|
||||
void TextureReaderWriter::loadTextureFromFile(const std::string& filename,
|
||||
void TextureReaderWriter::loadTextureFromFile(const etk::String& filename,
|
||||
Texture2D& textureToCreate) {
|
||||
|
||||
// Get the extension of the file
|
||||
@ -87,7 +87,7 @@ void TextureReaderWriter::loadTextureFromFile(const std::string& filename,
|
||||
}
|
||||
|
||||
// Write a texture to a file
|
||||
void TextureReaderWriter::writeTextureToFile(const std::string& filename,const Texture2D& texture) {
|
||||
void TextureReaderWriter::writeTextureToFile(const etk::String& filename,const Texture2D& texture) {
|
||||
|
||||
// Get the extension of the file
|
||||
uint32_t startPosExtension = filename.find_last_of(".");
|
||||
@ -113,7 +113,7 @@ void TextureReaderWriter::writeTextureToFile(const std::string& filename,const T
|
||||
}
|
||||
|
||||
// Load a TGA picture
|
||||
void TextureReaderWriter::readTGAPicture(const std::string &filename, Texture2D& textureToCreate) {
|
||||
void TextureReaderWriter::readTGAPicture(const etk::String &filename, Texture2D& textureToCreate) {
|
||||
|
||||
// Open the file
|
||||
std::ifstream stream(filename.c_str(), std::ios::binary);
|
||||
@ -158,7 +158,7 @@ void TextureReaderWriter::readTGAPicture(const std::string &filename, Texture2D&
|
||||
|
||||
|
||||
// Write a TGA picture
|
||||
void TextureReaderWriter::writeTGAPicture(const std::string& filename, const Texture2D& texture) {
|
||||
void TextureReaderWriter::writeTGAPicture(const etk::String& filename, const Texture2D& texture) {
|
||||
assert(texture.getID() != 0);
|
||||
|
||||
// Bind the corresponding texture
|
||||
@ -223,7 +223,7 @@ void TextureReaderWriter::writeTGAPicture(const std::string& filename, const Tex
|
||||
#ifdef USE_JPEG_TEXTURE
|
||||
|
||||
// Read a JPEG picture
|
||||
void TextureReaderWriter::readJPEGPicture(const std::string& filename, Texture2D& textureToCreate) {
|
||||
void TextureReaderWriter::readJPEGPicture(const etk::String& filename, Texture2D& textureToCreate) {
|
||||
|
||||
struct jpeg_decompress_struct info;
|
||||
struct jpeg_error_mgr error;
|
||||
@ -278,7 +278,7 @@ void TextureReaderWriter::readJPEGPicture(const std::string& filename, Texture2D
|
||||
}
|
||||
|
||||
// Write a JPEG picture
|
||||
void TextureReaderWriter::writeJPEGPicture(const std::string& filename, const Texture2D& texture) {
|
||||
void TextureReaderWriter::writeJPEGPicture(const etk::String& filename, const Texture2D& texture) {
|
||||
|
||||
struct jpeg_compress_struct info;
|
||||
struct jpeg_error_mgr error;
|
||||
|
@ -52,26 +52,26 @@ class TextureReaderWriter {
|
||||
TextureReaderWriter();
|
||||
|
||||
// Read a TGA picture
|
||||
static void readTGAPicture(const std::string& filename, Texture2D& textureToCreate);
|
||||
static void readTGAPicture(const etk::String& filename, Texture2D& textureToCreate);
|
||||
|
||||
// Write a TGA picture
|
||||
static void writeTGAPicture(const std::string& filename, const Texture2D& texture);
|
||||
static void writeTGAPicture(const etk::String& filename, const Texture2D& texture);
|
||||
|
||||
// Read a JPEG picture
|
||||
static void readJPEGPicture(const std::string& filename, Texture2D& textureToCreate);
|
||||
static void readJPEGPicture(const etk::String& filename, Texture2D& textureToCreate);
|
||||
|
||||
// Write a JPEG picture
|
||||
static void writeJPEGPicture(const std::string& filename, const Texture2D& texture);
|
||||
static void writeJPEGPicture(const etk::String& filename, const Texture2D& texture);
|
||||
|
||||
public :
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
// Load a texture from a file
|
||||
static void loadTextureFromFile(const std::string& filename, Texture2D& textureToCreate);
|
||||
static void loadTextureFromFile(const etk::String& filename, Texture2D& textureToCreate);
|
||||
|
||||
// Write a texture to a file
|
||||
static void writeTextureToFile(const std::string& filename, const Texture2D& texture);
|
||||
static void writeTextureToFile(const etk::String& filename, const Texture2D& texture);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ using namespace openglframework;
|
||||
using namespace collisionshapesscene;
|
||||
|
||||
// Constructor
|
||||
CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
CollisionShapesScene::CollisionShapesScene(const etk::String& name)
|
||||
: SceneDemo(name, SCENE_RADIUS) {
|
||||
|
||||
std::string meshFolderPath("meshes/");
|
||||
etk::String meshFolderPath("meshes/");
|
||||
|
||||
// Compute the radius and the center of the scene
|
||||
openglframework::vec3 center(0, 5, 0);
|
||||
@ -73,7 +73,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the mesh the list of dumbbells in the scene
|
||||
mDumbbells.push_back(dumbbell);
|
||||
mDumbbells.pushBack(dumbbell);
|
||||
}
|
||||
|
||||
// Create all the boxes of the scene
|
||||
@ -97,7 +97,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the sphere the list of sphere in the scene
|
||||
mBoxes.push_back(box);
|
||||
mBoxes.pushBack(box);
|
||||
}
|
||||
|
||||
// Create all the spheres of the scene
|
||||
@ -125,7 +125,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the sphere the list of sphere in the scene
|
||||
mSpheres.push_back(sphere);
|
||||
mSpheres.pushBack(sphere);
|
||||
}
|
||||
|
||||
// Create all the cones of the scene
|
||||
@ -153,7 +153,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the cone the list of sphere in the scene
|
||||
mCones.push_back(cone);
|
||||
mCones.pushBack(cone);
|
||||
}
|
||||
|
||||
// Create all the cylinders of the scene
|
||||
@ -181,7 +181,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the cylinder the list of sphere in the scene
|
||||
mCylinders.push_back(cylinder);
|
||||
mCylinders.pushBack(cylinder);
|
||||
}
|
||||
|
||||
// Create all the capsules of the scene
|
||||
@ -208,7 +208,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the cylinder the list of sphere in the scene
|
||||
mCapsules.push_back(capsule);
|
||||
mCapsules.pushBack(capsule);
|
||||
}
|
||||
|
||||
// Create all the convex meshes of the scene
|
||||
@ -232,7 +232,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.2));
|
||||
|
||||
// Add the mesh the list of sphere in the scene
|
||||
mConvexMeshes.push_back(mesh);
|
||||
mConvexMeshes.pushBack(mesh);
|
||||
}
|
||||
|
||||
// ---------- Create the floor ---------
|
||||
@ -290,7 +290,7 @@ CollisionShapesScene::CollisionShapesScene(const std::string& name)
|
||||
CollisionShapesScene::~CollisionShapesScene() {
|
||||
|
||||
// Destroy all the boxes of the scene
|
||||
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
for (etk::Vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
|
||||
@ -300,7 +300,7 @@ CollisionShapesScene::~CollisionShapesScene() {
|
||||
}
|
||||
|
||||
// Destroy all the sphere of the scene
|
||||
for (std::vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
|
||||
for (etk::Vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
|
||||
@ -310,7 +310,7 @@ CollisionShapesScene::~CollisionShapesScene() {
|
||||
}
|
||||
|
||||
// Destroy all the cones of the scene
|
||||
for (std::vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
|
||||
for (etk::Vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
|
||||
@ -320,7 +320,7 @@ CollisionShapesScene::~CollisionShapesScene() {
|
||||
}
|
||||
|
||||
// Destroy all the cylinders of the scene
|
||||
for (std::vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
|
||||
for (etk::Vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
|
||||
@ -330,7 +330,7 @@ CollisionShapesScene::~CollisionShapesScene() {
|
||||
}
|
||||
|
||||
// Destroy all the capsules of the scene
|
||||
for (std::vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
|
||||
for (etk::Vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
mDynamicsWorld->destroyRigidBody((*it)->getRigidBody());
|
||||
@ -340,7 +340,7 @@ CollisionShapesScene::~CollisionShapesScene() {
|
||||
}
|
||||
|
||||
// Destroy all the convex meshes of the scene
|
||||
for (std::vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
|
||||
for (etk::Vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
|
||||
it != mConvexMeshes.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
@ -351,7 +351,7 @@ CollisionShapesScene::~CollisionShapesScene() {
|
||||
}
|
||||
|
||||
// Destroy all the dumbbell of the scene
|
||||
for (std::vector<Dumbbell*>::iterator it = mDumbbells.begin();
|
||||
for (etk::Vector<Dumbbell*>::iterator it = mDumbbells.begin();
|
||||
it != mDumbbells.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
@ -400,42 +400,42 @@ void CollisionShapesScene::update() {
|
||||
SceneDemo::update();
|
||||
|
||||
// Update the position and orientation of the boxes
|
||||
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
for (etk::Vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
(*it)->updateetk::Transform3D(mInterpolationFactor);
|
||||
}
|
||||
|
||||
// Update the position and orientation of the sphere
|
||||
for (std::vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
|
||||
for (etk::Vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
(*it)->updateetk::Transform3D(mInterpolationFactor);
|
||||
}
|
||||
|
||||
// Update the position and orientation of the cones
|
||||
for (std::vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
|
||||
for (etk::Vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
(*it)->updateetk::Transform3D(mInterpolationFactor);
|
||||
}
|
||||
|
||||
// Update the position and orientation of the cylinders
|
||||
for (std::vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
|
||||
for (etk::Vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
(*it)->updateetk::Transform3D(mInterpolationFactor);
|
||||
}
|
||||
|
||||
// Update the position and orientation of the capsules
|
||||
for (std::vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
|
||||
for (etk::Vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
(*it)->updateetk::Transform3D(mInterpolationFactor);
|
||||
}
|
||||
|
||||
// Update the position and orientation of the convex meshes
|
||||
for (std::vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
|
||||
for (etk::Vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
|
||||
it != mConvexMeshes.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
@ -443,7 +443,7 @@ void CollisionShapesScene::update() {
|
||||
}
|
||||
|
||||
// Update the position and orientation of the dumbbells
|
||||
for (std::vector<Dumbbell*>::iterator it = mDumbbells.begin();
|
||||
for (etk::Vector<Dumbbell*>::iterator it = mDumbbells.begin();
|
||||
it != mDumbbells.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
@ -463,38 +463,38 @@ void CollisionShapesScene::renderSinglePass(openglframework::Shader& shader,
|
||||
shader.bind();
|
||||
|
||||
// Render all the boxes of the scene
|
||||
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
for (etk::Vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
// Render all the sphere of the scene
|
||||
for (std::vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
|
||||
for (etk::Vector<Sphere*>::iterator it = mSpheres.begin(); it != mSpheres.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
// Render all the cones of the scene
|
||||
for (std::vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
|
||||
for (etk::Vector<Cone*>::iterator it = mCones.begin(); it != mCones.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
// Render all the cylinders of the scene
|
||||
for (std::vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
|
||||
for (etk::Vector<Cylinder*>::iterator it = mCylinders.begin(); it != mCylinders.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
// Render all the capsules of the scene
|
||||
for (std::vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
|
||||
for (etk::Vector<Capsule*>::iterator it = mCapsules.begin(); it != mCapsules.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
// Render all the convex meshes of the scene
|
||||
for (std::vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
|
||||
for (etk::Vector<ConvexMesh*>::iterator it = mConvexMeshes.begin();
|
||||
it != mConvexMeshes.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
// Render all the dumbbells of the scene
|
||||
for (std::vector<Dumbbell*>::iterator it = mDumbbells.begin();
|
||||
for (etk::Vector<Dumbbell*>::iterator it = mDumbbells.begin();
|
||||
it != mDumbbells.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
@ -76,21 +76,21 @@ class CollisionShapesScene : public SceneDemo {
|
||||
// -------------------- Attributes -------------------- //
|
||||
|
||||
/// All the spheres of the scene
|
||||
std::vector<Box*> mBoxes;
|
||||
etk::Vector<Box*> mBoxes;
|
||||
|
||||
std::vector<Sphere*> mSpheres;
|
||||
etk::Vector<Sphere*> mSpheres;
|
||||
|
||||
std::vector<Cone*> mCones;
|
||||
etk::Vector<Cone*> mCones;
|
||||
|
||||
std::vector<Cylinder*> mCylinders;
|
||||
etk::Vector<Cylinder*> mCylinders;
|
||||
|
||||
std::vector<Capsule*> mCapsules;
|
||||
etk::Vector<Capsule*> mCapsules;
|
||||
|
||||
/// All the convex meshes of the scene
|
||||
std::vector<ConvexMesh*> mConvexMeshes;
|
||||
etk::Vector<ConvexMesh*> mConvexMeshes;
|
||||
|
||||
/// All the dumbbell of the scene
|
||||
std::vector<Dumbbell*> mDumbbells;
|
||||
etk::Vector<Dumbbell*> mDumbbells;
|
||||
|
||||
/// Box for the floor
|
||||
Box* mFloor;
|
||||
@ -103,7 +103,7 @@ class CollisionShapesScene : public SceneDemo {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
CollisionShapesScene(const std::string& name);
|
||||
CollisionShapesScene(const etk::String& name);
|
||||
|
||||
/// Destructor
|
||||
virtual ~CollisionShapesScene();
|
||||
@ -123,11 +123,11 @@ class CollisionShapesScene : public SceneDemo {
|
||||
virtual void reset();
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
virtual std::vector<ContactPoint> getContactPoints() const;
|
||||
virtual etk::Vector<ContactPoint> getContactPoints() const;
|
||||
};
|
||||
|
||||
// Return all the contact points of the scene
|
||||
inline std::vector<ContactPoint> CollisionShapesScene::getContactPoints() const {
|
||||
inline etk::Vector<ContactPoint> CollisionShapesScene::getContactPoints() const {
|
||||
return computeContactPointsOfWorld(mDynamicsWorld);
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@ using namespace openglframework;
|
||||
using namespace trianglemeshscene;
|
||||
|
||||
// Constructor
|
||||
ConcaveMeshScene::ConcaveMeshScene(const std::string& name)
|
||||
ConcaveMeshScene::ConcaveMeshScene(const etk::String& name)
|
||||
: SceneDemo(name, SCENE_RADIUS) {
|
||||
|
||||
std::string meshFolderPath("meshes/");
|
||||
etk::String meshFolderPath("meshes/");
|
||||
|
||||
// Compute the radius and the center of the scene
|
||||
openglframework::vec3 center(0, 5, 0);
|
||||
|
@ -63,7 +63,7 @@ class ConcaveMeshScene : public SceneDemo {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
ConcaveMeshScene(const std::string& name);
|
||||
ConcaveMeshScene(const etk::String& name);
|
||||
|
||||
/// Destructor
|
||||
virtual ~ConcaveMeshScene();
|
||||
@ -83,11 +83,11 @@ class ConcaveMeshScene : public SceneDemo {
|
||||
virtual void reset();
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
virtual std::vector<ContactPoint> getContactPoints() const;
|
||||
virtual etk::Vector<ContactPoint> getContactPoints() const;
|
||||
};
|
||||
|
||||
// Return all the contact points of the scene
|
||||
inline std::vector<ContactPoint> ConcaveMeshScene::getContactPoints() const {
|
||||
inline etk::Vector<ContactPoint> ConcaveMeshScene::getContactPoints() const {
|
||||
return computeContactPointsOfWorld(mDynamicsWorld);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ using namespace openglframework;
|
||||
using namespace cubesscene;
|
||||
|
||||
// Constructor
|
||||
CubesScene::CubesScene(const std::string& name)
|
||||
CubesScene::CubesScene(const etk::String& name)
|
||||
: SceneDemo(name, SCENE_RADIUS) {
|
||||
|
||||
// Compute the radius and the center of the scene
|
||||
@ -72,7 +72,7 @@ CubesScene::CubesScene(const std::string& name)
|
||||
material.setBounciness(ephysics::float(0.4));
|
||||
|
||||
// Add the box the list of box in the scene
|
||||
mBoxes.push_back(cube);
|
||||
mBoxes.pushBack(cube);
|
||||
}
|
||||
|
||||
// Create the floor
|
||||
@ -104,7 +104,7 @@ CubesScene::CubesScene(const std::string& name)
|
||||
CubesScene::~CubesScene() {
|
||||
|
||||
// Destroy all the cubes of the scene
|
||||
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
for (etk::Vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
|
||||
// Destroy the corresponding rigid body from the dynamics world
|
||||
m_dynamicsWorld->destroyRigidBody((*it)->getRigidBody());
|
||||
@ -148,7 +148,7 @@ void CubesScene::update() {
|
||||
SceneDemo::update();
|
||||
|
||||
// Update the position and orientation of the boxes
|
||||
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
for (etk::Vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
|
||||
// Update the transform used for the rendering
|
||||
(*it)->updateetk::Transform3D(mInterpolationFactor);
|
||||
@ -164,7 +164,7 @@ void CubesScene::renderSinglePass(Shader& shader, const openglframework::Matrix4
|
||||
shader.bind();
|
||||
|
||||
// Render all the cubes of the scene
|
||||
for (std::vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
for (etk::Vector<Box*>::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ namespace cubesscene {
|
||||
class CubesScene : public SceneDemo {
|
||||
protected :
|
||||
/// All the boxes of the scene
|
||||
std::vector<Box*> mBoxes;
|
||||
etk::Vector<Box*> mBoxes;
|
||||
/// Box for the floor
|
||||
Box* mFloor;
|
||||
/// Dynamics world used for the physics simulation
|
||||
ephysics::DynamicsWorld* m_dynamicsWorld;
|
||||
public:
|
||||
/// Constructor
|
||||
CubesScene(const std::string& name);
|
||||
CubesScene(const etk::String& name);
|
||||
/// Destructor
|
||||
virtual ~CubesScene();
|
||||
/// Update the physics world (take a simulation step)
|
||||
@ -65,7 +65,7 @@ namespace cubesscene {
|
||||
/// Reset the scene
|
||||
virtual void reset();
|
||||
/// Return all the contact points of the scene
|
||||
virtual std::vector<ContactPoint> getContactPoints() const {
|
||||
virtual etk::Vector<ContactPoint> getContactPoints() const {
|
||||
return computeContactPointsOfWorld(m_dynamicsWorld);
|
||||
}
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ using namespace openglframework;
|
||||
using namespace heightfieldscene;
|
||||
|
||||
// Constructor
|
||||
HeightFieldScene::HeightFieldScene(const std::string& name) : SceneDemo(name, SCENE_RADIUS) {
|
||||
HeightFieldScene::HeightFieldScene(const etk::String& name) : SceneDemo(name, SCENE_RADIUS) {
|
||||
|
||||
// Compute the radius and the center of the scene
|
||||
openglframework::vec3 center(0, 5, 0);
|
||||
|
@ -60,7 +60,7 @@ class HeightFieldScene : public SceneDemo {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
HeightFieldScene(const std::string& name);
|
||||
HeightFieldScene(const etk::String& name);
|
||||
|
||||
/// Destructor
|
||||
virtual ~HeightFieldScene();
|
||||
@ -80,11 +80,11 @@ class HeightFieldScene : public SceneDemo {
|
||||
virtual void reset();
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
virtual std::vector<ContactPoint> getContactPoints() const;
|
||||
virtual etk::Vector<ContactPoint> getContactPoints() const;
|
||||
};
|
||||
|
||||
// Return all the contact points of the scene
|
||||
inline std::vector<ContactPoint> HeightFieldScene::getContactPoints() const {
|
||||
inline etk::Vector<ContactPoint> HeightFieldScene::getContactPoints() const {
|
||||
return computeContactPointsOfWorld(mDynamicsWorld);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ using namespace openglframework;
|
||||
using namespace jointsscene;
|
||||
|
||||
// Constructor
|
||||
JointsScene::JointsScene(const std::string& name)
|
||||
JointsScene::JointsScene(const etk::String& name)
|
||||
: SceneDemo(name, SCENE_RADIUS) {
|
||||
|
||||
// Compute the radius and the center of the scene
|
||||
|
@ -117,7 +117,7 @@ class JointsScene : public SceneDemo {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
JointsScene(const std::string& name);
|
||||
JointsScene(const etk::String& name);
|
||||
|
||||
/// Destructor
|
||||
virtual ~JointsScene();
|
||||
@ -137,11 +137,11 @@ class JointsScene : public SceneDemo {
|
||||
virtual void reset();
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
virtual std::vector<ContactPoint> getContactPoints() const;
|
||||
virtual etk::Vector<ContactPoint> getContactPoints() const;
|
||||
};
|
||||
|
||||
// Return all the contact points of the scene
|
||||
inline std::vector<ContactPoint> JointsScene::getContactPoints() const {
|
||||
inline etk::Vector<ContactPoint> JointsScene::getContactPoints() const {
|
||||
return computeContactPointsOfWorld(mDynamicsWorld);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ using namespace openglframework;
|
||||
using namespace raycastscene;
|
||||
|
||||
// Constructor
|
||||
RaycastScene::RaycastScene(const std::string& name)
|
||||
RaycastScene::RaycastScene(const etk::String& name)
|
||||
: SceneDemo(name, SCENE_RADIUS, false), mMeshFolderPath("meshes/"),
|
||||
m_raycastManager(mPhongShader, mMeshFolderPath), mCurrentBodyIndex(-1),
|
||||
mAreNormalsDisplayed(false), mVBOVertices(GL_ARRAY_BUFFER) {
|
||||
@ -172,10 +172,10 @@ void RaycastScene::createLines() {
|
||||
openglframework::vec3 point1(x, y, z);
|
||||
openglframework::vec3 point2(0.0f, 0.0f, 0.0f);
|
||||
Line* line = new Line(point1, point2);
|
||||
mLines.push_back(line);
|
||||
mLines.pushBack(line);
|
||||
|
||||
mLinePoints.push_back(point1);
|
||||
mLinePoints.push_back(point2);
|
||||
mLinePoints.pushBack(point1);
|
||||
mLinePoints.pushBack(point2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -287,7 +287,7 @@ RaycastScene::~RaycastScene() {
|
||||
delete mCollisionWorld;
|
||||
|
||||
// Destroy the lines
|
||||
for (std::vector<Line*>::iterator it = mLines.begin(); it != mLines.end();
|
||||
for (etk::Vector<Line*>::iterator it = mLines.begin(); it != mLines.end();
|
||||
++it) {
|
||||
delete (*it);
|
||||
}
|
||||
@ -309,7 +309,7 @@ void RaycastScene::update() {
|
||||
m_raycastManager.resetPoints();
|
||||
|
||||
// For each line of the scene
|
||||
for (std::vector<Line*>::iterator it = mLines.begin(); it != mLines.end();
|
||||
for (etk::Vector<Line*>::iterator it = mLines.begin(); it != mLines.end();
|
||||
++it) {
|
||||
|
||||
Line* line = *it;
|
||||
|
@ -67,18 +67,18 @@ class RaycastManager : public ephysics::RaycastCallback {
|
||||
private:
|
||||
|
||||
/// All the visual contact points
|
||||
std::vector<ContactPoint> mHitPoints;
|
||||
etk::Vector<ContactPoint> mHitPoints;
|
||||
|
||||
/// All the normals at hit points
|
||||
std::vector<Line*> mNormals;
|
||||
etk::Vector<Line*> mNormals;
|
||||
|
||||
/// Contact point mesh folder path
|
||||
std::string mMeshFolderPath;
|
||||
etk::String mMeshFolderPath;
|
||||
|
||||
public:
|
||||
|
||||
RaycastManager(openglframework::Shader& shader,
|
||||
const std::string& meshFolderPath)
|
||||
const etk::String& meshFolderPath)
|
||||
: mMeshFolderPath(meshFolderPath) {
|
||||
|
||||
}
|
||||
@ -86,13 +86,13 @@ class RaycastManager : public ephysics::RaycastCallback {
|
||||
virtual ephysics::float notifyRaycastHit(const ephysics::RaycastInfo& raycastInfo) {
|
||||
ephysics::vec3 hitPos = raycastInfo.worldPoint;
|
||||
openglframework::vec3 position(hitPos.x(), hitPos.y(), hitPos.z());
|
||||
mHitPoints.push_back(ContactPoint(position));
|
||||
mHitPoints.pushBack(ContactPoint(position));
|
||||
|
||||
// Create a line to display the normal at hit point
|
||||
ephysics::vec3 n = raycastInfo.worldNormal;
|
||||
openglframework::vec3 normal(n.x(), n.y(), n.z());
|
||||
Line* normalLine = new Line(position, position + normal);
|
||||
mNormals.push_back(normalLine);
|
||||
mNormals.pushBack(normalLine);
|
||||
|
||||
return raycastInfo.hitFraction;
|
||||
}
|
||||
@ -102,14 +102,14 @@ class RaycastManager : public ephysics::RaycastCallback {
|
||||
mHitPoints.clear();
|
||||
|
||||
// Destroy all the normals
|
||||
for (std::vector<Line*>::iterator it = mNormals.begin();
|
||||
for (etk::Vector<Line*>::iterator it = mNormals.begin();
|
||||
it != mNormals.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
mNormals.clear();
|
||||
}
|
||||
|
||||
std::vector<ContactPoint> getHitPoints() const {
|
||||
etk::Vector<ContactPoint> getHitPoints() const {
|
||||
return mHitPoints;
|
||||
}
|
||||
};
|
||||
@ -122,13 +122,13 @@ class RaycastScene : public SceneDemo {
|
||||
// -------------------- Attributes -------------------- //
|
||||
|
||||
/// Contact point mesh folder path
|
||||
std::string mMeshFolderPath;
|
||||
etk::String mMeshFolderPath;
|
||||
|
||||
/// Raycast manager
|
||||
RaycastManager m_raycastManager;
|
||||
|
||||
/// All the raycast lines
|
||||
std::vector<Line*> mLines;
|
||||
etk::Vector<Line*> mLines;
|
||||
|
||||
/// Current body index
|
||||
int32_t mCurrentBodyIndex;
|
||||
@ -153,7 +153,7 @@ class RaycastScene : public SceneDemo {
|
||||
ephysics::CollisionWorld* mCollisionWorld;
|
||||
|
||||
/// All the points to render the lines
|
||||
std::vector<openglframework::vec3> mLinePoints;
|
||||
etk::Vector<openglframework::vec3> mLinePoints;
|
||||
|
||||
/// Vertex Buffer Object for the vertices data
|
||||
openglframework::VertexBufferObject mVBOVertices;
|
||||
@ -173,7 +173,7 @@ class RaycastScene : public SceneDemo {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
RaycastScene(const std::string& name);
|
||||
RaycastScene(const etk::String& name);
|
||||
|
||||
/// Destructor
|
||||
virtual ~RaycastScene();
|
||||
@ -208,7 +208,7 @@ class RaycastScene : public SceneDemo {
|
||||
void virtual setIsContactPointsDisplayed(bool display);
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
virtual std::vector<ContactPoint> getContactPoints() const;
|
||||
virtual etk::Vector<ContactPoint> getContactPoints() const;
|
||||
};
|
||||
|
||||
// Display or not the surface normals at hit points
|
||||
@ -227,7 +227,7 @@ inline void RaycastScene::setIsContactPointsDisplayed(bool display) {
|
||||
}
|
||||
|
||||
// Return all the contact points of the scene
|
||||
inline std::vector<ContactPoint> RaycastScene::getContactPoints() const {
|
||||
inline etk::Vector<ContactPoint> RaycastScene::getContactPoints() const {
|
||||
return m_raycastManager.getHitPoints();
|
||||
}
|
||||
|
||||
|
@ -79,13 +79,13 @@ void Gui::update() {
|
||||
}
|
||||
|
||||
// Framerate (FPS)
|
||||
mFPSLabel->setCaption(std::string("FPS : ") + floatToString(mCachedFPS, 0));
|
||||
mFPSLabel->setCaption(etk::String("FPS : ") + floatToString(mCachedFPS, 0));
|
||||
|
||||
// Frame time
|
||||
mFrameTimeLabel->setCaption(std::string("Frame time : ") + floatToString(mCachedUpdateTime * 1000.0, 1) + std::string(" ms"));
|
||||
mFrameTimeLabel->setCaption(etk::String("Frame time : ") + floatToString(mCachedUpdateTime * 1000.0, 1) + etk::String(" ms"));
|
||||
|
||||
// Physics time
|
||||
mPhysicsTimeLabel->setCaption(std::string("Physics time : ") + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1) + std::string(" ms"));
|
||||
mPhysicsTimeLabel->setCaption(etk::String("Physics time : ") + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1) + etk::String(" ms"));
|
||||
}
|
||||
|
||||
void Gui::createSimulationPanel() {
|
||||
@ -122,10 +122,10 @@ void Gui::createSimulationPanel() {
|
||||
});
|
||||
|
||||
// Scenes
|
||||
std::vector<Scene*> scenes = mApp->getScenes();
|
||||
std::vector<std::string> scenesNames;
|
||||
etk::Vector<Scene*> scenes = mApp->getScenes();
|
||||
etk::Vector<etk::String> scenesNames;
|
||||
for (uint32_t i=0; i<scenes.size(); i++) {
|
||||
scenesNames.push_back(scenes[i]->getName().c_str());
|
||||
scenesNames.pushBack(scenes[i]->getName().c_str());
|
||||
}
|
||||
new Label(mSimulationPanel, "Scene","sans-bold");
|
||||
ComboBox* comboBoxScenes = new ComboBox(mSimulationPanel, scenesNames, [&, scenes](int32_t index) {
|
||||
@ -191,7 +191,7 @@ void Gui::createSettingsPanel() {
|
||||
out << std::setprecision(1) << std::fixed << (mApp->mEngineSettings.timeStep * 1000);
|
||||
textboxTimeStep->setValue(out.str());
|
||||
textboxTimeStep->setUnits("ms");
|
||||
textboxTimeStep->setCallback([&, textboxTimeStep](const std::string &str) {
|
||||
textboxTimeStep->setCallback([&, textboxTimeStep](const etk::String &str) {
|
||||
|
||||
try {
|
||||
float value = std::stof(str);
|
||||
@ -221,9 +221,9 @@ void Gui::createSettingsPanel() {
|
||||
TextBox* textboxVelocityIterations = new TextBox(panelVelocityIterations);
|
||||
textboxVelocityIterations->setFixedSize(vec2i(70, 25));
|
||||
textboxVelocityIterations->setEditable(true);
|
||||
textboxVelocityIterations->setValue(std::to_string(mApp->mEngineSettings.nbVelocitySolverIterations));
|
||||
textboxVelocityIterations->setValue(etk::toString(mApp->mEngineSettings.nbVelocitySolverIterations));
|
||||
textboxVelocityIterations->setUnits("iter");
|
||||
textboxVelocityIterations->setCallback([&, textboxVelocityIterations](const std::string &str) {
|
||||
textboxVelocityIterations->setCallback([&, textboxVelocityIterations](const etk::String &str) {
|
||||
|
||||
try {
|
||||
float value = std::stof(str);
|
||||
@ -252,9 +252,9 @@ void Gui::createSettingsPanel() {
|
||||
TextBox* textboxPositionIterations = new TextBox(panelPositionIterations);
|
||||
textboxPositionIterations->setFixedSize(vec2i(70, 25));
|
||||
textboxPositionIterations->setEditable(true);
|
||||
textboxPositionIterations->setValue(std::to_string(mApp->mEngineSettings.nbPositionSolverIterations));
|
||||
textboxPositionIterations->setValue(etk::toString(mApp->mEngineSettings.nbPositionSolverIterations));
|
||||
textboxPositionIterations->setUnits("iter");
|
||||
textboxPositionIterations->setCallback([&, textboxPositionIterations](const std::string &str) {
|
||||
textboxPositionIterations->setCallback([&, textboxPositionIterations](const etk::String &str) {
|
||||
|
||||
try {
|
||||
float value = std::stof(str);
|
||||
@ -287,7 +287,7 @@ void Gui::createSettingsPanel() {
|
||||
textboxTimeSleep->setEditable(true);
|
||||
textboxTimeSleep->setValue(out.str());
|
||||
textboxTimeSleep->setUnits("ms");
|
||||
textboxTimeSleep->setCallback([&, textboxTimeSleep](const std::string &str) {
|
||||
textboxTimeSleep->setCallback([&, textboxTimeSleep](const etk::String &str) {
|
||||
|
||||
try {
|
||||
float value = std::stof(str);
|
||||
@ -321,7 +321,7 @@ void Gui::createSettingsPanel() {
|
||||
textboxSleepLinearVel->setEditable(true);
|
||||
textboxSleepLinearVel->setValue(out.str());
|
||||
textboxSleepLinearVel->setUnits("m/s");
|
||||
textboxSleepLinearVel->setCallback([&, textboxSleepLinearVel](const std::string &str) {
|
||||
textboxSleepLinearVel->setCallback([&, textboxSleepLinearVel](const etk::String &str) {
|
||||
|
||||
try {
|
||||
float value = std::stof(str);
|
||||
@ -355,7 +355,7 @@ void Gui::createSettingsPanel() {
|
||||
textboxSleepAngularVel->setEditable(true);
|
||||
textboxSleepAngularVel->setValue(out.str());
|
||||
textboxSleepAngularVel->setUnits("rad/s");
|
||||
textboxSleepAngularVel->setCallback([&, textboxSleepAngularVel](const std::string &str) {
|
||||
textboxSleepAngularVel->setCallback([&, textboxSleepAngularVel](const etk::String &str) {
|
||||
|
||||
try {
|
||||
float value = std::stof(str);
|
||||
@ -415,13 +415,13 @@ void Gui::createProfilingPanel() {
|
||||
profilingPanel->setFixedWidth(220);
|
||||
|
||||
// Framerate (FPS)
|
||||
mFPSLabel = new Label(profilingPanel, std::string("FPS : ") + floatToString(mCachedFPS, 0),"sans-bold");
|
||||
mFPSLabel = new Label(profilingPanel, etk::String("FPS : ") + floatToString(mCachedFPS, 0),"sans-bold");
|
||||
|
||||
// Update time
|
||||
mFrameTimeLabel = new Label(profilingPanel, std::string("Frame time : ") + floatToString(mCachedUpdateTime * 1000.0, 1) + std::string(" ms"),"sans-bold");
|
||||
mFrameTimeLabel = new Label(profilingPanel, etk::String("Frame time : ") + floatToString(mCachedUpdateTime * 1000.0, 1) + etk::String(" ms"),"sans-bold");
|
||||
|
||||
// Update time
|
||||
mPhysicsTimeLabel = new Label(profilingPanel, std::string("Physics time : ") + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1) + std::string(" ms"),"sans-bold");
|
||||
mPhysicsTimeLabel = new Label(profilingPanel, etk::String("Physics time : ") + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1) + etk::String(" ms"),"sans-bold");
|
||||
|
||||
profilingPanel->setVisible(true);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class Gui {
|
||||
Label* mFrameTimeLabel;
|
||||
Label* mPhysicsTimeLabel;
|
||||
|
||||
std::vector<CheckBox*> mCheckboxesScenes;
|
||||
etk::Vector<CheckBox*> mCheckboxesScenes;
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
@ -98,7 +98,7 @@ class Gui {
|
||||
void createProfilingPanel();
|
||||
|
||||
// Convert float value to string
|
||||
std::string floatToString(float value, int32_t precision);
|
||||
etk::String floatToString(float value, int32_t precision);
|
||||
|
||||
public :
|
||||
|
||||
@ -132,8 +132,8 @@ inline void Gui::setScroll(double scrollX, double scrollY) {
|
||||
mScrollY = scrollY;
|
||||
}
|
||||
|
||||
inline std::string Gui::floatToString(float value, int32_t precision) {
|
||||
std::stringstream ss;
|
||||
inline etk::String Gui::floatToString(float value, int32_t precision) {
|
||||
etk::Stringstream ss;
|
||||
ss << std::fixed << std::setprecision(precision) << value;
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
using namespace openglframework;
|
||||
|
||||
// Constructor
|
||||
Scene::Scene(const std::string& name, bool isShadowMappingEnabled)
|
||||
Scene::Scene(const etk::String& name, bool isShadowMappingEnabled)
|
||||
: m_name(name), mInterpolationFactor(0.0f), mViewportX(0), mViewportY(0),
|
||||
mViewportWidth(0), mViewportHeight(0), mIsShadowMappingEnabled(isShadowMappingEnabled),
|
||||
mIsContactPointsDisplayed(true) {
|
||||
|
@ -73,7 +73,7 @@ class Scene {
|
||||
// -------------------- Attributes -------------------- //
|
||||
|
||||
/// Scene name
|
||||
std::string m_name;
|
||||
etk::String m_name;
|
||||
|
||||
/// Physics engine settings
|
||||
EngineSettings mEngineSettings;
|
||||
@ -134,7 +134,7 @@ class Scene {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
Scene(const std::string& name, bool isShadowMappingEnabled = false);
|
||||
Scene(const etk::String& name, bool isShadowMappingEnabled = false);
|
||||
|
||||
/// Destructor
|
||||
virtual ~Scene();
|
||||
@ -188,7 +188,7 @@ class Scene {
|
||||
void setInterpolationFactor(float int32_terpolationFactor);
|
||||
|
||||
/// Return the name of the scene
|
||||
std::string getName() const;
|
||||
etk::String getName() const;
|
||||
|
||||
/// Return true if the shadow mapping is enabled
|
||||
bool getIsShadowMappingEnabled() const;
|
||||
@ -200,7 +200,7 @@ class Scene {
|
||||
void virtual setIsContactPointsDisplayed(bool display);
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
std::vector<ContactPoint> virtual getContactPoints() const;
|
||||
etk::Vector<ContactPoint> virtual getContactPoints() const;
|
||||
};
|
||||
|
||||
// Called when a keyboard event occurs
|
||||
@ -248,7 +248,7 @@ inline void Scene::setInterpolationFactor(float int32_terpolationFactor) {
|
||||
}
|
||||
|
||||
// Return the name of the scene
|
||||
inline std::string Scene::getName() const {
|
||||
inline etk::String Scene::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
@ -268,10 +268,10 @@ inline void Scene::setIsContactPointsDisplayed(bool display) {
|
||||
}
|
||||
|
||||
// Return all the contact points of the scene
|
||||
inline std::vector<ContactPoint> Scene::getContactPoints() const {
|
||||
inline etk::Vector<ContactPoint> Scene::getContactPoints() const {
|
||||
|
||||
// Return an empty list of contact points
|
||||
return std::vector<ContactPoint>();
|
||||
return etk::Vector<ContactPoint>();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,7 +41,7 @@ openglframework::Color SceneDemo::mDemoColors[] = {SceneDemo::mYellowColorDemo,
|
||||
SceneDemo::mOrangeColorDemo, SceneDemo::mPinkColorDemo};
|
||||
|
||||
// Constructor
|
||||
SceneDemo::SceneDemo(const std::string& name, float sceneRadius, bool isShadowMappingEnabled)
|
||||
SceneDemo::SceneDemo(const etk::String& name, float sceneRadius, bool isShadowMappingEnabled)
|
||||
: Scene(name, isShadowMappingEnabled), mIsShadowMappingInitialized(false),
|
||||
mDepthShader("shaders/depth.vert", "shaders/depth.frag"),
|
||||
mPhongShader("shaders/phong.vert", "shaders/phong.frag"),
|
||||
@ -282,15 +282,15 @@ void SceneDemo::updateContactPoints() {
|
||||
if (mIsContactPointsDisplayed) {
|
||||
|
||||
// Get the current contact points of the scene
|
||||
std::vector<ContactPoint> contactPoints = getContactPoints();
|
||||
etk::Vector<ContactPoint> contactPoints = getContactPoints();
|
||||
|
||||
// For each contact point
|
||||
std::vector<ContactPoint>::const_iterator it;
|
||||
etk::Vector<ContactPoint>::const_iterator it;
|
||||
for (it = contactPoints.begin(); it != contactPoints.end(); ++it) {
|
||||
|
||||
// Create a visual contact point for rendering
|
||||
VisualContactPoint* point = new VisualContactPoint(it->point, mMeshFolderPath);
|
||||
m_contactPoints.push_back(point);
|
||||
m_contactPoints.pushBack(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,7 +300,7 @@ void SceneDemo::renderContactPoints(openglframework::Shader& shader,
|
||||
const openglframework::Matrix4& worldToCameraMatrix) {
|
||||
|
||||
// Render all the raycast hit points
|
||||
for (std::vector<VisualContactPoint*>::iterator it = m_contactPoints.begin();
|
||||
for (etk::Vector<VisualContactPoint*>::iterator it = m_contactPoints.begin();
|
||||
it != m_contactPoints.end(); ++it) {
|
||||
(*it)->render(shader, worldToCameraMatrix);
|
||||
}
|
||||
@ -309,7 +309,7 @@ void SceneDemo::renderContactPoints(openglframework::Shader& shader,
|
||||
void SceneDemo::removeAllContactPoints() {
|
||||
|
||||
// Destroy all the visual contact points
|
||||
for (std::vector<VisualContactPoint*>::iterator it = m_contactPoints.begin();
|
||||
for (etk::Vector<VisualContactPoint*>::iterator it = m_contactPoints.begin();
|
||||
it != m_contactPoints.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
@ -317,15 +317,15 @@ void SceneDemo::removeAllContactPoints() {
|
||||
}
|
||||
|
||||
// Return all the contact points of the scene
|
||||
std::vector<ContactPoint> SceneDemo::computeContactPointsOfWorld(const ephysics::DynamicsWorld* world) const {
|
||||
etk::Vector<ContactPoint> SceneDemo::computeContactPointsOfWorld(const ephysics::DynamicsWorld* world) const {
|
||||
|
||||
std::vector<ContactPoint> contactPoints;
|
||||
etk::Vector<ContactPoint> contactPoints;
|
||||
|
||||
// Get the list of contact manifolds from the world
|
||||
std::vector<const ephysics::ContactManifold*> manifolds = world->getContactsList();
|
||||
etk::Vector<const ephysics::ContactManifold*> manifolds = world->getContactsList();
|
||||
|
||||
// For each contact manifold
|
||||
std::vector<const ephysics::ContactManifold*>::const_iterator it;
|
||||
etk::Vector<const ephysics::ContactManifold*>::const_iterator it;
|
||||
for (it = manifolds.begin(); it != manifolds.end(); ++it) {
|
||||
|
||||
const ephysics::ContactManifold* manifold = *it;
|
||||
@ -336,7 +336,7 @@ std::vector<ContactPoint> SceneDemo::computeContactPointsOfWorld(const ephysics:
|
||||
ephysics::ContactPoint* contactPoint = manifold->getContactPoint(i);
|
||||
ephysics::vec3 point = contactPoint->getWorldPointOnBody1();
|
||||
ContactPoint contact(openglframework::vec3(point.x(), point.y(), point.z()));
|
||||
contactPoints.push_back(contact);
|
||||
contactPoints.pushBack(contact);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class SceneDemo : public Scene {
|
||||
static int32_t shadowMapTextureLevel;
|
||||
|
||||
/// All the visual contact points
|
||||
std::vector<VisualContactPoint*> m_contactPoints;
|
||||
etk::Vector<VisualContactPoint*> m_contactPoints;
|
||||
|
||||
/// Shadow map bias matrix
|
||||
openglframework::Matrix4 mShadowMapBiasMatrix;
|
||||
@ -90,7 +90,7 @@ class SceneDemo : public Scene {
|
||||
static openglframework::Color mDemoColors[];
|
||||
static int32_t mNbDemoColors;
|
||||
|
||||
std::string mMeshFolderPath;
|
||||
etk::String mMeshFolderPath;
|
||||
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
@ -117,7 +117,7 @@ class SceneDemo : public Scene {
|
||||
// -------------------- Methods -------------------- //
|
||||
|
||||
/// Constructor
|
||||
SceneDemo(const std::string& name, float sceneRadius, bool isShadowMappingEnabled = true);
|
||||
SceneDemo(const etk::String& name, float sceneRadius, bool isShadowMappingEnabled = true);
|
||||
|
||||
/// Destructor
|
||||
virtual ~SceneDemo();
|
||||
@ -136,7 +136,7 @@ class SceneDemo : public Scene {
|
||||
void virtual setIsShadowMappingEnabled(bool isShadowMappingEnabled);
|
||||
|
||||
/// Return all the contact points of the scene
|
||||
std::vector<ContactPoint> computeContactPointsOfWorld(const ephysics::DynamicsWorld* world) const;
|
||||
etk::Vector<ContactPoint> computeContactPointsOfWorld(const ephysics::DynamicsWorld* world) const;
|
||||
};
|
||||
|
||||
// Enabled/Disable the shadow mapping
|
||||
|
@ -95,27 +95,27 @@ void TestbedApplication::createScenes() {
|
||||
|
||||
// Cubes scene
|
||||
CubesScene* cubeScene = new CubesScene("Cubes");
|
||||
mScenes.push_back(cubeScene);
|
||||
mScenes.pushBack(cubeScene);
|
||||
|
||||
// Joints scene
|
||||
JointsScene* jointsScene = new JointsScene("Joints");
|
||||
mScenes.push_back(jointsScene);
|
||||
mScenes.pushBack(jointsScene);
|
||||
|
||||
// Collision shapes scene
|
||||
CollisionShapesScene* collisionShapesScene = new CollisionShapesScene("Collision Shapes");
|
||||
mScenes.push_back(collisionShapesScene);
|
||||
mScenes.pushBack(collisionShapesScene);
|
||||
|
||||
// Heightfield shape scene
|
||||
HeightFieldScene* heightFieldScene = new HeightFieldScene("Heightfield");
|
||||
mScenes.push_back(heightFieldScene);
|
||||
mScenes.pushBack(heightFieldScene);
|
||||
|
||||
// Raycast scene
|
||||
RaycastScene* raycastScene = new RaycastScene("Raycast");
|
||||
mScenes.push_back(raycastScene);
|
||||
mScenes.pushBack(raycastScene);
|
||||
|
||||
// Raycast scene
|
||||
ConcaveMeshScene* concaveMeshScene = new ConcaveMeshScene("Concave Mesh");
|
||||
mScenes.push_back(concaveMeshScene);
|
||||
mScenes.pushBack(concaveMeshScene);
|
||||
|
||||
assert(mScenes.size() > 0);
|
||||
mCurrentScene = mScenes[0];
|
||||
@ -270,7 +270,7 @@ void TestbedApplication::checkOpenGLErrorsInternal(const char* file, int32_t lin
|
||||
// While there are errors
|
||||
while (glError != GL_NO_ERROR) {
|
||||
|
||||
std::string error;
|
||||
etk::String error;
|
||||
|
||||
switch(glError) {
|
||||
case GL_INVALID_OPERATION: error="INVALID_OPERATION"; break;
|
||||
|
@ -60,7 +60,7 @@ class TestbedApplication : public Screen {
|
||||
Timer mTimer;
|
||||
|
||||
/// List of 3D scenes
|
||||
std::vector<Scene*> mScenes;
|
||||
etk::Vector<Scene*> mScenes;
|
||||
|
||||
/// Current 3D scene
|
||||
Scene* mCurrentScene;
|
||||
@ -142,7 +142,7 @@ class TestbedApplication : public Screen {
|
||||
void destroyScenes();
|
||||
|
||||
/// Return the list of the scenes
|
||||
std::vector<Scene*> getScenes();
|
||||
etk::Vector<Scene*> getScenes();
|
||||
|
||||
/// Start/stop the simulation
|
||||
void togglePlayPauseSimulation();
|
||||
@ -208,7 +208,7 @@ class TestbedApplication : public Screen {
|
||||
};
|
||||
|
||||
// Return the list of the scenes
|
||||
inline std::vector<Scene*> TestbedApplication::getScenes() {
|
||||
inline etk::Vector<Scene*> TestbedApplication::getScenes() {
|
||||
return mScenes;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user