2017-01-03 15:18:06 +01:00
|
|
|
#include "data/Clump.hpp"
|
2014-02-09 04:14:43 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
|
2017-01-03 17:21:21 +01:00
|
|
|
Geometry::Geometry() : flags(0) {
|
2013-09-25 10:05:18 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 17:21:21 +01:00
|
|
|
Geometry::~Geometry() {
|
2013-09-25 10:05:18 +02:00
|
|
|
}
|
2014-02-09 04:14:43 +01:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
ModelFrame::ModelFrame(unsigned int index, ModelFrame* parent, glm::mat3 dR,
|
|
|
|
glm::vec3 dT)
|
|
|
|
: index(index)
|
|
|
|
, defaultRotation(dR)
|
|
|
|
, defaultTranslation(dT)
|
|
|
|
, parentFrame(parent) {
|
|
|
|
if (parent != nullptr) {
|
|
|
|
parent->childs.push_back(this);
|
|
|
|
}
|
|
|
|
reset();
|
2014-02-09 04:14:43 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void ModelFrame::reset() {
|
|
|
|
matrix = glm::translate(glm::mat4(), defaultTranslation) *
|
|
|
|
glm::mat4(defaultRotation);
|
2014-02-09 04:14:43 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void ModelFrame::addGeometry(size_t idx) {
|
|
|
|
geometries.push_back(idx);
|
2014-06-08 23:40:46 +02:00
|
|
|
}
|
2014-08-04 23:21:01 +02:00
|
|
|
|
2017-01-03 15:18:06 +01:00
|
|
|
Clump::~Clump() {
|
2016-09-09 22:13:21 +02:00
|
|
|
for (auto mf : frames) {
|
|
|
|
delete mf;
|
|
|
|
}
|
2014-08-04 23:21:01 +02:00
|
|
|
}
|
2015-04-06 05:06:35 +02:00
|
|
|
|
2017-01-03 15:18:06 +01:00
|
|
|
void Clump::recalculateMetrics() {
|
2016-09-09 22:13:21 +02:00
|
|
|
boundingRadius = std::numeric_limits<float>::min();
|
|
|
|
for (size_t g = 0; g < geometries.size(); g++) {
|
|
|
|
RW::BSGeometryBounds& bounds = geometries[g]->geometryBounds;
|
|
|
|
boundingRadius = std::max(boundingRadius,
|
|
|
|
glm::length(bounds.center) + bounds.radius);
|
|
|
|
}
|
2015-04-06 05:06:35 +02:00
|
|
|
}
|