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 v2(std::sin(degToRad(viewDegree - hAng + fov)), std::cos(degToRad(viewDegree - hAng + fov)));
|
||||
|
||||
v.normalize(false);
|
||||
v1.normalize(false);
|
||||
v2.normalize(false);
|
||||
v.normalize();
|
||||
v1.normalize();
|
||||
v2.normalize();
|
||||
|
||||
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));
|
||||
|
|
|
@ -8139,14 +8139,14 @@ void Renderer::renderArrow(const Vec3f &pos1, const Vec3f &pos2,
|
|||
const float blendDelay= 5.f;
|
||||
|
||||
Vec3f dir= Vec3f(pos2-pos1);
|
||||
float len= dir.length(false);
|
||||
float len= dir.length();
|
||||
|
||||
if(len>maxlen) {
|
||||
return;
|
||||
}
|
||||
float alphaFactor= clamp((maxlen-len)/blendDelay, 0.f, 1.f);
|
||||
|
||||
dir.normalize(false);
|
||||
dir.normalize();
|
||||
Vec3f normal= dir.cross(Vec3f(0, 1, 0));
|
||||
|
||||
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
|
||||
float posLength = currRelPos.length();
|
||||
double posLength = currRelPos.length();
|
||||
//if(Vec2i(0).dist(currRelPos) < surfSightRange + indirectSightRange + 1) {
|
||||
if(posLength < surfSightRange + indirectSightRange + 1) {
|
||||
sc->setExplored(teamIndex, true);
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
Quaternion();
|
||||
Quaternion(float w, const Vec3f &v);
|
||||
Quaternion(const EulerAngles &eulerAngles);
|
||||
Quaternion(const AxisAngle &axisAngle);
|
||||
//Quaternion(const AxisAngle &axisAngle);
|
||||
|
||||
//initializers
|
||||
void setMultIdentity();
|
||||
|
@ -75,9 +75,9 @@ public:
|
|||
void setEuler(const EulerAngles &eulerAngles);
|
||||
|
||||
//unary operators
|
||||
float length();
|
||||
//float length();
|
||||
Quaternion conjugate();
|
||||
void normalize();
|
||||
//void normalize();
|
||||
|
||||
//binary operators
|
||||
Quaternion operator + (const Quaternion &q) const;
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
//conversions
|
||||
Matrix3f toMatrix3() const;
|
||||
Matrix4f toMatrix4() const;
|
||||
AxisAngle toAxisAngle() const;
|
||||
//AxisAngle toAxisAngle() const;
|
||||
|
||||
//local axis
|
||||
Vec3f getLocalXAxis() const;
|
||||
|
|
|
@ -213,32 +213,36 @@ public:
|
|||
return x < v.x || (x == v.x && y < v.y);
|
||||
}
|
||||
|
||||
inline float length(bool requireAccuracy=true) const {
|
||||
#ifdef USE_STREFLOP
|
||||
if(requireAccuracy == true) {
|
||||
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)));
|
||||
#else
|
||||
return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
||||
#endif
|
||||
inline double length() const {
|
||||
//#ifdef USE_STREFLOP
|
||||
// if(requireAccuracy == true) {
|
||||
// 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)));
|
||||
//#else
|
||||
// return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
|
||||
//#endif
|
||||
return static_cast<double>(std::sqrt(static_cast<double>(x*x + y*y)));
|
||||
}
|
||||
|
||||
inline void normalize(bool requireAccuracy=true){
|
||||
T m= length(requireAccuracy);
|
||||
inline void normalize(){
|
||||
T m= length();
|
||||
x/= m;
|
||||
y/= m;
|
||||
}
|
||||
|
||||
inline Vec2<T> rotate(float rad){
|
||||
const float
|
||||
#ifdef USE_STREFLOP
|
||||
c = streflop::cosf(rad),
|
||||
s = streflop::sinf(rad);
|
||||
#else
|
||||
c = cosf(rad),
|
||||
s = sinf(rad);
|
||||
#endif
|
||||
inline Vec2<T> rotate(float rad) {
|
||||
// const float
|
||||
//#ifdef USE_STREFLOP
|
||||
// c = streflop::cosf(rad),
|
||||
// s = streflop::sinf(rad);
|
||||
//#else
|
||||
// c = cosf(rad),
|
||||
// s = sinf(rad);
|
||||
//#endif
|
||||
double c = std::cos(rad),
|
||||
s = std::sin(rad);
|
||||
|
||||
return Vec2<T>(x*c-y*s,x*s+y*c);
|
||||
}
|
||||
|
||||
|
@ -447,25 +451,26 @@ public:
|
|||
return Vec3<T>(v-*this).length();
|
||||
}
|
||||
|
||||
inline float length(bool requireAccuracy=true) const {
|
||||
#ifdef USE_STREFLOP
|
||||
if(requireAccuracy == true) {
|
||||
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));
|
||||
#else
|
||||
return static_cast<float>(sqrt(x*x + y*y + z*z));
|
||||
#endif
|
||||
inline double length() const {
|
||||
//#ifdef USE_STREFLOP
|
||||
// if(requireAccuracy == true) {
|
||||
// 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));
|
||||
//#else
|
||||
// return static_cast<float>(sqrt(x*x + y*y + z*z));
|
||||
//#endif
|
||||
return static_cast<double>(std::sqrt(x*x + y*y + z*z));
|
||||
}
|
||||
|
||||
inline void normalize(bool requireAccuracy=true){
|
||||
T m= length(requireAccuracy);
|
||||
inline void normalize() {
|
||||
T m= length();
|
||||
x/= m;
|
||||
y/= m;
|
||||
z/= m;
|
||||
}
|
||||
|
||||
inline Vec3<T> getNormalized() const{
|
||||
inline Vec3<T> getNormalized() const {
|
||||
T m= length();
|
||||
return Vec3<T>(x/m, y/m, z/m);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
|
|||
// float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f;
|
||||
//#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);
|
||||
|
||||
//#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));
|
||||
|
||||
const float powFactor= 2.0f;
|
||||
#ifdef USE_STREFLOP
|
||||
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));
|
||||
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));
|
||||
avg= streflop::pow(static_cast<streflop::Simple>(avg), static_cast<streflop::Simple>(powFactor));
|
||||
#else
|
||||
distLu= pow(distLu, powFactor);
|
||||
distRu= pow(distRu, powFactor);
|
||||
distLd= pow(distLd, powFactor);
|
||||
distRd= pow(distRd, powFactor);
|
||||
avg= pow(avg, powFactor);
|
||||
#endif
|
||||
//#ifdef USE_STREFLOP
|
||||
// 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));
|
||||
// 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));
|
||||
// avg= streflop::pow(static_cast<streflop::Simple>(avg), static_cast<streflop::Simple>(powFactor));
|
||||
//#else
|
||||
// distLu= pow(distLu, powFactor);
|
||||
// distRu= pow(distRu, powFactor);
|
||||
// distLd= pow(distLd, powFactor);
|
||||
// distRd= pow(distRd, powFactor);
|
||||
// avg= pow(avg, powFactor);
|
||||
//#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 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);
|
||||
|
|
|
@ -52,9 +52,9 @@ Quaternion::Quaternion(const EulerAngles &eulerAngles){
|
|||
setEuler(eulerAngles);
|
||||
}
|
||||
|
||||
Quaternion::Quaternion(const AxisAngle &axisAngle){
|
||||
setAxisAngle(axisAngle);
|
||||
}
|
||||
//Quaternion::Quaternion(const AxisAngle &axisAngle){
|
||||
// setAxisAngle(axisAngle);
|
||||
//}
|
||||
|
||||
void Quaternion::setMultIdentity(){
|
||||
w= 1.0f;
|
||||
|
@ -66,42 +66,50 @@ void Quaternion::setAddIdentity(){
|
|||
v= Vec3f(0.0f);
|
||||
}
|
||||
|
||||
void Quaternion::setAxisAngle(const AxisAngle &axisAngle){
|
||||
#ifdef USE_STREFLOP
|
||||
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.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));
|
||||
#else
|
||||
w= cosf(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.z= axisAngle.axis.z * sinf(axisAngle.angle/2.0f);
|
||||
#endif
|
||||
}
|
||||
//void Quaternion::setAxisAngle(const AxisAngle &axisAngle){
|
||||
//#ifdef USE_STREFLOP
|
||||
// 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.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));
|
||||
//#else
|
||||
// w= cosf(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.z= axisAngle.axis.z * sinf(axisAngle.angle/2.0f);
|
||||
//#endif
|
||||
//}
|
||||
|
||||
void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
||||
Quaternion qx, qy, qz, qr;
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
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);
|
||||
//#ifdef USE_STREFLOP
|
||||
// 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);
|
||||
//
|
||||
// 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.v= Vec3f(0.0f, streflop::sinf(static_cast<streflop::Simple>(eulerAngles.y/2.0f)), 0.0f);
|
||||
qy.w= std::cos(eulerAngles.y/2.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.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
|
||||
qz.w= std::cos(eulerAngles.z/2.0f);
|
||||
qz.v= Vec3f(0.0f, 0.0f, std::sin(eulerAngles.z/2.0f));
|
||||
|
||||
qr= qx*qy*qz;
|
||||
|
||||
|
@ -109,23 +117,23 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){
|
|||
v= qr.v;
|
||||
}
|
||||
|
||||
float Quaternion::length(){
|
||||
#ifdef USE_STREFLOP
|
||||
return streflop::sqrt(static_cast<streflop::Simple>(w*w+v.x*v.x+v.y*v.y+v.z*v.z));
|
||||
#else
|
||||
return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
|
||||
#endif
|
||||
}
|
||||
//float Quaternion::length(){
|
||||
//#ifdef USE_STREFLOP
|
||||
// return streflop::sqrt(static_cast<streflop::Simple>(w*w+v.x*v.x+v.y*v.y+v.z*v.z));
|
||||
//#else
|
||||
// return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
|
||||
//#endif
|
||||
//}
|
||||
|
||||
Quaternion Quaternion::conjugate(){
|
||||
return Quaternion(w, -v);
|
||||
}
|
||||
|
||||
void Quaternion::normalize(){
|
||||
float il= 1.f/length();
|
||||
w*= il;
|
||||
v= v*il;
|
||||
}
|
||||
//void Quaternion::normalize(){
|
||||
// float il= 1.f/length();
|
||||
// w*= il;
|
||||
// v= v*il;
|
||||
//}
|
||||
|
||||
Quaternion Quaternion::operator + (const Quaternion &q) const{
|
||||
return Quaternion(w +q.w, v+q.v);
|
||||
|
@ -204,14 +212,14 @@ Matrix4f Quaternion::toMatrix4() const{
|
|||
return rm;
|
||||
}
|
||||
|
||||
AxisAngle Quaternion::toAxisAngle() const{
|
||||
float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
#ifdef USE_STREFLOP
|
||||
return AxisAngle(v*scale, 2*streflop::acosf(static_cast<streflop::Simple>(w)));
|
||||
#else
|
||||
return AxisAngle(v*scale, 2*acosf(w));
|
||||
#endif
|
||||
}
|
||||
//AxisAngle Quaternion::toAxisAngle() const{
|
||||
// float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
//#ifdef USE_STREFLOP
|
||||
// return AxisAngle(v*scale, 2*streflop::acosf(static_cast<streflop::Simple>(w)));
|
||||
//#else
|
||||
// return AxisAngle(v*scale, 2*acosf(w));
|
||||
//#endif
|
||||
//}
|
||||
|
||||
Vec3f Quaternion::getLocalXAxis() const{
|
||||
return Vec3f(
|
||||
|
|
Loading…
Reference in New Issue