Skip to content

Commit

Permalink
dTriColliderCommon.h: macro replaced with inline functions
Browse files Browse the repository at this point in the history
Thanks to Im-Dex. Imported from commit:
Im-dex/xray-162@98f5477
  • Loading branch information
Xottab-DUTY committed Aug 13, 2017
1 parent 8ed36ae commit 7b87b2c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/xrPhysics/tri-colliderknoopc/dTriColliderCommon.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#ifndef D_TRI_COLLIDER_COMMON
#define D_TRI_COLLIDER_COMMON

Expand All @@ -7,11 +8,21 @@

extern xr_vector<flags8> gl_cl_tries_state;

// extern xr_vector<int>::iterator I,E,B ;
// NOTE: stride is sizeof(dContact) * N, where N is [0, ...)
inline dContactGeom* CONTACT(dContactGeom* ptr, const int stride)
{
const size_t count = stride / sizeof(dContact);
dContact* contact = (dContact*)(uintptr_t(ptr) - uintptr_t(offsetof(dContact, geom)));
return &contact[count].geom;
}

inline dSurfaceParameters* SURFACE(dContactGeom* ptr, const int stride)
{
const size_t count = stride / sizeof(dContact);
dContact* contact = (dContact*)(uintptr_t(ptr) - uintptr_t(offsetof(dContact, geom)));
return &contact[count].surface;
}

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

#define M_SIN_PI_3 REAL(0.8660254037844386467637231707529362)
Expand Down

0 comments on commit 7b87b2c

Please sign in to comment.