Skip to content

Commit 7b87b2c

Browse files
committed
dTriColliderCommon.h: macro replaced with inline functions
Thanks to Im-Dex. Imported from commit: Im-dex/xray-162@98f5477
1 parent 8ed36ae commit 7b87b2c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/xrPhysics/tri-colliderknoopc/dTriColliderCommon.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pragma once
12
#ifndef D_TRI_COLLIDER_COMMON
23
#define D_TRI_COLLIDER_COMMON
34

@@ -7,11 +8,21 @@
78

89
extern xr_vector<flags8> gl_cl_tries_state;
910

10-
// extern xr_vector<int>::iterator I,E,B ;
11+
// NOTE: stride is sizeof(dContact) * N, where N is [0, ...)
12+
inline dContactGeom* CONTACT(dContactGeom* ptr, const int stride)
13+
{
14+
const size_t count = stride / sizeof(dContact);
15+
dContact* contact = (dContact*)(uintptr_t(ptr) - uintptr_t(offsetof(dContact, geom)));
16+
return &contact[count].geom;
17+
}
18+
19+
inline dSurfaceParameters* SURFACE(dContactGeom* ptr, const int stride)
20+
{
21+
const size_t count = stride / sizeof(dContact);
22+
dContact* contact = (dContact*)(uintptr_t(ptr) - uintptr_t(offsetof(dContact, geom)));
23+
return &contact[count].surface;
24+
}
1125

12-
#define CONTACT(Ptr, Stride) ((dContactGeom*)(((char*)Ptr) + (Stride)))
13-
//#define SURFACE(Ptr, Stride) ((dSurfaceParameters*)(((char*)Ptr) + (Stride - sizeof(dSurfaceParameters))))
14-
#define SURFACE(Ptr, Stride) ((dSurfaceParameters*) (((char*)Ptr) + (Stride - offsetof(dContact, geom) + offsetof(dContact, surface))))
1526
#define NUMC_MASK (0xffff)
1627

1728
#define M_SIN_PI_3 REAL(0.8660254037844386467637231707529362)

0 commit comments

Comments
 (0)