Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
imdex committed Jul 15, 2017
1 parent 05490c8 commit 98f5477
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions code/engine/xrPhysics/tri-colliderknoopc/dTriColliderCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ extern xr_vector<flags8> gl_cl_tries_state;

// extern xr_vector<int>::iterator I,E,B ;

#define CONTACT(Ptr, Stride) ((dContactGeom*)(((char*)Ptr) + (Stride)))
// 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;
}
//#define SURFACE(Ptr, Stride) ((dSurfaceParameters*) (((char*)Ptr) +
//(Stride-sizeof(dSurfaceParameters))))
#define SURFACE(Ptr, Stride) \
((dSurfaceParameters*)(((char*)Ptr) + \
(Stride - offsetof(dContact, geom) + offsetof(dContact, surface))))
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 NUMC_MASK (0xffff)

#define M_SIN_PI_3 REAL(0.8660254037844386467637231707529362)
Expand Down

0 comments on commit 98f5477

Please sign in to comment.