https://git.reactos.org/?p=reactos.git;a=commitdiff;h=868f57e6b2c38071d2233…
commit 868f57e6b2c38071d2233d2fa3344ad908c666b4
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Sep 21 23:07:40 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Thu Feb 4 16:37:07 2021 +0100
[WINESYNC] d3dx9: Simplify D3DXSphereBoundProbe() a bit.
Spurred by a patch by Alex Henrie.
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 18ae539c914a9b5a89f63d8cf9c2a21273eccc6c by Matteo Bruni
<mbruni(a)codeweavers.com>
---
dll/directx/wine/d3dx9_36/mesh.c | 23 ++++++-------
modules/rostests/winetests/d3dx9_36/mesh.c | 32 ++++++++++++++---
sdk/tools/winesync/d3dx9.cfg | 55 ++++++++++++++++++++----------
3 files changed, 75 insertions(+), 35 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/mesh.c b/dll/directx/wine/d3dx9_36/mesh.c
index 6c6628a1127..e2265ed6aed 100644
--- a/dll/directx/wine/d3dx9_36/mesh.c
+++ b/dll/directx/wine/d3dx9_36/mesh.c
@@ -1694,11 +1694,7 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface,
DWORD flags,
if (FAILED(hr)) goto cleanup;
} else if (flags & D3DXMESHOPT_ATTRSORT) {
if (!(flags & D3DXMESHOPT_IGNOREVERTS))
- {
FIXME("D3DXMESHOPT_ATTRSORT vertex reordering not
implemented.\n");
- hr = E_NOTIMPL;
- goto cleanup;
- }
hr = iface->lpVtbl->LockAttributeBuffer(iface, 0, &attrib_buffer);
if (FAILED(hr)) goto cleanup;
@@ -2414,20 +2410,21 @@ BOOL WINAPI D3DXIntersectTri(const D3DXVECTOR3 *p0, const
D3DXVECTOR3 *p1, const
return FALSE;
}
-BOOL WINAPI D3DXSphereBoundProbe(const D3DXVECTOR3 *pcenter, float radius,
- const D3DXVECTOR3 *prayposition, const D3DXVECTOR3 *praydirection)
+BOOL WINAPI D3DXSphereBoundProbe(const D3DXVECTOR3 *center, float radius,
+ const D3DXVECTOR3 *ray_position, const D3DXVECTOR3 *ray_direction)
{
- D3DXVECTOR3 difference;
- FLOAT a, b, c, d;
+ D3DXVECTOR3 difference = {0};
+ float a, b, c, d;
- a = D3DXVec3LengthSq(praydirection);
- if (!D3DXVec3Subtract(&difference, prayposition, pcenter)) return FALSE;
- b = D3DXVec3Dot(&difference, praydirection);
+ D3DXVec3Subtract(&difference, ray_position, center);
c = D3DXVec3LengthSq(&difference) - radius * radius;
+ if (c < 0.0f)
+ return TRUE;
+ a = D3DXVec3LengthSq(ray_direction);
+ b = D3DXVec3Dot(&difference, ray_direction);
d = b * b - a * c;
- if ( ( d <= 0.0f ) || ( sqrt(d) <= b ) ) return FALSE;
- return TRUE;
+ return d >= 0.0f && (b <= 0.0f || d > b * b);
}
/*************************************************************************
diff --git a/modules/rostests/winetests/d3dx9_36/mesh.c
b/modules/rostests/winetests/d3dx9_36/mesh.c
index c410162da6f..aa486bc14e6 100644
--- a/modules/rostests/winetests/d3dx9_36/mesh.c
+++ b/modules/rostests/winetests/d3dx9_36/mesh.c
@@ -435,18 +435,42 @@ static void D3DXBoundProbeTest(void)
radius = sqrt(77.0f);
center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
-
rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
- ok(result == TRUE, "expected TRUE, received FALSE\n");
+ ok(result == TRUE, "Got unexpected result %#x.\n", result);
rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
- ok(result == FALSE, "expected FALSE, received TRUE\n");
+ ok(result == FALSE, "Got unexpected result %#x.\n", result);
+
+ raydirection.x = -2.0f; raydirection.y = 4.0f; raydirection.z = -2.0f;
+ result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
+ ok(result == TRUE, "Got unexpected result %#x.\n", result);
rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
- ok(result == FALSE, "expected FALSE, received TRUE\n");
+ ok(result == FALSE, "Got unexpected result %#x.\n", result);
+
+ raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
+ result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
+ ok(result == FALSE, "Got unexpected result %#x.\n", result);
+
+ radius = 1.0f;
+ rayposition.x = 2.0f; rayposition.y = 2.0f; rayposition.z = 3.0f;
+ result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
+ ok(result == FALSE, "Got unexpected result %#x.\n", result);
+
+ raydirection.x = 0.0f; raydirection.y = 0.0f; raydirection.z = 1.0f;
+ result = D3DXSphereBoundProbe(¢er, radius, &rayposition,
&raydirection);
+ ok(result == TRUE, "Got unexpected result %#x.\n", result);
+
+ if (0)
+ {
+ /* All these crash on native. */
+ D3DXSphereBoundProbe(¢er, radius, &rayposition, NULL);
+ D3DXSphereBoundProbe(¢er, radius, NULL, &raydirection);
+ D3DXSphereBoundProbe(NULL, radius, &rayposition, &raydirection);
+ }
}
static void D3DXComputeBoundingBoxTest(void)
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index d42dffe471b..5af2cd084a9 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -1,18 +1,37 @@
-directories: {dlls/d3dx9_24: dll/directx/wine/d3dx9_24, dlls/d3dx9_25:
dll/directx/wine/d3dx9_25,
- dlls/d3dx9_26: dll/directx/wine/d3dx9_26, dlls/d3dx9_27: dll/directx/wine/d3dx9_27,
- dlls/d3dx9_28: dll/directx/wine/d3dx9_28, dlls/d3dx9_29: dll/directx/wine/d3dx9_29,
- dlls/d3dx9_30: dll/directx/wine/d3dx9_30, dlls/d3dx9_31: dll/directx/wine/d3dx9_31,
- dlls/d3dx9_32: dll/directx/wine/d3dx9_32, dlls/d3dx9_33: dll/directx/wine/d3dx9_33,
- dlls/d3dx9_34: dll/directx/wine/d3dx9_34, dlls/d3dx9_35: dll/directx/wine/d3dx9_35,
- dlls/d3dx9_36: dll/directx/wine/d3dx9_36, dlls/d3dx9_36/tests:
modules/rostests/winetests/d3dx9_36,
- dlls/d3dx9_37: dll/directx/wine/d3dx9_37, dlls/d3dx9_38: dll/directx/wine/d3dx9_38,
- dlls/d3dx9_39: dll/directx/wine/d3dx9_39, dlls/d3dx9_40: dll/directx/wine/d3dx9_40,
- dlls/d3dx9_41: dll/directx/wine/d3dx9_41, dlls/d3dx9_42: dll/directx/wine/d3dx9_42,
- dlls/d3dx9_43: dll/directx/wine/d3dx9_43}
-files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h:
sdk/include/dxsdk/d3dx9anim.h,
- include/d3dx9core.h: sdk/include/dxsdk/d3dx9core.h, include/d3dx9effect.h:
sdk/include/dxsdk/d3dx9effect.h,
- include/d3dx9math.h: sdk/include/dxsdk/d3dx9math.h, include/d3dx9math.inl:
sdk/include/dxsdk/d3dx9math.inl,
- include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h:
sdk/include/dxsdk/d3dx9of.h,
- include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h:
sdk/include/dxsdk/d3dx9shape.h,
- include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h:
sdk/include/dxsdk/d3dx9xof.h}
-tags: {wine: ea7cf679150f790d2e375d99ee226ea4881b490a}
+directories:
+ dlls/d3dx9_24: dll/directx/wine/d3dx9_24
+ dlls/d3dx9_25: dll/directx/wine/d3dx9_25
+ dlls/d3dx9_26: dll/directx/wine/d3dx9_26
+ dlls/d3dx9_27: dll/directx/wine/d3dx9_27
+ dlls/d3dx9_28: dll/directx/wine/d3dx9_28
+ dlls/d3dx9_29: dll/directx/wine/d3dx9_29
+ dlls/d3dx9_30: dll/directx/wine/d3dx9_30
+ dlls/d3dx9_31: dll/directx/wine/d3dx9_31
+ dlls/d3dx9_32: dll/directx/wine/d3dx9_32
+ dlls/d3dx9_33: dll/directx/wine/d3dx9_33
+ dlls/d3dx9_34: dll/directx/wine/d3dx9_34
+ dlls/d3dx9_35: dll/directx/wine/d3dx9_35
+ dlls/d3dx9_36: dll/directx/wine/d3dx9_36
+ dlls/d3dx9_36/tests: modules/rostests/winetests/d3dx9_36
+ dlls/d3dx9_37: dll/directx/wine/d3dx9_37
+ dlls/d3dx9_38: dll/directx/wine/d3dx9_38
+ dlls/d3dx9_39: dll/directx/wine/d3dx9_39
+ dlls/d3dx9_40: dll/directx/wine/d3dx9_40
+ dlls/d3dx9_41: dll/directx/wine/d3dx9_41
+ dlls/d3dx9_42: dll/directx/wine/d3dx9_42
+ dlls/d3dx9_43: dll/directx/wine/d3dx9_43
+files:
+ include/d3dx9.h: sdk/include/dxsdk/d3dx9.h
+ include/d3dx9anim.h: sdk/include/dxsdk/d3dx9anim.h
+ include/d3dx9core.h: sdk/include/dxsdk/d3dx9core.h
+ include/d3dx9effect.h: sdk/include/dxsdk/d3dx9effect.h
+ include/d3dx9math.h: sdk/include/dxsdk/d3dx9math.h
+ include/d3dx9math.inl: sdk/include/dxsdk/d3dx9math.inl
+ include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h
+ include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h
+ include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h
+ include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
+ include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
+ include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h
+tags:
+ wine: 1dcc3ab292151cd91ea4202b92107c3a91527c7a