This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
// 128 by 64 bit integer division for gcc and clang | |
inline uint64_t udiv128_64(unsigned __int128 a, uint64_t b) | |
{ | |
// We don't want 128 bit software division | |
uint64_t alo = (uint64_t)a; | |
uint64_t ahi = (a >> 64); | |
uint64_t d, e; | |
__asm__("divq %[b]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Build orthonormal frame from normalized dir | |
/// Hughes and Moeller http://cs.brown.edu/~jfh/papers/Moller-BAO-1999/main.htm | |
inline float3x3 FrameFromDirHughes(float3 dir) | |
{ | |
float3 dx0 = float3(0, dir.z, -dir.y); | |
float3 dx1 = float3(-dir.z, 0, dir.x); | |
float3 dx = normalize(dot(dx0, dx0) > dot(dx1, dx1) ? dx0 : dx1); | |
float3 dy = cross(dir, dx); | |
return float3x3(dx, dy, dir); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HRESULT hot_init(hot_ctx **out) | |
{ | |
*out = nullptr; | |
std::unique_ptr<hot_ctx> ctx(new hot_ctx); | |
// Obtain base address of main executable | |
// 1. Module info | |
//MODULEINFO mod_info; | |
//GetModuleInformation(GetCurrentProcess(), hmod, &mod_info, sizeof(mod_info)); | |
//void *baseaddr = mod_info.lpBaseOfDll; |