From 37491bb5d1f9bdb9b68929b6fe38114fe22674eb Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 22 Jun 2009 10:15:57 +0200 Subject: [PATCH] wined3d: Simplify the transformed position fixup a bit. --- dlls/wined3d/buffer.c | 26 +++++++------------------- dlls/wined3d/directx.c | 9 ++++++--- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index e9f3ff6cc03..8896db97093 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -506,27 +506,15 @@ static inline void fixup_d3dcolor(DWORD *dst_color) static inline void fixup_transformed_pos(float *p) { - float x, y, z, w; - - /* rhw conversion like in drawStridedSlow */ - if (p[3] == 1.0 || ((p[3] < eps) && (p[3] > -eps))) + /* rhw conversion like in position_float4(). */ + if (p[3] != 1.0 && p[3] != 0.0) { - x = p[0]; - y = p[1]; - z = p[2]; - w = 1.0; + float w = 1.0 / p[3]; + p[0] *= w; + p[1] *= w; + p[2] *= w; + p[3] = w; } - else - { - w = 1.0 / p[3]; - x = p[0] * w; - y = p[1] * w; - z = p[2] * w; - } - p[0] = x; - p[1] = y; - p[2] = z; - p[3] = w; } const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 28f07efabff..df5d4cccc0f 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4316,13 +4316,16 @@ static void WINE_GLAPI position_float4(const void *data) { const GLfloat *pos = data; - if (pos[3] < eps && pos[3] > -eps) - glVertex3fv(pos); - else { + if (pos[3] != 0.0 && pos[3] != 1.0) + { float w = 1.0 / pos[3]; glVertex4f(pos[0] * w, pos[1] * w, pos[2] * w, w); } + else + { + glVertex3fv(pos); + } } static void WINE_GLAPI diffuse_d3dcolor(const void *data)