2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Bug fixes and CAutoMapper mouse events

This commit is contained in:
Jack Andersen
2019-01-22 21:52:19 -10:00
parent aeb6a9a147
commit 137968ecc7
38 changed files with 275 additions and 118 deletions

View File

@@ -393,6 +393,7 @@ void CGraphics::SetViewportResolution(const zeus::CVector2i& res) {
g_CroppedViewport.x10_height = res.y;
g_Viewport.x10_halfWidth = res.x / 2.f;
g_Viewport.x14_halfHeight = res.y / 2.f;
g_Viewport.aspect = res.x / float(res.y);
if (g_GuiSys)
g_GuiSys->OnViewportResize();
}

View File

@@ -103,6 +103,7 @@ struct SViewport {
u32 xc_height;
float x10_halfWidth;
float x14_halfHeight;
float aspect;
};
extern SViewport g_Viewport;

View File

@@ -15,11 +15,13 @@ float CLight::CalculateLightRadius() const {
if (x2c_distQ > FLT_EPSILON) {
if (intens <= FLT_EPSILON)
return 0.f;
return std::sqrt(intens / 5.f * intens / 255.f * x2c_distQ);
return std::sqrt(intens / (0.0588235f * x2c_distQ));
}
float nextIntens = 5.f * intens / 255.f;
return intens / std::min(0.2f, nextIntens) * x28_distL;
if (x28_distL > FLT_EPSILON)
return intens / (0.0588235f * x28_distL);
return 0.f;
}
float CLight::GetIntensity() const {

View File

@@ -66,8 +66,7 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
}
void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
if (aspect < 1.7777f) {
if (g_Viewport.aspect < 1.7777f) {
float targetHeight = g_Viewport.x8_width / 1.7777f;
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
delta /= float(g_Viewport.xc_height);
@@ -81,8 +80,7 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
void CWideScreenFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) {}
float CWideScreenFilter::SetViewportToMatch(float t) {
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
if (aspect < 1.7777f) {
if (g_Viewport.aspect < 1.7777f) {
float targetHeight = g_Viewport.x8_width / 1.7777f;
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
boo::SWindowRect rect = {};
@@ -94,7 +92,7 @@ float CWideScreenFilter::SetViewportToMatch(float t) {
return 1.7777f;
} else {
SetViewportToFull();
return aspect;
return g_Viewport.aspect;
}
}

View File

@@ -84,10 +84,10 @@ FOG_STRUCT_GLSL
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n"
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n"
" ret += lights[i].color * angAtt * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n"
" }\n"
" \n"
" return ret;\n"
" return clamp(ret, 0.0, 1.0);\n"
"}\n"sv;
static std::string_view LightingShadowGLSL =

View File

@@ -83,7 +83,7 @@ FOG_STRUCT_HLSL
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n"
" ret += lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" ret += lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n"
" \n"
" return ret;\n"

View File

@@ -83,7 +83,7 @@ FOG_STRUCT_METAL
" float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n"
" lu.lights[i].angAtt[1] * angDot +\n"
" lu.lights[i].angAtt[0];\n"
" ret += lu.lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" ret += lu.lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n"
" \n"
" return ret;\n"

View File

@@ -40,7 +40,6 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
{{1.f, -1.f, 0.f}, {1.f, 0.f}}};
m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts, sizeof(BlurVert), 4);
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
struct Vert {
zeus::CVector3f pos;
zeus::CVector2f screenUv;
@@ -48,8 +47,8 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
zeus::CVector2f maskUv;
} verts[4] = {{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
{{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
{{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {aspect * 4.f, 4.f}, {1.f, 1.f}},
{{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {aspect * 4.f, 0.f}, {1.f, 0.f}}};
{{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {g_Viewport.aspect * 4.f, 4.f}, {1.f, 1.f}},
{{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {g_Viewport.aspect * 4.f, 0.f}, {1.f, 0.f}}};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBufBlurX.get()};