more render improvements
This commit is contained in:
parent
836172f87c
commit
1e1676a34a
|
@ -240,9 +240,9 @@ Quad2i GameCamera::computeVisibleQuad() {
|
||||||
Vec2f v1(std::sin(degToRad(viewDegree - hAng - fov)), std::cos(degToRad(viewDegree - hAng - fov)));
|
Vec2f v1(std::sin(degToRad(viewDegree - hAng - fov)), std::cos(degToRad(viewDegree - hAng - fov)));
|
||||||
Vec2f v2(std::sin(degToRad(viewDegree - hAng + fov)), std::cos(degToRad(viewDegree - hAng + fov)));
|
Vec2f v2(std::sin(degToRad(viewDegree - hAng + fov)), std::cos(degToRad(viewDegree - hAng + fov)));
|
||||||
|
|
||||||
v.normalize(false);
|
v.normalize();
|
||||||
v1.normalize(false);
|
v1.normalize();
|
||||||
v2.normalize(false);
|
v2.normalize();
|
||||||
|
|
||||||
Vec2f p = Vec2f(pos.x, pos.z) - v * dist;
|
Vec2f p = Vec2f(pos.x, pos.z) - v * dist;
|
||||||
Vec2i p1(static_cast<int>(p.x + v1.x * nearDist), static_cast<int>(p.y + v1.y * nearDist));
|
Vec2i p1(static_cast<int>(p.x + v1.x * nearDist), static_cast<int>(p.y + v1.y * nearDist));
|
||||||
|
|
|
@ -8139,14 +8139,14 @@ void Renderer::renderArrow(const Vec3f &pos1, const Vec3f &pos2,
|
||||||
const float blendDelay= 5.f;
|
const float blendDelay= 5.f;
|
||||||
|
|
||||||
Vec3f dir= Vec3f(pos2-pos1);
|
Vec3f dir= Vec3f(pos2-pos1);
|
||||||
float len= dir.length(false);
|
float len= dir.length();
|
||||||
|
|
||||||
if(len>maxlen) {
|
if(len>maxlen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float alphaFactor= clamp((maxlen-len)/blendDelay, 0.f, 1.f);
|
float alphaFactor= clamp((maxlen-len)/blendDelay, 0.f, 1.f);
|
||||||
|
|
||||||
dir.normalize(false);
|
dir.normalize();
|
||||||
Vec3f normal= dir.cross(Vec3f(0, 1, 0));
|
Vec3f normal= dir.cross(Vec3f(0, 1, 0));
|
||||||
|
|
||||||
Vec3f pos2Left= pos2 + normal*(width-0.05f) - dir*arrowEndSize*width;
|
Vec3f pos2Left= pos2 + normal*(width-0.05f) - dir*arrowEndSize*width;
|
||||||
|
|
|
@ -2349,7 +2349,7 @@ void World::exploreCells(const Vec2i &newPos, int sightRange, int teamIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//explore
|
//explore
|
||||||
float posLength = currRelPos.length();
|
double posLength = currRelPos.length();
|
||||||
//if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
//if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
||||||
if(posLength < surfSightRange + indirectSightRange + 1) {
|
if(posLength < surfSightRange + indirectSightRange + 1) {
|
||||||
sc->setExplored(teamIndex, true);
|
sc->setExplored(teamIndex, true);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
Quaternion();
|
Quaternion();
|
||||||
Quaternion(float w, const Vec3f &v);
|
Quaternion(float w, const Vec3f &v);
|
||||||
Quaternion(const EulerAngles &eulerAngles);
|
Quaternion(const EulerAngles &eulerAngles);
|
||||||
Quaternion(const AxisAngle &axisAngle);
|
//Quaternion(const AxisAngle &axisAngle);
|
||||||
|
|
||||||
//initializers
|
//initializers
|
||||||
void setMultIdentity();
|
void setMultIdentity();
|
||||||
|
@ -75,9 +75,9 @@ public:
|
||||||
void setEuler(const EulerAngles &eulerAngles);
|
void setEuler(const EulerAngles &eulerAngles);
|
||||||
|
|
||||||
//unary operators
|
//unary operators
|
||||||
float length();
|
//float length();
|
||||||
Quaternion conjugate();
|
Quaternion conjugate();
|
||||||
void normalize();
|
//void normalize();
|
||||||
|
|
||||||
//binary operators
|
//binary operators
|
||||||
Quaternion operator + (const Quaternion &q) const;
|
Quaternion operator + (const Quaternion &q) const;
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
//conversions
|
//conversions
|
||||||
Matrix3f toMatrix3() const;
|
Matrix3f toMatrix3() const;
|
||||||
Matrix4f toMatrix4() const;
|
Matrix4f toMatrix4() const;
|
||||||
AxisAngle toAxisAngle() const;
|
//AxisAngle toAxisAngle() const;
|
||||||
|
|
||||||
//local axis
|
//local axis
|
||||||
Vec3f getLocalXAxis() const;
|
Vec3f getLocalXAxis() const;
|
||||||
|
|
|
@ -213,32 +213,36 @@ public:
|
||||||
return x < v.x || (x == v.x && y < v.y);
|
return x < v.x || (x == v.x && y < v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float length(bool requireAccuracy=true) const {
|
inline double length() const {
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
if(requireAccuracy == true) {
|
// if(requireAccuracy == true) {
|
||||||
return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y)));
|
// return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y)));
|
||||||
}
|
// }
|
||||||
return static_cast<float>(std::sqrt(static_cast<float>(x*x + y*y)));
|
// return static_cast<float>(std::sqrt(static_cast<float>(x*x + y*y)));
|
||||||
#else
|
//#else
|
||||||
return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
// return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
||||||
#endif
|
//#endif
|
||||||
|
return static_cast<double>(std::sqrt(static_cast<double>(x*x + y*y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void normalize(bool requireAccuracy=true){
|
inline void normalize(){
|
||||||
T m= length(requireAccuracy);
|
T m= length();
|
||||||
x/= m;
|
x/= m;
|
||||||
y/= m;
|
y/= m;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vec2<T> rotate(float rad) {
|
inline Vec2<T> rotate(float rad) {
|
||||||
const float
|
// const float
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
c = streflop::cosf(rad),
|
// c = streflop::cosf(rad),
|
||||||
s = streflop::sinf(rad);
|
// s = streflop::sinf(rad);
|
||||||
#else
|
//#else
|
||||||
c = cosf(rad),
|
// c = cosf(rad),
|
||||||
s = sinf(rad);
|
// s = sinf(rad);
|
||||||
#endif
|
//#endif
|
||||||
|
double c = std::cos(rad),
|
||||||
|
s = std::sin(rad);
|
||||||
|
|
||||||
return Vec2<T>(x*c-y*s,x*s+y*c);
|
return Vec2<T>(x*c-y*s,x*s+y*c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,19 +451,20 @@ public:
|
||||||
return Vec3<T>(v-*this).length();
|
return Vec3<T>(v-*this).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float length(bool requireAccuracy=true) const {
|
inline double length() const {
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
if(requireAccuracy == true) {
|
// if(requireAccuracy == true) {
|
||||||
return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y + z*z)));
|
// return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y + z*z)));
|
||||||
}
|
// }
|
||||||
return static_cast<float>(std::sqrt(x*x + y*y + z*z));
|
// return static_cast<float>(std::sqrt(x*x + y*y + z*z));
|
||||||
#else
|
//#else
|
||||||
return static_cast<float>(sqrt(x*x + y*y + z*z));
|
// return static_cast<float>(sqrt(x*x + y*y + z*z));
|
||||||
#endif
|
//#endif
|
||||||
|
return static_cast<double>(std::sqrt(x*x + y*y + z*z));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void normalize(bool requireAccuracy=true){
|
inline void normalize() {
|
||||||
T m= length(requireAccuracy);
|
T m= length();
|
||||||
x/= m;
|
x/= m;
|
||||||
y/= m;
|
y/= m;
|
||||||
z/= m;
|
z/= m;
|
||||||
|
|
|
@ -250,7 +250,7 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
|
||||||
// float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f;
|
// float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
float angleV= radToDeg(std::atan2(flatDirection.length(false), direction.y)) - 90.f;
|
float angleV= radToDeg(std::atan2(flatDirection.length(), direction.y)) - 90.f;
|
||||||
glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z);
|
glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z);
|
||||||
|
|
||||||
//#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
|
|
|
@ -1209,19 +1209,26 @@ void Pixmap2D::splat(const Pixmap2D *leftUp, const Pixmap2D *rightUp, const Pixm
|
||||||
float distRd= splatDist(Vec2i(i, j), Vec2i(w, h));
|
float distRd= splatDist(Vec2i(i, j), Vec2i(w, h));
|
||||||
|
|
||||||
const float powFactor= 2.0f;
|
const float powFactor= 2.0f;
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
distLu= streflop::pow(static_cast<streflop::Simple>(distLu), static_cast<streflop::Simple>(powFactor));
|
// distLu= streflop::pow(static_cast<streflop::Simple>(distLu), static_cast<streflop::Simple>(powFactor));
|
||||||
distRu= streflop::pow(static_cast<streflop::Simple>(distRu), static_cast<streflop::Simple>(powFactor));
|
// distRu= streflop::pow(static_cast<streflop::Simple>(distRu), static_cast<streflop::Simple>(powFactor));
|
||||||
distLd= streflop::pow(static_cast<streflop::Simple>(distLd), static_cast<streflop::Simple>(powFactor));
|
// distLd= streflop::pow(static_cast<streflop::Simple>(distLd), static_cast<streflop::Simple>(powFactor));
|
||||||
distRd= streflop::pow(static_cast<streflop::Simple>(distRd), static_cast<streflop::Simple>(powFactor));
|
// distRd= streflop::pow(static_cast<streflop::Simple>(distRd), static_cast<streflop::Simple>(powFactor));
|
||||||
avg= streflop::pow(static_cast<streflop::Simple>(avg), static_cast<streflop::Simple>(powFactor));
|
// avg= streflop::pow(static_cast<streflop::Simple>(avg), static_cast<streflop::Simple>(powFactor));
|
||||||
#else
|
//#else
|
||||||
distLu= pow(distLu, powFactor);
|
// distLu= pow(distLu, powFactor);
|
||||||
distRu= pow(distRu, powFactor);
|
// distRu= pow(distRu, powFactor);
|
||||||
distLd= pow(distLd, powFactor);
|
// distLd= pow(distLd, powFactor);
|
||||||
distRd= pow(distRd, powFactor);
|
// distRd= pow(distRd, powFactor);
|
||||||
avg= pow(avg, powFactor);
|
// avg= pow(avg, powFactor);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
distLu = std::pow(distLu, powFactor);
|
||||||
|
distRu = std::pow(distRu, powFactor);
|
||||||
|
distLd = std::pow(distLd, powFactor);
|
||||||
|
distRd = std::pow(distRd, powFactor);
|
||||||
|
avg = std::pow(avg, powFactor);
|
||||||
|
|
||||||
float lu= distLu>avg? 0: ((avg-distLu))*random.randRange(0.5f, 1.0f);
|
float lu= distLu>avg? 0: ((avg-distLu))*random.randRange(0.5f, 1.0f);
|
||||||
float ru= distRu>avg? 0: ((avg-distRu))*random.randRange(0.5f, 1.0f);
|
float ru= distRu>avg? 0: ((avg-distRu))*random.randRange(0.5f, 1.0f);
|
||||||
float ld= distLd>avg? 0: ((avg-distLd))*random.randRange(0.5f, 1.0f);
|
float ld= distLd>avg? 0: ((avg-distLd))*random.randRange(0.5f, 1.0f);
|
||||||
|
|
|
@ -52,9 +52,9 @@ Quaternion::Quaternion(const EulerAngles &eulerAngles){
|
||||||
setEuler(eulerAngles);
|
setEuler(eulerAngles);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion::Quaternion(const AxisAngle &axisAngle){
|
//Quaternion::Quaternion(const AxisAngle &axisAngle){
|
||||||
setAxisAngle(axisAngle);
|
// setAxisAngle(axisAngle);
|
||||||
}
|
//}
|
||||||
|
|
||||||
void Quaternion::setMultIdentity(){
|
void Quaternion::setMultIdentity(){
|
||||||
w= 1.0f;
|
w= 1.0f;
|
||||||
|
@ -66,42 +66,50 @@ void Quaternion::setAddIdentity(){
|
||||||
v= Vec3f(0.0f);
|
v= Vec3f(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quaternion::setAxisAngle(const AxisAngle &axisAngle){
|
//void Quaternion::setAxisAngle(const AxisAngle &axisAngle){
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
w= streflop::cosf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
// w= streflop::cosf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
||||||
v.x= axisAngle.axis.x * streflop::sinf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
// v.x= axisAngle.axis.x * streflop::sinf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
||||||
v.y= axisAngle.axis.y * streflop::sinf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
// v.y= axisAngle.axis.y * streflop::sinf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
||||||
v.z= axisAngle.axis.z * streflop::sinf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
// v.z= axisAngle.axis.z * streflop::sinf(static_cast<streflop::Simple>(axisAngle.angle/2.0f));
|
||||||
#else
|
//#else
|
||||||
w= cosf(axisAngle.angle/2.0f);
|
// w= cosf(axisAngle.angle/2.0f);
|
||||||
v.x= axisAngle.axis.x * sinf(axisAngle.angle/2.0f);
|
// v.x= axisAngle.axis.x * sinf(axisAngle.angle/2.0f);
|
||||||
v.y= axisAngle.axis.y * sinf(axisAngle.angle/2.0f);
|
// v.y= axisAngle.axis.y * sinf(axisAngle.angle/2.0f);
|
||||||
v.z= axisAngle.axis.z * sinf(axisAngle.angle/2.0f);
|
// v.z= axisAngle.axis.z * sinf(axisAngle.angle/2.0f);
|
||||||
#endif
|
//#endif
|
||||||
}
|
//}
|
||||||
|
|
||||||
void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||||
Quaternion qx, qy, qz, qr;
|
Quaternion qx, qy, qz, qr;
|
||||||
|
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
qx.w= streflop::cosf(static_cast<streflop::Simple>(eulerAngles.x/2.0f));
|
// qx.w= streflop::cosf(static_cast<streflop::Simple>(eulerAngles.x/2.0f));
|
||||||
qx.v= Vec3f(streflop::sinf(static_cast<streflop::Simple>(eulerAngles.x/2.0f)), 0.0f, 0.0f);
|
// qx.v= Vec3f(streflop::sinf(static_cast<streflop::Simple>(eulerAngles.x/2.0f)), 0.0f, 0.0f);
|
||||||
|
//
|
||||||
|
// qy.w= streflop::cosf(static_cast<streflop::Simple>(eulerAngles.y/2.0f));
|
||||||
|
// qy.v= Vec3f(0.0f, streflop::sinf(static_cast<streflop::Simple>(eulerAngles.y/2.0f)), 0.0f);
|
||||||
|
//
|
||||||
|
// qz.w= streflop::cosf(static_cast<streflop::Simple>(eulerAngles.z/2.0f));
|
||||||
|
// qz.v= Vec3f(0.0f, 0.0f, streflop::sinf(static_cast<streflop::Simple>(eulerAngles.z/2.0f)));
|
||||||
|
//#else
|
||||||
|
// qx.w= cosf(eulerAngles.x/2.0f);
|
||||||
|
// qx.v= Vec3f(sinf(eulerAngles.x/2.0f), 0.0f, 0.0f);
|
||||||
|
//
|
||||||
|
// qy.w= cosf(eulerAngles.y/2.0f);
|
||||||
|
// qy.v= Vec3f(0.0f, sinf(eulerAngles.y/2.0f), 0.0f);
|
||||||
|
//
|
||||||
|
// qz.w= cosf(eulerAngles.z/2.0f);
|
||||||
|
// qz.v= Vec3f(0.0f, 0.0f, sinf(eulerAngles.z/2.0f));
|
||||||
|
//#endif
|
||||||
|
qx.w= std::cos(eulerAngles.x/2.0f);
|
||||||
|
qx.v= Vec3f(std::sin(eulerAngles.x/2.0f), 0.0f, 0.0f);
|
||||||
|
|
||||||
qy.w= streflop::cosf(static_cast<streflop::Simple>(eulerAngles.y/2.0f));
|
qy.w= std::cos(eulerAngles.y/2.0f);
|
||||||
qy.v= Vec3f(0.0f, streflop::sinf(static_cast<streflop::Simple>(eulerAngles.y/2.0f)), 0.0f);
|
qy.v= Vec3f(0.0f, std::sin(eulerAngles.y/2.0f), 0.0f);
|
||||||
|
|
||||||
qz.w= streflop::cosf(static_cast<streflop::Simple>(eulerAngles.z/2.0f));
|
qz.w= std::cos(eulerAngles.z/2.0f);
|
||||||
qz.v= Vec3f(0.0f, 0.0f, streflop::sinf(static_cast<streflop::Simple>(eulerAngles.z/2.0f)));
|
qz.v= Vec3f(0.0f, 0.0f, std::sin(eulerAngles.z/2.0f));
|
||||||
#else
|
|
||||||
qx.w= cosf(eulerAngles.x/2.0f);
|
|
||||||
qx.v= Vec3f(sinf(eulerAngles.x/2.0f), 0.0f, 0.0f);
|
|
||||||
|
|
||||||
qy.w= cosf(eulerAngles.y/2.0f);
|
|
||||||
qy.v= Vec3f(0.0f, sinf(eulerAngles.y/2.0f), 0.0f);
|
|
||||||
|
|
||||||
qz.w= cosf(eulerAngles.z/2.0f);
|
|
||||||
qz.v= Vec3f(0.0f, 0.0f, sinf(eulerAngles.z/2.0f));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
qr= qx*qy*qz;
|
qr= qx*qy*qz;
|
||||||
|
|
||||||
|
@ -109,23 +117,23 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||||
v= qr.v;
|
v= qr.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Quaternion::length(){
|
//float Quaternion::length(){
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
return streflop::sqrt(static_cast<streflop::Simple>(w*w+v.x*v.x+v.y*v.y+v.z*v.z));
|
// return streflop::sqrt(static_cast<streflop::Simple>(w*w+v.x*v.x+v.y*v.y+v.z*v.z));
|
||||||
#else
|
//#else
|
||||||
return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
|
// return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
|
||||||
#endif
|
//#endif
|
||||||
}
|
//}
|
||||||
|
|
||||||
Quaternion Quaternion::conjugate(){
|
Quaternion Quaternion::conjugate(){
|
||||||
return Quaternion(w, -v);
|
return Quaternion(w, -v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quaternion::normalize(){
|
//void Quaternion::normalize(){
|
||||||
float il= 1.f/length();
|
// float il= 1.f/length();
|
||||||
w*= il;
|
// w*= il;
|
||||||
v= v*il;
|
// v= v*il;
|
||||||
}
|
//}
|
||||||
|
|
||||||
Quaternion Quaternion::operator + (const Quaternion &q) const{
|
Quaternion Quaternion::operator + (const Quaternion &q) const{
|
||||||
return Quaternion(w +q.w, v+q.v);
|
return Quaternion(w +q.w, v+q.v);
|
||||||
|
@ -204,14 +212,14 @@ Matrix4f Quaternion::toMatrix4() const{
|
||||||
return rm;
|
return rm;
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisAngle Quaternion::toAxisAngle() const{
|
//AxisAngle Quaternion::toAxisAngle() const{
|
||||||
float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z);
|
// float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||||
#ifdef USE_STREFLOP
|
//#ifdef USE_STREFLOP
|
||||||
return AxisAngle(v*scale, 2*streflop::acosf(static_cast<streflop::Simple>(w)));
|
// return AxisAngle(v*scale, 2*streflop::acosf(static_cast<streflop::Simple>(w)));
|
||||||
#else
|
//#else
|
||||||
return AxisAngle(v*scale, 2*acosf(w));
|
// return AxisAngle(v*scale, 2*acosf(w));
|
||||||
#endif
|
//#endif
|
||||||
}
|
//}
|
||||||
|
|
||||||
Vec3f Quaternion::getLocalXAxis() const{
|
Vec3f Quaternion::getLocalXAxis() const{
|
||||||
return Vec3f(
|
return Vec3f(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user