add print to ray
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "math/vec4.hpp"
|
#include "math/vec4.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -52,6 +53,11 @@ class Ray {
|
|||||||
|
|
||||||
/** Returns inverse direction */
|
/** Returns inverse direction */
|
||||||
Vec4 invDir() const;
|
Vec4 invDir() const;
|
||||||
|
|
||||||
|
void print() const;
|
||||||
|
void print(const char* name) const;
|
||||||
|
void print(const std::string& name) const { print(name.c_str()); }
|
||||||
|
std::string getPrint(const char* name = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -74,4 +76,27 @@ Vec4 Ray::invDir() const {
|
|||||||
1 / this->direction.z, 1);
|
1 / this->direction.z, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ray::print() const {
|
||||||
|
auto text = getPrint(nullptr);
|
||||||
|
printf("%s\n", text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ray::print(const char* name) const {
|
||||||
|
auto text = getPrint(name);
|
||||||
|
printf("%s\n", text.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Ray::getPrint(const char* name) const {
|
||||||
|
std::stringstream res;
|
||||||
|
if (name) {
|
||||||
|
res << name << "(";
|
||||||
|
} else {
|
||||||
|
res << "Ray(";
|
||||||
|
}
|
||||||
|
res << std::fixed << std::setprecision(4);
|
||||||
|
res << origin.getPrint("origin") << ", " << direction.getPrint("direction")
|
||||||
|
<< ")";
|
||||||
|
return res.str();
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace Tyra
|
} // Namespace Tyra
|
||||||
Reference in New Issue
Block a user