28 json_t* m_candidate = json_object_get(candidate,
"metadata");
29 json_t* m_result = json_object_get(result,
"metadata");
31 if (m_candidate && m_result)
33 json_object_foreach_safe( m_candidate, temp, c_key, c_value )
35 bool found_array =
false;
36 json_object_foreach_safe( m_result, temp2, r_key, r_value )
38 if (strcmp(r_key,c_key) == 0)
40 if (json_is_array(r_value) && json_is_array(c_value))
42 json_array_extend(r_value,c_value);
49 json_object_set( m_result, c_key, c_value );
53 json_object_foreach_safe( candidate, temp, c_key, c_value )
55 bool found_meta =
false;
56 json_object_foreach_safe( result, temp2, r_key, r_value )
58 if (strcmp(r_key,c_key) == 0 && strcmp(r_key,
"metadata") == 0)
65 json_object_set( result, c_key, c_value );
68 void mulMatrixMatrix(IceTDouble* result,
const IceTDouble* matrix1,
const IceTDouble* matrix2)
72 result[y+x*4] = matrix1[y+0*4] * matrix2[0+x*4]
73 + matrix1[y+1*4] * matrix2[1+x*4]
74 + matrix1[y+2*4] * matrix2[2+x*4]
75 + matrix1[y+3*4] * matrix2[3+x*4];
77 void mulMatrixVector(IceTDouble* result,
const IceTDouble* matrix,
const IceTDouble* vector)
79 result[0] = matrix[ 0] * vector[0] + matrix[ 4] * vector[1] + matrix[ 8] * vector[2] + matrix[12] * vector[3];
80 result[1] = matrix[ 1] * vector[0] + matrix[ 5] * vector[1] + matrix[ 9] * vector[2] + matrix[13] * vector[3];
81 result[2] = matrix[ 2] * vector[0] + matrix[ 6] * vector[1] + matrix[10] * vector[2] + matrix[14] * vector[3];
82 result[3] = matrix[ 3] * vector[0] + matrix[ 7] * vector[1] + matrix[11] * vector[2] + matrix[15] * vector[3];
85 void calcInverse(IceTDouble* inv,
const IceTDouble* projection,
const IceTDouble* modelview)
89 inv[0] = m[5] * m[10] * m[15] -
90 m[5] * m[11] * m[14] -
93 m[13] * m[6] * m[11] -
96 inv[4] = -m[4] * m[10] * m[15] +
97 m[4] * m[11] * m[14] +
100 m[12] * m[6] * m[11] +
101 m[12] * m[7] * m[10];
103 inv[8] = m[4] * m[9] * m[15] -
104 m[4] * m[11] * m[13] -
105 m[8] * m[5] * m[15] +
106 m[8] * m[7] * m[13] +
107 m[12] * m[5] * m[11] -
110 inv[12] = -m[4] * m[9] * m[14] +
111 m[4] * m[10] * m[13] +
112 m[8] * m[5] * m[14] -
113 m[8] * m[6] * m[13] -
114 m[12] * m[5] * m[10] +
117 inv[1] = -m[1] * m[10] * m[15] +
118 m[1] * m[11] * m[14] +
119 m[9] * m[2] * m[15] -
120 m[9] * m[3] * m[14] -
121 m[13] * m[2] * m[11] +
122 m[13] * m[3] * m[10];
124 inv[5] = m[0] * m[10] * m[15] -
125 m[0] * m[11] * m[14] -
126 m[8] * m[2] * m[15] +
127 m[8] * m[3] * m[14] +
128 m[12] * m[2] * m[11] -
129 m[12] * m[3] * m[10];
131 inv[9] = -m[0] * m[9] * m[15] +
132 m[0] * m[11] * m[13] +
133 m[8] * m[1] * m[15] -
134 m[8] * m[3] * m[13] -
135 m[12] * m[1] * m[11] +
138 inv[13] = m[0] * m[9] * m[14] -
139 m[0] * m[10] * m[13] -
140 m[8] * m[1] * m[14] +
141 m[8] * m[2] * m[13] +
142 m[12] * m[1] * m[10] -
145 inv[2] = m[1] * m[6] * m[15] -
146 m[1] * m[7] * m[14] -
147 m[5] * m[2] * m[15] +
148 m[5] * m[3] * m[14] +
149 m[13] * m[2] * m[7] -
152 inv[6] = -m[0] * m[6] * m[15] +
153 m[0] * m[7] * m[14] +
154 m[4] * m[2] * m[15] -
155 m[4] * m[3] * m[14] -
156 m[12] * m[2] * m[7] +
159 inv[10] = m[0] * m[5] * m[15] -
160 m[0] * m[7] * m[13] -
161 m[4] * m[1] * m[15] +
162 m[4] * m[3] * m[13] +
163 m[12] * m[1] * m[7] -
166 inv[14] = -m[0] * m[5] * m[14] +
167 m[0] * m[6] * m[13] +
168 m[4] * m[1] * m[14] -
169 m[4] * m[2] * m[13] -
170 m[12] * m[1] * m[6] +
173 inv[3] = -m[1] * m[6] * m[11] +
174 m[1] * m[7] * m[10] +
175 m[5] * m[2] * m[11] -
176 m[5] * m[3] * m[10] -
180 inv[7] = m[0] * m[6] * m[11] -
181 m[0] * m[7] * m[10] -
182 m[4] * m[2] * m[11] +
183 m[4] * m[3] * m[10] +
187 inv[11] = -m[0] * m[5] * m[11] +
189 m[4] * m[1] * m[11] -
194 inv[15] = m[0] * m[5] * m[10] -
196 m[4] * m[1] * m[10] +
201 IceTDouble det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
209 inv[i] = inv[i] * det;
219 isaac_float4 result = {0,0,0,a};
259 isaac_float width = right - left;
260 isaac_float height = top - bottom;
261 isaac_float zRange = znear - zfar;
262 projection[ 0] = znear2 / width;
267 projection[ 5] = znear2 / height;
270 projection[ 8] = ( right + left ) / width;
271 projection[ 9] = ( top + bottom ) / height;
272 projection[10] = ( zfar + znear) / zRange;
276 projection[14] = ( -znear2 * zfar ) / -zRange;
283 setFrustum(projection, -xmax, xmax, -ymax, ymax, znear, zfar );
293 setFrustum(projection, xmin, xmax, ymin, ymax, znear, zfar );
294 projection[12] += distance;
297 #if ISAAC_VALGRIND_TWEAKS == 1 298 static void *extra_malloc(
size_t size)
301 void *ptr = malloc(size + 4);
305 static void extra_free(
void *ptr)
void calcInverse(IceTDouble *inv, const IceTDouble *projection, const IceTDouble *modelview)
isaac_float4 getHSVA(isaac_float h, isaac_float s, isaac_float v, isaac_float a)
void spSetPerspectiveStereoscopic(IceTDouble *const projection, const isaac_float fovyInDegrees, const isaac_float aspectRatio, const isaac_float znear, const isaac_float zfar, const isaac_float z0, const isaac_float distance)
void setPerspective(IceTDouble *const projection, const isaac_float fovyInDegrees, const isaac_float aspectRatio, const isaac_float znear, const isaac_float zfar)
void setFrustum(IceTDouble *const projection, const isaac_float left, const isaac_float right, const isaac_float bottom, const isaac_float top, const isaac_float znear, const isaac_float zfar)
void mergeJSON(json_t *result, json_t *candidate)
void mulMatrixMatrix(IceTDouble *result, const IceTDouble *matrix1, const IceTDouble *matrix2)
void mulMatrixVector(IceTDouble *result, const IceTDouble *matrix, const IceTDouble *vector)