我一直在尝试修改下面的代码以使用 NEON Intrinsics,从而提高速度。不幸的是,似乎没有什么能正常工作。有谁知道出了什么问题?我将双打更新为单浮点元素。
typedef float REAL;
typedef REAL VEC3[3];
typedef struct driehoek
{
VEC3 norm; /* Face normal. */
REAL d; /* Plane equation D. */
VEC3 *vptr; /* Global vertex list pointer. */
VEC3 *nptr; /* Global normal list pointer. */
INT vindex[3]; /* Index of vertices. */
INT indx; /* Normal component max flag. */
BOOL norminterp; /* Do normal interpolation? */
BOOL vorder; /* Vertex order orientation. */
}driehoek;
typedef struct element
{
INT index;
struct object *parent; /* Ptr back to parent object. */
CHAR *data; /* Pointer to data info. */
BBOX bv; /* Element bounding volume. */
}ELEMENT;
INT TriangleIntersection(RAY *pr, ELEMENT *pe, IRECORD *hit)
{
FLOAT Rd_dot_Pn; /* Polygon normal dot ray direction. */
FLOAT Ro_dot_Pn; /* Polygon normal dot ray origin. */
FLOAT q1, q2;
FLOAT tval; /* Intersection t distance value. */
VEC3 *v1, *v2, *v3; /* Vertex list pointers. */
VEC3 e1, e2, e3; /* Edge vectors. */
driehoek *pt; /* Ptr to triangle data. */
pt = (driehoek *)pe->data;
Rd_dot_Pn = VecDot(pt->norm, pr->D);
if (ABS(Rd_dot_Pn) < RAYEPS) /* Ray is parallel. */
return (0);
hit->b3 = e1[0] * (q2 - (*v1)[1]) - e1[1] * (q1 - (*v1)[0]);
if (!INSIDE(hit->b3, pt->norm[2]))
return (0);
break;
}
return (1);
}