Merge pull request #13488 from hrydgard/delete-old-unused-stuff

Delete old unused stuff
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2020-09-29 11:40:17 +02:00
commit b87826698d
34 files changed
+21 -874

No files matched your search

-7
View File
@@ -939,8 +939,6 @@ endif()
add_library(native STATIC
${nativeExtra}
ext/native/base/backtrace.cpp
ext/native/base/backtrace.h
ext/native/base/basictypes.h
ext/native/base/buffer.cpp
ext/native/base/buffer.h
@@ -1024,11 +1022,6 @@ add_library(native STATIC
ext/native/math/expression_parser.h
ext/native/math/lin/matrix4x4.cpp
ext/native/math/lin/matrix4x4.h
ext/native/math/lin/plane.cpp
ext/native/math/lin/plane.h
ext/native/math/lin/quat.cpp
ext/native/math/lin/quat.h
ext/native/math/lin/ray.h
ext/native/math/lin/vec3.cpp
ext/native/math/lin/vec3.h
ext/native/math/math_util.cpp
+5 -28
View File
@@ -20,9 +20,9 @@ static double curtime = 0;
#ifdef _WIN32
LARGE_INTEGER frequency;
double frequencyMult;
LARGE_INTEGER startTime;
static LARGE_INTEGER frequency;
static double frequencyMult;
static LARGE_INTEGER startTime;
double time_now_d() {
if (frequency.QuadPart == 0) {
@@ -39,8 +39,8 @@ double time_now_d() {
#else
uint64_t _frequency = 0;
uint64_t _starttime = 0;
static uint64_t _frequency = 0;
static uint64_t _starttime = 0;
double time_now_d() {
static time_t start;
@@ -64,26 +64,3 @@ void sleep_ms(int ms) {
usleep(ms * 1000);
#endif
}
LoggingDeadline::LoggingDeadline(const char *name, int ms) : name_(name), endCalled_(false) {
totalTime_ = (double)ms * 0.001;
endTime_ = time_now_d() + totalTime_;
}
LoggingDeadline::~LoggingDeadline() {
if (!endCalled_)
End();
}
bool LoggingDeadline::End() {
endCalled_ = true;
double now = time_now_d();
if (now > endTime_) {
double late = (now - endTime_);
double totalTime = late + totalTime_;
ERROR_LOG(SYSTEM, "===== %0.2fms DEADLINE PASSED FOR %s at %0.2fms - %0.2fms late =====", totalTime_ * 1000.0, name_, 1000.0 * totalTime, 1000.0 * late);
return false;
}
return true;
}
-17
View File
@@ -1,24 +1,7 @@
#pragma once
// http://linux.die.net/man/3/clock_gettime
// Seconds.
double time_now_d();
// Sleep. Does not necessarily have millisecond granularity, especially on Windows.
void sleep_ms(int ms);
// Can be sprinkled around the code to make sure that thing don't take
// unexpectedly long. What that means is up to you.
class LoggingDeadline {
public:
LoggingDeadline(const char *name, int deadline_in_ms);
~LoggingDeadline();
bool End();
private:
const char *name_;
bool endCalled_;
double totalTime_;
double endTime_;
};
+1 -1
View File
@@ -6415,7 +6415,7 @@ void actOnBirthPacket(SceNetAdhocMatchingContext * context, SceNetEtherAddr * se
SceNetEtherAddr mac;
memcpy(&mac, context->rxbuf + 1, sizeof(SceNetEtherAddr));
// Allocate Memory (If this fails... we are fucked.)
// Allocate Memory
SceNetAdhocMatchingMemberInternal * sibling = (SceNetAdhocMatchingMemberInternal *)malloc(sizeof(SceNetAdhocMatchingMemberInternal));
// Allocated Memory
+3 -3
View File
@@ -2337,9 +2337,9 @@ void GPUCommon::Execute_Unknown(u32 op, u32 diff) {
}
void GPUCommon::FastLoadBoneMatrix(u32 target) {
const int num = gstate.boneMatrixNumber & 0x7F;
const int mtxNum = num / 12;
uint32_t uniformsToDirty = DIRTY_BONEMATRIX0 << mtxNum;
const u32 num = gstate.boneMatrixNumber & 0x7F;
const u32 mtxNum = num / 12;
u32 uniformsToDirty = DIRTY_BONEMATRIX0 << mtxNum;
if (num != 12 * mtxNum) {
uniformsToDirty |= DIRTY_BONEMATRIX0 << ((mtxNum + 1) & 7);
}
-7
View File
@@ -379,7 +379,6 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\ext\native\base\backtrace.h" />
<ClInclude Include="..\..\ext\native\base\basictypes.h" />
<ClInclude Include="..\..\ext\native\base\buffer.h" />
<ClInclude Include="..\..\ext\native\base\colorutil.h" />
@@ -391,7 +390,6 @@
<ClInclude Include="..\..\ext\native\base\stringutil.h" />
<ClInclude Include="..\..\ext\native\data\base64.h" />
<ClInclude Include="..\..\ext\native\data\compression.h" />
<ClInclude Include="..\..\ext\native\data\listable.h" />
<ClInclude Include="..\..\ext\native\ext\cityhash\city.h" />
<ClInclude Include="..\..\ext\native\ext\cityhash\citycrc.h" />
<ClInclude Include="..\..\ext\native\ext\gason\gason.h" />
@@ -436,8 +434,6 @@
<ClInclude Include="..\..\ext\native\math\fast\fast_matrix.h" />
<ClInclude Include="..\..\ext\native\math\geom2d.h" />
<ClInclude Include="..\..\ext\native\math\lin\matrix4x4.h" />
<ClInclude Include="..\..\ext\native\math\lin\plane.h" />
<ClInclude Include="..\..\ext\native\math\lin\quat.h" />
<ClInclude Include="..\..\ext\native\math\lin\ray.h" />
<ClInclude Include="..\..\ext\native\math\lin\vec3.h" />
<ClInclude Include="..\..\ext\native\math\math_util.h" />
@@ -473,7 +469,6 @@
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\ext\native\base\backtrace.cpp" />
<ClCompile Include="..\..\ext\native\base\buffer.cpp" />
<ClCompile Include="..\..\ext\native\base\colorutil.cpp" />
<ClCompile Include="..\..\ext\native\base\display.cpp" />
@@ -1588,8 +1583,6 @@
</ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="..\..\ext\native\math\lin\matrix4x4.cpp" />
<ClCompile Include="..\..\ext\native\math\lin\plane.cpp" />
<ClCompile Include="..\..\ext\native\math\lin\quat.cpp" />
<ClCompile Include="..\..\ext\native\math\lin\vec3.cpp" />
<ClCompile Include="..\..\ext\native\math\math_util.cpp" />
<ClCompile Include="..\..\ext\native\net\http_client.cpp" />
-21
View File
@@ -64,9 +64,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="..\..\ext\native\base\backtrace.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\base\buffer.cpp">
<Filter>base</Filter>
</ClCompile>
@@ -169,12 +166,6 @@
<ClCompile Include="..\..\ext\native\math\lin\matrix4x4.cpp">
<Filter>math</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\math\lin\plane.cpp">
<Filter>math</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\math\lin\quat.cpp">
<Filter>math</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\native\math\lin\vec3.cpp">
<Filter>math</Filter>
</ClCompile>
@@ -475,9 +466,6 @@
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="..\..\ext\native\base\backtrace.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\base\basictypes.h">
<Filter>base</Filter>
</ClInclude>
@@ -607,12 +595,6 @@
<ClInclude Include="..\..\ext\native\math\lin\matrix4x4.h">
<Filter>math</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\math\lin\plane.h">
<Filter>math</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\math\lin\quat.h">
<Filter>math</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\math\lin\ray.h">
<Filter>math</Filter>
</ClInclude>
@@ -718,9 +700,6 @@
<ClInclude Include="..\..\ext\native\data\compression.h">
<Filter>data</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\data\listable.h">
<Filter>data</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\native\json\json_reader.h" />
<ClInclude Include="..\..\ext\native\json\json_writer.h" />
<ClInclude Include="..\..\ext\native\ext\gason\gason.h">
-3
View File
@@ -7,7 +7,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libnative
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES :=\
base/backtrace.cpp \
base/buffer.cpp \
base/display.cpp \
base/colorutil.cpp \
@@ -53,8 +52,6 @@ LOCAL_SRC_FILES :=\
math/math_util.cpp \
math/curves.cpp \
math/expression_parser.cpp \
math/lin/plane.cpp.arm \
math/lin/quat.cpp.arm \
math/lin/vec3.cpp.arm \
math/lin/matrix4x4.cpp.arm \
net/http_client.cpp \
+1 -1
View File
@@ -3,7 +3,7 @@ set(SRCS
../thread/threadutil.cpp
display.cpp
buffer.cpp
backtrace.cpp)
)
add_library(base STATIC ${SRCS})
-22
View File
@@ -1,22 +0,0 @@
#include "base/backtrace.h"
#if (defined(__GLIBC__) && !defined(__UCLIBC__)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include <execinfo.h>
#include <unistd.h>
static void *backtrace_buffer[128];
void PrintBacktraceToStderr() {
int num_addrs = backtrace(backtrace_buffer, 128);
backtrace_symbols_fd(backtrace_buffer, num_addrs, STDERR_FILENO);
}
#else
#include <stdio.h>
void PrintBacktraceToStderr() {
fprintf(stderr, "No backtrace available to print on this platform\n");
}
#endif
-3
View File
@@ -1,3 +0,0 @@
#pragma once
void PrintBacktraceToStderr();
-53
View File
@@ -34,33 +34,12 @@ std::string LineNumberString(const std::string &str) {
return output.str();
}
void StringTrimEndNonAlphaNum(char *str) {
ssize_t n = strlen(str);
while (!isalnum(str[n]) && n >= 0) {
str[n--] = '\0';
}
}
void SkipSpace(const char **ptr) {
while (**ptr && isspace(**ptr)) {
(*ptr)++;
}
}
void StringUpper(char *str) {
while (*str) {
*str = toupper(*str);
str++;
}
}
void StringUpper(char *str, int len) {
while (len--) {
*str = toupper(*str);
str++;
}
}
void DataToHexString(const uint8_t *data, size_t size, std::string *output) {
Buffer buffer;
for (size_t i = 0; i < size; i++) {
@@ -140,11 +119,6 @@ std::string StringFromInt(int value)
return temp;
}
std::string StringFromBool(bool value)
{
return value ? "True" : "False";
}
// Turns " hej " into "hej". Also handles tabs.
std::string StripSpaces(const std::string &str)
{
@@ -167,27 +141,6 @@ std::string StripQuotes(const std::string& s)
return s;
}
// For Debugging. Read out an u8 array.
std::string ArrayToString(const uint8_t *data, uint32_t size, int line_len, bool spaces)
{
std::ostringstream oss;
oss << std::setfill('0') << std::hex;
for (int line = 0; size; ++data, --size)
{
oss << std::setw(2) << (int)*data;
if (line_len == ++line)
{
oss << '\n';
line = 0;
}
else if (spaces)
oss << ' ';
}
return oss.str();
}
void SplitString(const std::string& str, const char delim, std::vector<std::string>& output)
{
size_t next = 0;
@@ -243,9 +196,3 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
}
return result;
}
int strcmpIgnore(std::string str1, std::string str2, std::string ignorestr1, std::string ignorestr2) {
str1 = ReplaceAll(str1, ignorestr1, ignorestr2);
str2 = ReplaceAll(str2, ignorestr1, ignorestr2);
return strcmp(str1.c_str(),str2.c_str());
}
-19
View File
@@ -13,16 +13,6 @@
#include <strings.h>
#endif
// Dumb wrapper around itoa, providing a buffer. Declare this on the stack.
class ITOA {
public:
char buffer[16];
const char *p(int i) {
sprintf(buffer, "%i", i);
return &buffer[0];
}
};
// Useful for shaders with error messages..
std::string LineNumberString(const std::string &str);
@@ -62,9 +52,6 @@ inline void StringToHexString(const std::string &data, std::string *output) {
std::string StringFromFormat(const char* format, ...);
std::string StringFromInt(int value);
std::string StringFromBool(bool value);
std::string ArrayToString(const uint8_t *data, uint32_t size, int line_len = 20, bool spaces = true);
std::string StripSpaces(const std::string &s);
std::string StripQuotes(const std::string &s);
@@ -75,10 +62,4 @@ void GetQuotedStrings(const std::string& str, std::vector<std::string>& output);
std::string ReplaceAll(std::string input, const std::string& src, const std::string& dest);
// Compare two strings, ignore the difference between the ignorestr1 and the ignorestr2 in str1 and str2.
int strcmpIgnore(std::string str1, std::string str2, std::string ignorestr1, std::string ignorestr2);
void StringTrimEndNonAlphaNum(char *str);
void SkipSpace(const char **ptr);
void StringUpper(char *str);
void StringUpper(char *str, int len);
+1 -22
View File
@@ -2,27 +2,6 @@
#include <string>
// inflate/deflate convenience wrapper. Uses zlib.
bool compress_string(const std::string& str, std::string *dest, int compressionlevel = 9);
bool decompress_string(const std::string& str, std::string *dest);
// Delta encoding/decoding - many formats benefit from a pass of this before zlibbing.
// WARNING : Do not use these with floating point data, especially not float16...
template <class T>
inline void delta(T *data, int length) {
T prev = data[0];
for (int i = 1; i < length; i++) {
T temp = data[i] - prev;
prev = data[i];
data[i] = temp;
}
}
template <class T>
inline void dedelta(T *data, int length) {
for (int i = 1; i < length; i++) {
data[i] += data[i - 1];
}
}
-49
View File
@@ -1,49 +0,0 @@
#pragma once
#include <vector>
#include <string>
class Listable
{
public:
virtual ~Listable() {}
virtual const char *getItem(size_t i) const = 0;
virtual size_t numItems() const = 0;
// Returns -1 for not found.
// Child classes are meant to specialize this if they have a faster way
// than brute force search.
virtual int getIndex(const char *text) {
for (size_t i = 0; i < numItems(); i++) {
if (!strcmp(getItem(i), text))
return i;
}
return -1;
}
};
class ArrayListable : public Listable
{
public:
ArrayListable(const char * const*arr, size_t count) : arr_(arr), count_(count) {}
virtual ~ArrayListable() {}
virtual const char *getItem(size_t i) const { return arr_[i]; }
virtual size_t numItems() const { return count_; }
private:
const char *const*arr_;
size_t count_;
};
class VectorListable : public Listable
{
VectorListable(const std::vector<std::string> &vec) : vec_(vec) {}
virtual ~VectorListable() {}
virtual const char *getItem(size_t i) const { return vec_[i].c_str(); }
virtual size_t numItems() const { return vec_.size(); }
private:
const std::vector<std::string> &vec_;
};
-3
View File
@@ -29,7 +29,6 @@ int RIFFReader::ReadInt() {
return 0;
}
// let's get into the business
bool RIFFReader::Descend(uint32_t intoId) {
if (depth_ > 30)
return false;
@@ -83,7 +82,6 @@ bool RIFFReader::Descend(uint32_t intoId) {
return true;
}
// let's ascend out
void RIFFReader::Ascend() {
// ascend, and restore information
depth_--;
@@ -91,7 +89,6 @@ void RIFFReader::Ascend() {
eof_ = stack[depth_].parentEOF;
}
// read a block
void RIFFReader::ReadData(void *what, int count) {
memcpy(what, data_ + pos_, count);
pos_ += count;
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
// RIFF file format reader/writer. Very old code, basically a total mess but it still works.
// Has nothing to do with the ChunkFile.h used in Dolphin or PPSSPP.
// Simple RIFF file format reader/writer.
// Unrelated to the ChunkFile.h used in Dolphin and PPSSPP.
// TO REMEMBER WHEN USING:
+1 -1
View File
@@ -52,7 +52,7 @@ public:
void Set(const char* key, bool newValue, bool defaultValue);
void Set(const char* key, bool newValue) {
Set(key, StringFromBool(newValue).c_str());
Set(key, newValue ? "True" : "False");
}
void Set(const char* key, const std::vector<std::string>& newValues);
+2 -3
View File
@@ -1,9 +1,8 @@
set(SRCS
lin/matrix4x4.cpp
lin/vec3.cpp
lin/quat.cpp
curves.cpp
math_util.cpp
curves.cpp
math_util.cpp
)
set(SRCS ${SRCS})
-159
View File
@@ -3,7 +3,6 @@
#include <cstdio>
#include "math/lin/vec3.h"
#include "math/lin/quat.h"
#include "math/fast/fast_matrix.h"
#ifdef _WIN32
@@ -16,32 +15,6 @@
namespace Lin {
Matrix4x4 Matrix4x4::simpleInverse() const {
Matrix4x4 out;
out.xx = xx;
out.xy = yx;
out.xz = zx;
out.yx = xy;
out.yy = yy;
out.yz = zy;
out.zx = xz;
out.zy = yz;
out.zz = zz;
out.wx = -(xx * wx + xy * wy + xz * wz);
out.wy = -(yx * wx + yy * wy + yz * wz);
out.wz = -(zx * wx + zy * wy + zz * wz);
out.xw = 0.0f;
out.yw = 0.0f;
out.zw = 0.0f;
out.ww = 1.0f;
return out;
}
Matrix4x4 Matrix4x4::transpose() const
{
Matrix4x4 out;
@@ -59,100 +32,6 @@ Matrix4x4 Matrix4x4::operator * (const Matrix4x4 &other) const
return temp;
}
Matrix4x4 Matrix4x4::inverse() const {
Matrix4x4 temp;
float dW = 1.0f / (xx*(yy*zz - yz*zy) - xy*(yx*zz - yz*zx) - xz*(yy*zx - yx*zy));
temp.xx = (yy*zz - yz*zy) * dW;
temp.xy = (xz*zy - xy*zz) * dW;
temp.xz = (xy*yz - xz*yy) * dW;
temp.xw = xw;
temp.yx = (yz*zx - yx*zz) * dW;
temp.yy = (xx*zz - xz*zx) * dW;
temp.yz = (xz*yx - xx*zx) * dW;
temp.yw = yw;
temp.zx = (yx*zy - yy*zx) * dW;
temp.zy = (xy*zx - xx*zy) * dW;
temp.zz = (xx*yy - xy*yx) * dW;
temp.zw = zw;
temp.wx = (yy*(zx*wz - zz*wx) + yz*(zy*wx - zx*wy) - yx*(zy*wz - zz*wy)) * dW;
temp.wy = (xx*(zy*wz - zz*wy) + xy*(zz*wx - zx*wz) + xz*(zx*wy - zy*wx)) * dW;
temp.wz = (xy*(yx*wz - yz*wx) + xz*(yy*wx - yx*wy) - xx*(yy*wz - yz*wy)) * dW;
temp.ww = ww;
return temp;
}
void Matrix4x4::setViewLookAt(const Vec3 &vFrom, const Vec3 &vAt, const Vec3 &vWorldUp) {
Vec3 vView = vFrom - vAt; // OpenGL, sigh...
vView.normalize();
float DotProduct = vWorldUp * vView;
Vec3 vUp = vWorldUp - vView * DotProduct;
float Length = vUp.length();
if (1e-6f > Length) {
// EMERGENCY
vUp = Vec3(0.0f, 1.0f, 0.0f) - vView * vView.y;
// If we still have near-zero length, resort to a different axis.
Length = vUp.length();
if (1e-6f > Length)
{
vUp = Vec3(0.0f, 0.0f, 1.0f) - vView * vView.z;
Length = vUp.length();
if (1e-6f > Length)
return;
}
}
vUp.normalize();
Vec3 vRight = vUp % vView;
empty();
xx = vRight.x; xy = vUp.x; xz=vView.x;
yx = vRight.y; yy = vUp.y; yz=vView.y;
zx = vRight.z; zy = vUp.z; zz=vView.z;
wx = -vFrom * vRight;
wy = -vFrom * vUp;
wz = -vFrom * vView;
ww = 1.0f;
}
void Matrix4x4::setViewLookAtD3D(const Vec3 &vFrom, const Vec3 &vAt, const Vec3 &vWorldUp) {
Vec3 vView = vAt - vFrom;
vView.normalize();
float DotProduct = vWorldUp * vView;
Vec3 vUp = vWorldUp - vView * DotProduct;
float Length = vUp.length();
if (1e-6f > Length) {
vUp = Vec3(0.0f, 1.0f, 0.0f) - vView * vView.y;
// If we still have near-zero length, resort to a different axis.
Length = vUp.length();
if (1e-6f > Length)
{
vUp = Vec3(0.0f, 0.0f, 1.0f) - vView * vView.z;
Length = vUp.length();
if (1e-6f > Length)
return;
}
}
vUp.normalize();
Vec3 vRight = vUp % vView;
empty();
xx = vRight.x; xy = vUp.x; xz=vView.x;
yx = vRight.y; yy = vUp.y; yz=vView.y;
zx = vRight.z; zy = vUp.z; zz=vView.z;
wx = -vFrom * vRight;
wy = -vFrom * vUp;
wz = -vFrom * vView;
ww = 1.0f;
}
void Matrix4x4::setViewFrame(const Vec3 &pos, const Vec3 &vRight, const Vec3 &vView, const Vec3 &vUp) {
xx = vRight.x; xy = vUp.x; xz=vView.x; xw = 0.0f;
yx = vRight.y; yy = vUp.y; yz=vView.y; yw = 0.0f;
@@ -164,44 +43,6 @@ void Matrix4x4::setViewFrame(const Vec3 &pos, const Vec3 &vRight, const Vec3 &vV
ww = 1.0f;
}
//YXZ euler angles
void Matrix4x4::setRotation(float x,float y, float z)
{
setRotationY(y);
Matrix4x4 temp;
temp.setRotationX(x);
*this *= temp;
temp.setRotationZ(z);
*this *= temp;
}
void Matrix4x4::setProjection(float near, float far, float fov_horiz, float aspect) {
// Now OpenGL style.
empty();
float xFac = tanf(fov_horiz * 3.14f/360);
float yFac = xFac * aspect;
xx = 1.0f / xFac;
yy = 1.0f / yFac;
zz = -(far+near)/(far-near);
zw = -1.0f;
wz = -(2*far*near)/(far-near);
}
void Matrix4x4::setProjectionD3D(float near_plane, float far_plane, float fov_horiz, float aspect) {
empty();
float Q, f;
f = fov_horiz*0.5f;
Q = far_plane / (far_plane - near_plane);
xx = (float)(1.0f / tanf(f));;
yy = (float)(1.0f / tanf(f*aspect));
zz = Q;
wz = -Q * near_plane;
zw = 1.0f;
}
void Matrix4x4::setOrtho(float left, float right, float bottom, float top, float near, float far) {
empty();
xx = 2.0f / (right - left);
+2 -52
View File
@@ -24,19 +24,6 @@ public:
const Vec3 front() const {return Vec3(zx, zy, zz);}
const Vec3 move() const {return Vec3(wx, wy, wz);}
void setRight(const Vec3 &v) {
xx = v.x; xy = v.y; xz = v.z;
}
void setUp(const Vec3 &v) {
yx = v.x; yy = v.y; yz = v.z;
}
void setFront(const Vec3 &v) {
zx = v.x; zy = v.y; zz = v.z;
}
void setMove(const Vec3 &v) {
wx = v.x; wy = v.y; wz = v.z;
}
const float &operator[](int i) const {
return *(((const float *)this) + i);
}
@@ -53,17 +40,14 @@ public:
void empty() {
memset(this, 0, 16 * sizeof(float));
}
void setScaling(const float f) {
empty();
xx=yy=zz=f; ww=1.0f;
}
static Matrix4x4 identity() {
Matrix4x4 id;
id.setIdentity();
return id;
}
void setIdentity() {
setScaling(1.0f);
empty();
xx = yy = zz = ww = 1.0f;
}
void setTranslation(const Vec3 &trans) {
setIdentity();
@@ -72,37 +56,8 @@ public:
wz = trans.z;
}
Matrix4x4 inverse() const;
Matrix4x4 simpleInverse() const;
Matrix4x4 transpose() const;
void setRotationX(const float a) {
empty();
float c = cosf(a);
float s = sinf(a);
xx = 1.0f;
yy = c; yz = s;
zy = -s; zz = c;
ww = 1.0f;
}
void setRotationY(const float a) {
empty();
float c = cosf(a);
float s = sinf(a);
xx = c; xz = -s;
yy = 1.0f;
zx = s; zz = c;
ww = 1.0f;
}
void setRotationZ(const float a) {
empty();
float c = cosf(a);
float s = sinf(a);
xx = c; xy = s;
yx = -s; yy = c;
zz = 1.0f;
ww = 1.0f;
}
// Exact angles to avoid any artifacts.
void setRotationZ90() {
empty();
@@ -132,15 +87,10 @@ public:
ww = 1.0f;
}
void setRotation(float x,float y, float z);
void setProjection(float near_plane, float far_plane, float fov_horiz, float aspect = 0.75f);
void setProjectionD3D(float near_plane, float far_plane, float fov_horiz, float aspect = 0.75f);
void setOrtho(float left, float right, float bottom, float top, float near, float far);
void setOrthoD3D(float left, float right, float bottom, float top, float near, float far);
void setOrthoVulkan(float left, float right, float top, float bottom, float near, float far);
void setViewLookAt(const Vec3 &from, const Vec3 &at, const Vec3 &worldup);
void setViewLookAtD3D(const Vec3 &from, const Vec3 &at, const Vec3 &worldup);
void setViewFrame(const Vec3 &pos, const Vec3 &right, const Vec3 &forward, const Vec3 &up);
void toText(char *buffer, int len) const;
void print() const;
-13
View File
@@ -1,13 +0,0 @@
#include "math/lin/matrix4x4.h"
#include "math/lin/plane.h"
namespace Lin {
void Plane::TransformByIT(const Matrix4x4 &m, Plane *out) {
out->x = x * m.xx + y * m.yx + z * m.zx + d * m.wx;
out->y = x * m.xy + y * m.yy + z * m.zy + d * m.wy;
out->z = x * m.xz + y * m.yz + z * m.zz + d * m.wz;
out->d = x * m.xw + y * m.yw + z * m.zw + d * m.ww;
}
} // namespace Lin
-41
View File
@@ -1,41 +0,0 @@
#ifndef _PLANE_H
#define _PLANE_H
#include "math/lin/vec3.h"
namespace Lin {
class Matrix4x4;
class Plane {
public:
float x, y, z, d;
Plane() {}
Plane(float x_, float y_, float z_, float d_)
: x(x_), y(y_), z(z_), d(d_) { }
~Plane() {}
float Distance(const Vec3 &v) const {
return x * v.x + y * v.y + z * v.z + d;
}
float Distance(float px, float py, float pz) const {
return x * px + y * py + z * pz + d;
}
void Normalize() {
float inv_length = sqrtf(x * x + y * y + z * z);
x *= inv_length;
y *= inv_length;
z *= inv_length;
d *= inv_length;
}
// Matrix is the inverse transpose of the wanted transform.
// out cannot be equal to this.
void TransformByIT(const Matrix4x4 &matrix, Plane *out);
};
} // namespace Lin
#endif
-129
View File
@@ -1,129 +0,0 @@
#include "math/lin/quat.h"
#include "math/lin/matrix4x4.h"
namespace Lin {
void Quaternion::toMatrix(Matrix4x4 *out) const {
Matrix4x4 temp;
temp.setIdentity();
float ww, xx, yy, zz, wx, wy, wz, xy, xz, yz;
ww = w*w; xx = x*x; yy = y*y; zz = z*z;
wx = w*x*2; wy = w*y*2; wz = w*z*2;
xy = x*y*2; xz = x*z*2; yz = y*z*2;
temp.xx = ww + xx - yy - zz;
temp.xy = xy + wz;
temp.xz = xz - wy;
temp.yx = xy - wz;
temp.yy = ww - xx + yy - zz;
temp.yz = yz + wx;
temp.zx = xz + wy;
temp.zy = yz - wx;
temp.zz = ww - xx - yy + zz;
*out = temp;
}
Quaternion Quaternion::fromMatrix(Matrix4x4 &m)
{
// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
// article "Quaternion Calculus and Fast Animation".
Quaternion q(0,0,0,1);
/*
float fTrace = m[0][0] + m[1][1] + m[2][2];
float fRoot;
if( fTrace > 0.0 )
{
fRoot = sqrtf( fTrace + 1.0f );
q.w = 0.5f * fRoot;
fRoot = 0.5f / fRoot;
q.x = ( m[2][1] - m[1][2] ) * fRoot;
q.y = ( m[0][2] - m[2][0] ) * fRoot;
q.z = ( m[1][0] - m[0][1] ) * fRoot;
}
else
{
int iNext[3] = { 1, 2, 0 };
int i = 0;
if( m[1][1] > m[0][0] )
i = 1;
if( m[2][2] > m[i][i] )
i = 2;
int j = iNext[i];
int k = iNext[j];
fRoot = sqrtf( m[i][i] - m[j][j] - m[k][k] + 1.0f );
float *apfQuat = &q.x;
apfQuat[i] = 0.5f * fRoot;
fRoot = 0.5f / fRoot;
q.w = ( m[k][j] - m[j][k] ) * fRoot;
apfQuat[j] = ( m[j][i] + m[i][j] ) * fRoot;
apfQuat[k] = ( m[k][i] + m[i][k] ) * fRoot;
}
q.normalize(); */
return q;
};
// TODO: Allegedly, lerp + normalize can achieve almost as good results.
Quaternion Quaternion::slerp(const Quaternion &to, const float a) const {
Quaternion to2;
float angle, cos_angle, scale_from, scale_to, sin_angle;
cos_angle = (x * to.x) + (y * to.y) + (z * to.z) + (w * to.w); //4D dot product
if (cos_angle < 0.0f)
{
cos_angle = -cos_angle;
to2.w = -to.w; to2.x = -to.x; to2.y = -to.y; to2.z = -to.z;
}
else
{
to2 = to;
}
if ((1.0f - fabsf(cos_angle)) > 0.00001f)
{
/* spherical linear interpolation (SLERP) */
angle = acosf(cos_angle);
sin_angle = sinf(angle);
scale_from = sinf((1.0f - a) * angle) / sin_angle;
scale_to = sinf(a * angle) / sin_angle;
}
else
{
/* to prevent divide-by-zero, resort to linear interpolation */
// This is okay in 99% of cases anyway, maybe should be the default?
scale_from = 1.0f - a;
scale_to = a;
}
return Quaternion(
scale_from*x + scale_to*to2.x,
scale_from*y + scale_to*to2.y,
scale_from*z + scale_to*to2.z,
scale_from*w + scale_to*to2.w
);
}
Quaternion Quaternion::multiply(const Quaternion &q) const {
return Quaternion((w * q.x) + (x * q.w) + (y * q.z) - (z * q.y),
(w * q.y) + (y * q.w) + (z * q.x) - (x * q.z),
(w * q.z) + (z * q.w) + (x * q.y) - (y * q.x),
(w * q.w) - (x * q.x) - (y * q.y) - (z * q.z));
}
}
-96
View File
@@ -1,96 +0,0 @@
#ifndef _MATH_LIN_QUAT_H
#define _MATH_LIN_QUAT_H
#include "math/lin/vec3.h"
namespace Lin {
class Matrix4x4;
class Quaternion
{
public:
float x,y,z,w;
Quaternion() { }
Quaternion(const float _x, const float _y, const float _z, const float _w) {
x=_x; y=_y; z=_z; w=_w;
}
void setIdentity()
{
x=y=z=0; w=1.0f;
}
void setXRotation(const float r) { w = cosf(r / 2); x = sinf(r / 2); y = z = 0; }
void setYRotation(const float r) { w = cosf(r / 2); y = sinf(r / 2); x = z = 0; }
void setZRotation(const float r) { w = cosf(r / 2); z = sinf(r / 2); x = y = 0; }
void toMatrix(Matrix4x4 *out) const;
static Quaternion fromMatrix(Matrix4x4 &m);
Quaternion operator *(Quaternion &q) const
{
return Quaternion(
(w * q.w) - (x * q.x) - (y * q.y) - (z * q.z),
(w * q.x) + (x * q.w) + (y * q.z) - (z * q.y),
(w * q.y) + (y * q.w) + (z * q.x) - (x * q.z),
(w * q.z) + (z * q.w) + (x * q.y) - (y * q.x)
);
}
Quaternion operator -()
{
return Quaternion(-x,-y,-z,-w);
}
void setRotation(Vec3 axis, float angle)
{
axis /= axis.length();
angle *= .5f;
float sine = sinf(angle);
w = cosf(angle);
x = sine * axis.x;
y = sine * axis.y;
z = sine * axis.z;
}
void toAxisAngle(Vec3 &v, float &angle)
{
normalize();
if (w==1.0f && x==0.0f && y==0.0f && z==0.0f)
{
v = Vec3(0,1,0);
angle = 0.0f;
return;
}
float cos_a = w;
angle = acosf(cos_a) * 2;
float sin_a = sqrtf( 1.0f - cos_a * cos_a );
if (fabsf(sin_a) < 0.00005f) sin_a = 1;
float inv_sin_a=1.0f/sin_a;
v.x = x * inv_sin_a;
v.y = y * inv_sin_a;
v.z = z * inv_sin_a;
}
enum {
QUAT_SHORT,
QUAT_LONG,
QUAT_CW,
QUAT_CCW
};
Quaternion slerp(const Quaternion &to, const float a) const;
Quaternion multiply(const Quaternion &q) const;
float &operator [] (int i) {
return *((&x) + i);
}
float operator [] (int i) const {
return *((&x) + i);
}
//not sure about this, maybe mag is supposed to sqrt
float magnitude() const {
return x*x + y*y + z*z + w*w;
}
void normalize() {
float f = 1.0f/sqrtf(magnitude());
x*=f; y*=f; z*=f; w*=f;
}
};
} // namespace Lin
#endif // _MATH_LIN_QUAT_H
-14
View File
@@ -1,14 +0,0 @@
#pragma once
#include "vec3.h"
/* __declspec(align(16)) */ struct Ray
{
Vec3 origin;
int pad;
Vec3 dir;
int pad2;
Vec3 invdir;
int pad3;
};
-12
View File
@@ -10,18 +10,6 @@ Vec3 Vec3::operator *(const Matrix4x4 &m) const {
x*m.xy + y*m.yy + z*m.zy + m.wy,
x*m.xz + y*m.yz + z*m.zz + m.wz);
}
Vec4 Vec3::multiply4D(const Matrix4x4 &m) const {
return Vec4(x*m.xx + y*m.yx + z*m.zx + m.wx,
x*m.xy + y*m.yy + z*m.zy + m.wy,
x*m.xz + y*m.yz + z*m.zz + m.wz,
x*m.xw + y*m.yw + z*m.zw + m.ww);
}
Vec4 Vec4::multiply4D(Matrix4x4 &m) const {
return Vec4(x*m.xx + y*m.yx + z*m.zx + w*m.wx,
x*m.xy + y*m.yy + z*m.zy + w*m.wy,
x*m.xz + y*m.yz + z*m.zz + w*m.wz,
x*m.xw + y*m.yw + z*m.zw + w*m.ww);
}
Vec3 Vec3::rotatedBy(const Matrix4x4 &m) const {
return Vec3(x*m.xx + y*m.yx + z*m.zx,
-6
View File
@@ -14,7 +14,6 @@ public:
float x,y,z,w;
Vec4(){}
Vec4(float a, float b, float c, float d) {x=a;y=b;z=c;w=d;}
Vec4 multiply4D(Matrix4x4 &m) const;
};
class Vec3 {
@@ -80,7 +79,6 @@ public:
void operator *=(const Matrix4x4 &m) {
*this = *this * m;
}
Vec4 multiply4D(const Matrix4x4 &m) const;
Vec3 rotatedBy(const Matrix4x4 &m) const;
Vec3 operator %(const Vec3 &v) const {
return Vec3(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
@@ -134,10 +132,6 @@ inline Vec3 cross(const Vec3 &a, const Vec3 &b) {
return a % b;
}
inline float sqr(const Vec3 &v) {
return dot(v, v);
}
class AABBox {
public:
Vec3 min;
-42
View File
@@ -8,9 +8,6 @@
#include "base/basictypes.h"
inline float sqr(float f) {return f*f;}
inline float sqr_signed(float f) {return f<0 ? -f*f : f*f;}
typedef unsigned short float16;
// This ain't a 1.5.10 float16, it's a stupid hack format where we chop 16 bits off a float.
@@ -56,33 +53,6 @@ inline uint32_t log2i(uint32_t val) {
#define M_PI 3.141592653589793f
#endif
// Calculate pseudo-random 32 bit number based on linear congruential method.
void SetSeed(unsigned int seed);
unsigned int GenerateRandomNumber();
inline float GenerateRandomFloat01() {
return (float)((double)GenerateRandomNumber() / 0xFFFFFFFF);
}
inline float GenerateRandomSignedFloat() {
return (float)((double)GenerateRandomNumber() / 0x80000000) - 1.0f;
}
inline float GaussRand()
{
float R1 = GenerateRandomFloat01();
float R2 = GenerateRandomFloat01();
float X = sqrtf(-2.0f * logf(R1)) * cosf(2.0f * PI * R2);
if (X > 4.0f) X = 4.0f;
if (X < -4.0f) X = -4.0f;
return X;
}
// Accuracy unknown
inline double atan_fast(double x) {
return (x / (1.0 + 0.28 * (x * x)));
}
template<class T>
inline T clamp_value(T val, T floor, T cap) {
if (val > cap)
@@ -93,18 +63,6 @@ inline T clamp_value(T val, T floor, T cap) {
return val;
}
// linear -> dB conversion
inline float lin2dB(float lin) {
const float LOG_2_DB = 8.6858896380650365530225783783321f; // 20 / ln( 10 )
return logf(lin) * LOG_2_DB;
}
// dB -> linear conversion
inline float dB2lin(float dB) {
const float DB_2_LOG = 0.11512925464970228420089957273422f; // ln( 10 ) / 20
return expf(dB * DB_2_LOG);
}
union FP32 {
uint32_t u;
float f;
+1 -8
View File
@@ -382,7 +382,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Qt\QtMain.h" />
<ClInclude Include="base\backtrace.h" />
<ClInclude Include="base\basictypes.h" />
<ClInclude Include="base\buffer.h" />
<ClInclude Include="base\colorutil.h" />
@@ -391,7 +390,6 @@
<ClInclude Include="base\stringutil.h" />
<ClInclude Include="data\base64.h" />
<ClInclude Include="data\compression.h" />
<ClInclude Include="data\listable.h" />
<ClInclude Include="ext\cityhash\city.h" />
<ClInclude Include="ext\cityhash\citycrc.h" />
<ClInclude Include="ext\gason\gason.h" />
@@ -456,8 +454,6 @@
<ClInclude Include="math\expression_parser.h" />
<ClInclude Include="math\geom2d.h" />
<ClInclude Include="math\lin\matrix4x4.h" />
<ClInclude Include="math\lin\plane.h" />
<ClInclude Include="math\lin\quat.h" />
<ClInclude Include="math\lin\vec3.h" />
<ClInclude Include="math\math_util.h" />
<ClInclude Include="math\fast\fast_math.h" />
@@ -490,7 +486,6 @@
<ClInclude Include="util\tiny_set.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="base\backtrace.cpp" />
<ClCompile Include="base\buffer.cpp" />
<ClCompile Include="base\colorutil.cpp" />
<ClCompile Include="base\display.cpp" />
@@ -1172,8 +1167,6 @@
<ClCompile Include="math\curves.cpp" />
<ClCompile Include="math\expression_parser.cpp" />
<ClCompile Include="math\lin\matrix4x4.cpp" />
<ClCompile Include="math\lin\plane.cpp" />
<ClCompile Include="math\lin\quat.cpp" />
<ClCompile Include="math\lin\vec3.cpp" />
<ClCompile Include="math\math_util.cpp" />
<ClCompile Include="math\fast\fast_math.c" />
@@ -1213,4 +1206,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
-30
View File
@@ -41,9 +41,6 @@
<ClInclude Include="image\zim_save.h">
<Filter>image</Filter>
</ClInclude>
<ClInclude Include="math\lin\quat.h">
<Filter>math</Filter>
</ClInclude>
<ClInclude Include="math\lin\matrix4x4.h">
<Filter>math</Filter>
</ClInclude>
@@ -110,12 +107,6 @@
<ClInclude Include="ui\ui.h">
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="data\listable.h">
<Filter>data</Filter>
</ClInclude>
<ClInclude Include="base\logging.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="net\http_client.h">
<Filter>net</Filter>
</ClInclude>
@@ -131,12 +122,6 @@
<ClInclude Include="ui\screen.h">
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="base\backtrace.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="math\lin\plane.h">
<Filter>math</Filter>
</ClInclude>
<ClInclude Include="util\random\rng.h">
<Filter>util</Filter>
</ClInclude>
@@ -370,9 +355,6 @@
<ClCompile Include="math\lin\matrix4x4.cpp">
<Filter>math</Filter>
</ClCompile>
<ClCompile Include="math\lin\quat.cpp">
<Filter>math</Filter>
</ClCompile>
<ClCompile Include="math\lin\vec3.cpp">
<Filter>math</Filter>
</ClCompile>
@@ -439,12 +421,6 @@
<ClCompile Include="ui\screen.cpp">
<Filter>ui</Filter>
</ClCompile>
<ClCompile Include="base\backtrace.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="math\lin\plane.cpp">
<Filter>math</Filter>
</ClCompile>
<ClCompile Include="math\curves.cpp">
<Filter>math</Filter>
</ClCompile>
@@ -781,9 +757,6 @@
<ClCompile Include="thin3d\d3d11_loader.cpp">
<Filter>thin3d</Filter>
</ClCompile>
<ClCompile Include="base\logging.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="gfx_es2\draw_text_win.cpp">
<Filter>gfx</Filter>
</ClCompile>
@@ -873,9 +846,6 @@
<Filter Include="data">
<UniqueIdentifier>{d5fa3d62-88bf-4dc4-9814-28f3c0444e62}</UniqueIdentifier>
</Filter>
<Filter Include="io">
<UniqueIdentifier>{1e85f968-7106-483c-ae7d-77d0ef58d787}</UniqueIdentifier>
</Filter>
<Filter Include="net">
<UniqueIdentifier>{6a548b3d-3a4c-4114-aa2f-0b42bf7bf2ce}</UniqueIdentifier>
</Filter>
+1 -2
View File
@@ -162,9 +162,8 @@ void View::PersistData(PersistStatus status, std::string anonId, PersistMap &sto
break;
}
ITOA stringify;
for (int i = 0; i < (int)tweens_.size(); ++i) {
tweens_[i]->PersistData(status, tag + "/" + stringify.p((int)i), storage);
tweens_[i]->PersistData(status, tag + "/" + StringFromInt(i), storage);
}
}
+1 -2
View File
@@ -70,9 +70,8 @@ void ViewGroup::PersistData(PersistStatus status, std::string anonId, PersistMap
tag = anonId;
}
ITOA stringify;
for (size_t i = 0; i < views_.size(); i++) {
views_[i]->PersistData(status, tag + "/" + stringify.p((int)i), storage);
views_[i]->PersistData(status, tag + "/" + StringFromInt((int)i), storage);
}
}
-3
View File
@@ -214,7 +214,6 @@ SOURCES_CXX += \
$(GPUDIR)/GLES/ShaderManagerGLES.cpp \
$(GPUDIR)/GLES/StateMappingGLES.cpp \
$(GPUDIR)/GLES/StencilBufferGLES.cpp \
$(EXTDIR)/native/base/backtrace.cpp \
$(EXTDIR)/native/base/buffer.cpp \
$(EXTDIR)/native/base/colorutil.cpp \
$(EXTDIR)/native/base/display.cpp \
@@ -302,8 +301,6 @@ SOURCES_CXX += $(NATIVEDIR)/math/dataconv.cpp \
$(NATIVEDIR)/math/curves.cpp \
$(NATIVEDIR)/math/expression_parser.cpp \
$(NATIVEDIR)/math/lin/matrix4x4.cpp \
$(NATIVEDIR)/math/lin/plane.cpp \
$(NATIVEDIR)/math/lin/quat.cpp \
$(NATIVEDIR)/math/lin/vec3.cpp \
$(NATIVEDIR)/net/http_client.cpp \
$(NATIVEDIR)/net/resolve.cpp \