Skip to content

Instantly share code, notes, and snippets.

pushedT = (aTimeLft < aTimeRgh) ? aTimeRgh : aTimeLft;
...
int aStackOffset = theHit.Time < pushedT ? 2 : 1;
if (aHead - aStackOffset + 1 <= theSentinel)
return aTriIndex;
aNode = Stack[aHead - aStackOffset + 1];
ivec4 ObjectNearestHit (in int theBVHOffset, in int theVrtOffset, in int theTrgOffset,
in SRay theRay, in vec3 theInverse, inout SIntersect theHit, in int theSentinel)
{
int aHead = theSentinel; // stack pointer
int aNode = 0; // node to visit
ivec4 aTriIndex = INALID_HIT;
float aTimeOut;
float aTimeLft;
// =======================================================================
// function : PrintPretty
// purpose :
// =======================================================================
void RayTraceGPU_Node::PrintPretty (std::string thePrefix, bool isLeft, int theLevel) const
{
if (IsLeaf())
{
thePrefix.erase(thePrefix.size() - 2, 2);
thePrefix += isLeft ? "|-" : "\xC0-";
{
// NOTE: You should always edit options in user file, not this file.
// Print debug message
"debug": false,
// Auto format on file save
"autoformat_on_save": false,
// The mapping key is `syntax name`, and the value is `formatting mode`.
@hb3p8
hb3p8 / Slerp
Created March 11, 2015 12:33
Spherical linear interpolation between unit quaternions q1 and q2 with interpolation parameter t.
// Spherical linear interpolation between unit quaternions q1 and q2 with interpolation parameter t.
Quaternion slerp(Quaternion q1, Quaternion q2, float t)
{
float w1, x1, y1, z1, w2, x2, y2, z2, w3, x3, y3, z3;
Quaternion q2New;
float theta, mult1, mult2;
w1 = q1.getW(); x1 = q1.getX(); y1 = q1.getY(); z1 = q1.getZ();
w2 = q2.getW(); x2 = q2.getX(); y2 = q2.getY(); z2 = q2.getZ();
@hb3p8
hb3p8 / ocl_framework.cpp
Created September 25, 2015 13:10
ocl framework
typedef double real;
typedef Eigen::Vector2d vec2;
typedef Eigen::Vector2i int2;
typedef Eigen::Vector4i int4;
vec2 mix (vec2 a, vec2 b, real c) {
return (a + b) * c;
}
@hb3p8
hb3p8 / ColoredTable.cpp
Created December 14, 2015 08:29
Colored table output win
HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
const int aDefaultColor = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
auto printTable = [&](const std::set<Standard_Integer>& theRemSet) {
return; // disabled
std::cout << setw (3) << " ";
for (int j = 0; j < aTableSize; ++j) {
std::cout << setw (6) << j;
}
@hb3p8
hb3p8 / WriteMesh.cpp
Created December 14, 2015 09:32
WriteMesh
void BRepMesh_RestoreOrientationTool::WriteMesh (const std::string& theFileName)
{
// write obj file
std::ofstream myfile;
myfile.open (theFileName);
const Handle(BRepMesh_TriangulatedPatch)& aPatch = myPatches.back();
for (int i = 0; i < aPatch->Vertices.size(); ++i) {
BVH_Vec3d aVert = aPatch->Vertices[i];