KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following function (from the opensource project "recast navigation" ): /// Derives the dot product of two vectors on the xz-plane. (@p u . @p v) /// @param[in] u A vector [(x, y, z)] /// @param[in] v A vector [(x, y, z)] /// @return The dot product on the xz-plane. /// /// The vectors are projected onto the xz-plane, so the y-values are ignored. inline float dtVdot2D(const float* u, const float* v) { return u[0]*v[0] + u[2]*v[2]; } I ran it through the VS2010 CPU performance test and it showed me that in all recast codebase codeline in this function u[0]*v[0] + u[2]*v[2] is most CPU hot . How can I CPU optimize (via SSE or GLSL like GLM (if it is easier or faster and appropriate in such case) for example) this line? Edit: The context in which the calls appear: bool dtClosestHeightPointTriangle(const float* p, const float* a, const float* b, const float* c, float& h) { float v0[3], v1[3], v2[3]; dtVsub(v0, c,a); dtVsub(v1, b,a); dtVsub(v2, p,a); const float dot00 = dtVdot2D(v0, v0); const float dot01 = dtVdot2D(v0, v1); const float dot02 = dtVdot2D(v0, v2); const float dot11 = dtVdot2D(v1, v1); const float dot12 = dtVdot2D(v1, v2); // Compute barycentric coordinates const float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01); const float u = (dot11 * dot02 - dot01 * dot12) * invDenom; const float v = (dot00 * dot12 - dot01 * dot02) * invDenom;
Tags (comma-separated)
Save Edits
Cancel