mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-24 22:09:10 -06:00
Merge branch 'feature/globebrowsing' of github.com:OpenSpace/OpenSpace-Development into feature/globebrowsing
This commit is contained in:
@@ -52,16 +52,29 @@ namespace openspace {
|
||||
return max - min;
|
||||
}
|
||||
|
||||
bool AABB2::intersects(const vec2& p) const {
|
||||
return (min.x < p.x) && (p.x < max.x)
|
||||
&& (min.y < p.y) && (p.y < max.y);
|
||||
bool AABB2::contains(const vec2& p) const {
|
||||
return (min.x <= p.x) && (p.x <= max.x)
|
||||
&& (min.y <= p.y) && (p.y <= max.y);
|
||||
}
|
||||
|
||||
bool AABB2::contains(const AABB2& o) const {
|
||||
return (min.x <= o.min.x) && (o.max.x <= max.x)
|
||||
&& (min.y <= o.min.y) && (o.max.y <= max.y);
|
||||
}
|
||||
|
||||
bool AABB2::intersects(const AABB2& o) const {
|
||||
return (min.x < o.max.x) && (o.min.x < max.x)
|
||||
&& (min.y < o.max.y) && (o.min.y < max.y);
|
||||
return (min.x <= o.max.x) && (o.min.x <= max.x)
|
||||
&& (min.y <= o.max.y) && (o.min.y <= max.y);
|
||||
}
|
||||
|
||||
AABBSpatialRelation AABB2::relationTo(const AABB2& o) const {
|
||||
if (intersects(o)) {
|
||||
if (contains(o)) return AABBSpatialRelation::Containing;
|
||||
if (o.contains(*this)) return AABBSpatialRelation::Contained;
|
||||
return AABBSpatialRelation::Intersecting;
|
||||
}
|
||||
return AABBSpatialRelation::None;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -86,17 +99,33 @@ namespace openspace {
|
||||
return max - min;
|
||||
}
|
||||
|
||||
bool AABB3::intersects(const vec3& p) const {
|
||||
return (min.x < p.x) && (p.x < max.x)
|
||||
&& (min.y < p.y) && (p.y < max.y)
|
||||
&& (min.z < p.z) && (p.z < max.z);
|
||||
bool AABB3::contains(const vec3& p) const {
|
||||
return (min.x <= p.x) && (p.x <= max.x)
|
||||
&& (min.y <= p.y) && (p.y <= max.y)
|
||||
&& (min.z <= p.z) && (p.z <= max.z);
|
||||
}
|
||||
|
||||
bool AABB3::contains(const AABB3& o) const {
|
||||
return (min.x <= o.min.x) && (o.max.x <= max.x)
|
||||
&& (min.y <= o.min.y) && (o.max.y <= max.y)
|
||||
&& (min.z <= o.min.z) && (o.max.z <= max.z);
|
||||
}
|
||||
|
||||
bool AABB3::intersects(const AABB3& o) const {
|
||||
return (min.x < o.max.x) && (o.min.x < max.x)
|
||||
&& (min.y < o.max.y) && (o.min.y < max.y)
|
||||
&& (min.z < o.max.z) && (o.min.z < max.z);
|
||||
return (min.x <= o.max.x) && (o.min.x <= max.x)
|
||||
&& (min.y <= o.max.y) && (o.min.y <= max.y)
|
||||
&& (min.z <= o.max.z) && (o.min.z <= max.z);
|
||||
}
|
||||
|
||||
AABBSpatialRelation AABB3::relationTo(const AABB3& o) const {
|
||||
if (intersects(o)) {
|
||||
if (contains(o)) return AABBSpatialRelation::Containing;
|
||||
if (o.contains(*this)) return AABBSpatialRelation::Contained;
|
||||
return AABBSpatialRelation::Intersecting;
|
||||
}
|
||||
return AABBSpatialRelation::None;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -36,6 +36,13 @@ namespace openspace {
|
||||
|
||||
using namespace glm;
|
||||
|
||||
enum class AABBSpatialRelation {
|
||||
None,
|
||||
Intersecting,
|
||||
Contained,
|
||||
Containing
|
||||
};
|
||||
|
||||
|
||||
struct AABB2 {
|
||||
AABB2();
|
||||
@@ -44,8 +51,10 @@ namespace openspace {
|
||||
void expand(const vec2& p);
|
||||
vec2 center() const;
|
||||
vec2 size() const;
|
||||
bool intersects(const vec2& p) const;
|
||||
bool contains(const vec2& p) const;
|
||||
bool contains(const AABB2& o) const;
|
||||
bool intersects(const AABB2& o) const;
|
||||
AABBSpatialRelation relationTo(const AABB2& o) const;
|
||||
|
||||
vec2 min;
|
||||
vec2 max;
|
||||
@@ -59,8 +68,11 @@ namespace openspace {
|
||||
void expand(const vec3 p);
|
||||
vec3 center() const;
|
||||
vec3 size() const;
|
||||
bool intersects(const vec3& p) const;
|
||||
bool contains(const vec3& p) const;
|
||||
bool contains(const AABB3& o) const;
|
||||
bool intersects(const AABB3& o) const;
|
||||
AABBSpatialRelation relationTo(const AABB3& o) const;
|
||||
|
||||
|
||||
vec3 min;
|
||||
vec3 max;
|
||||
|
||||
@@ -111,8 +111,6 @@ namespace openspace {
|
||||
mat4 modelViewProjectionTransform = dmat4(data.camera.projectionMatrix())
|
||||
* viewTransform * modelTransform;
|
||||
|
||||
|
||||
|
||||
double centerRadius = ellipsoid.maximumRadius();
|
||||
//double centerRadius = glm::length(ellipsoid.cartesianSurfacePosition(patch.center()));
|
||||
double maxCenterRadius = centerRadius + maxHeight;
|
||||
@@ -121,18 +119,7 @@ namespace openspace {
|
||||
double maxHeightOffset = maxCenterRadius / cos(maximumPatchSide) - centerRadius;
|
||||
double minHeightOffset = 0; // for now
|
||||
|
||||
|
||||
/*
|
||||
Geodetic3 centerGeodetic = { patch.center(), 0};
|
||||
vec4 centerModelSpace = vec4(ellipsoid.cartesianPosition(centerGeodetic), 1);
|
||||
vec4 centerClippingSpace = modelViewProjectionTransform * centerModelSpace;
|
||||
vec3 centerScreenSpace = (1.0f / glm::abs(centerClippingSpace.w)) * centerClippingSpace.xyz();
|
||||
AABB3 viewFrustum(vec3(-1, -1, 0), vec3(1, 1, 1e35));
|
||||
return viewFrustum.intersects(centerScreenSpace);
|
||||
*/
|
||||
|
||||
// Create a bounding box that fits the patch corners
|
||||
|
||||
AABB3 bounds; // in screen space
|
||||
int numPositiveZ = 0;
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
@@ -147,12 +134,7 @@ namespace openspace {
|
||||
|
||||
|
||||
return bounds.intersects(FrustumCuller::viewFrustum);
|
||||
|
||||
/*
|
||||
vec2 center = bounds.center();
|
||||
vec2 margin = 0.5f * bounds.size();
|
||||
return testPoint(center, margin) == PointLocation::Inside;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ namespace openspace {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class FrustumCuller {
|
||||
public:
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
//#include <test_scenegraphloader.inl>
|
||||
//#include <test_chunknode.inl>
|
||||
//#include <test_lrucache.inl>
|
||||
#include <test_threadpool.inl>
|
||||
//#include <test_threadpool.inl>
|
||||
#include <test_aabb.inl>
|
||||
|
||||
//#include <test_luaconversions.inl>
|
||||
//#include <test_powerscalecoordinates.inl>
|
||||
|
||||
142
tests/test_aabb.inl
Normal file
142
tests/test_aabb.inl
Normal file
@@ -0,0 +1,142 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/../modules/globebrowsing/rendering/aabb.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
class AABBTest : public testing::Test {};
|
||||
|
||||
|
||||
|
||||
TEST_F(AABBTest, Contains2) {
|
||||
|
||||
AABB2 a1;
|
||||
AABB2 a2;
|
||||
/*
|
||||
a1
|
||||
+-----+
|
||||
|+---+|
|
||||
||a2 ||
|
||||
|+---+|
|
||||
+-----+
|
||||
*/
|
||||
|
||||
a1.expand(glm::vec2(0, 0));
|
||||
a1.expand(glm::vec2(1, 1));
|
||||
|
||||
a2.expand(glm::vec2(0.1, 0.1));
|
||||
a2.expand(glm::vec2(0.9, 0.9));
|
||||
|
||||
EXPECT_TRUE(a1.contains(a2)) << "a1 should contain a2";
|
||||
EXPECT_FALSE(a2.contains(a1)) << "a2 should not contain a1";
|
||||
EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2";
|
||||
EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1";
|
||||
|
||||
EXPECT_EQ(AABBSpatialRelation::Containing, a1.relationTo(a2)) << "a1 contains a2";
|
||||
EXPECT_EQ(AABBSpatialRelation::Contained, a2.relationTo(a1)) << "a2 contained by a1";
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_F(AABBTest, Intersects2) {
|
||||
AABB2 a1;
|
||||
AABB2 a2;
|
||||
|
||||
/*
|
||||
a1
|
||||
+-----+
|
||||
| |
|
||||
| | a2
|
||||
| ++----+
|
||||
+----++ |
|
||||
| |
|
||||
| |
|
||||
+-----+
|
||||
*/
|
||||
|
||||
a1.expand(glm::vec2(0, 0));
|
||||
a1.expand(glm::vec2(1, 1));
|
||||
|
||||
a2.expand(glm::vec2(0.9, 0.9));
|
||||
a2.expand(glm::vec2(1.9, 1.9));
|
||||
|
||||
EXPECT_FALSE(a1.contains(a2)) << "a1 should not contain a2";
|
||||
EXPECT_FALSE(a2.contains(a1)) << "a2 should not contain a1";
|
||||
EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2";
|
||||
EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1";
|
||||
|
||||
EXPECT_EQ(AABBSpatialRelation::Intersecting, a1.relationTo(a2)) << "They should intersect";
|
||||
EXPECT_EQ(AABBSpatialRelation::Intersecting, a2.relationTo(a1)) << "They should intersect";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_F(AABBTest, Contains3) {
|
||||
AABB3 a1;
|
||||
AABB3 a2;
|
||||
|
||||
a1.expand(glm::vec3(0, 0, 0));
|
||||
a1.expand(glm::vec3(1, 1, 1));
|
||||
|
||||
a2.expand(glm::vec3(0.1, 0.1, 0.1));
|
||||
a2.expand(glm::vec3(0.9, 0.9, 0.9));
|
||||
|
||||
EXPECT_TRUE(a1.contains(a2)) << "a1 should contain a2";
|
||||
EXPECT_FALSE(a2.contains(a1)) << "a2 should not contain a1";
|
||||
EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2";
|
||||
EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1";
|
||||
|
||||
EXPECT_EQ(AABBSpatialRelation::Containing, a1.relationTo(a2)) << "a1 contains a2";
|
||||
EXPECT_EQ(AABBSpatialRelation::Contained, a2.relationTo(a1)) << "a2 contained by a1";
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_F(AABBTest, Intersects3) {
|
||||
AABB3 a1;
|
||||
AABB3 a2;
|
||||
|
||||
a1.expand(glm::vec3(0, 0, 0));
|
||||
a1.expand(glm::vec3(1, 1, 1));
|
||||
|
||||
a2.expand(glm::vec3(0.9, 0.9, 0.9));
|
||||
a2.expand(glm::vec3(1.9, 1.9, 1.9));
|
||||
|
||||
EXPECT_TRUE(a1.intersects(a2)) << "a1 should intersect a2";
|
||||
EXPECT_TRUE(a2.intersects(a1)) << "a2 should intersect a1";
|
||||
EXPECT_FALSE(a1.contains(a2)) << "a1 should not contain a2";
|
||||
EXPECT_FALSE(a2.contains(a1)) << "a2 should not contain a1";
|
||||
|
||||
EXPECT_EQ(AABBSpatialRelation::Intersecting, a1.relationTo(a2)) << "They should intersect";
|
||||
EXPECT_EQ(AABBSpatialRelation::Intersecting, a2.relationTo(a1)) << "They should intersect";
|
||||
}
|
||||
|
||||
48
tests/test_temporaltileprovider.inl
Normal file
48
tests/test_temporaltileprovider.inl
Normal file
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <modules/globebrowsing/other/temporaltileprovider.h>
|
||||
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
class TemporalTileProviderTest : public testing::Test {};
|
||||
|
||||
std::string fileName = "data/scene/debugglobe/map_service_configs/VIIRS_SNPP_CorrectedReflectance_TrueColor_temporal.xml";
|
||||
|
||||
TEST_F(TemporalTileProviderTest, Basic) {
|
||||
double t = 2016.01;
|
||||
openspace::Time::ref().setTime(t);
|
||||
openspace::Time::ref().preSynchronization();
|
||||
openspace::Time::ref().postSynchronizationPreDraw();
|
||||
openspace::TemporalTileProvider provider(absPath(fileName));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user