<html><head></head><body>Are you sure that you should do intermediate computations in double precision? That does not seem useful here.<br><br><div class="gmail_quote">Le 7 février 2019 13:12:16 GMT+02:00, Alexandre Janniaux <ajanni@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Refactor code from opengl/vout_helper and d3d11, by merging the creation of<br>three 4x4 rotation matrices for the shaders into only one created from the<br>viewpoint.<hr> include/vlc_viewpoint.h | 48 +++++++++++++++++++++++++++++++++++++++++<br> 1 file changed, 48 insertions(+)<br><br>diff --git a/include/vlc_viewpoint.h b/include/vlc_viewpoint.h<br>index df930b3900..0b8404513c 100644<br>--- a/include/vlc_viewpoint.h<br>+++ b/include/vlc_viewpoint.h<br>@@ -66,4 +66,52 @@ static inline void vlc_viewpoint_reverse( vlc_viewpoint_t *p_vp )<br> p_vp->roll *= -1;<br> }<br> <br>+static inline void vlc_viewpoint_to_4x4( const vlc_viewpoint_t *p_vp,<br>+ float *m )<br>+{<br>+ float s, c;<br>+<br>+ vlc_viewpoint_t vp = *p_vp;<br>+ vp.yaw *= M_PI; vp.pitch *= M_PI; vp.roll *= M_PI;<br>+ vp.yaw /= 180.f; vp.pitch /= 180.f; vp.roll /= 180.f;<br>+ vp.yaw += M_PI_2;<br>+<br>+ s = sinf(vp.pitch);<br>+ c = cosf(vp.pitch);<br>+ float x_rot[4][4] = {<br>+ { 1.f, 0.f, 0.f, 0.f },<br>+ { 0.f, c, -s, 0.f },<br>+ { 0.f, s, c, 0.f },<br>+ { 0.f, 0.f, 0.f, 1.f } };<br>+<br>+ s = sinf(vp.yaw);<br>+ c = cosf(vp.yaw);<br>+ float y_rot[4][4] = {<br>+ { c, 0.f, s, 0.f },<br>+ { 0.f, 1.f, 0.f, 0.f },<br>+ { -s, 0.f, c, 0.f },<br>+ { 0.f, 0.f, 0.f, 1.f } };<br>+<br>+ s = sinf(vp.roll);<br>+ c = cosf(vp.roll);<br>+ float z_rot[4][4] = {<br>+ { c, s, 0.f, 0.f },<br>+ { -s, c, 0.f, 0.f },<br>+ { 0.f, 0.f, 1.f, 0.f },<br>+ { 0.f, 0.f, 0.f, 1.f } };<br>+<br>+ /**<br>+ * Column-major matrix multiplication mathematically equal to<br>+ * z_rot * x_rot * y_rot<br>+ */<br>+ memset(m, 0, 16 * sizeof(float));<br>+ for (int i=0; i<4; ++i)<br>+ for (int j=0; j<4; ++j)<br>+ for (int k=0; k<4; ++k)<br>+ for (int l=0; l<4; ++l)<br>+ {<br>+ m[4*i+l] += y_rot[i][j] * x_rot[j][k] * z_rot[k][l];<br>+ }<br>+}<br>+<br> #endif /* VLC_VIEWPOINT_H_ */</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>