This file is indexed.

/usr/include/obs/graphics/vec3.h is in libobs-dev 21.0.2+dfsg1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/******************************************************************************
    Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#pragma once

#include "math-defs.h"
#include "vec4.h"
#include <xmmintrin.h>

#ifdef __cplusplus
extern "C" {
#endif

struct plane;
struct matrix3;
struct matrix4;
struct quat;

struct vec3 {
	union {
		struct {
			float x, y, z, w;
		};
		float ptr[4];
		__m128 m;
	};
};

static inline void vec3_zero(struct vec3 *v)
{
	v->m = _mm_setzero_ps();
}

static inline void vec3_set(struct vec3 *dst, float x, float y, float z)
{
	dst->m = _mm_set_ps(0.0f, z, y, x);
}

static inline void vec3_copy(struct vec3 *dst, const struct vec3 *v)
{
	dst->m = v->m;
}

EXPORT void vec3_from_vec4(struct vec3 *dst, const struct vec4 *v);

static inline void vec3_add(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	dst->m = _mm_add_ps(v1->m, v2->m);
	dst->w = 0.0f;
}

static inline void vec3_sub(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	dst->m = _mm_sub_ps(v1->m, v2->m);
	dst->w = 0.0f;
}

static inline void vec3_mul(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	dst->m = _mm_mul_ps(v1->m, v2->m);
}

static inline void vec3_div(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	dst->m = _mm_div_ps(v1->m, v2->m);
	dst->w = 0.0f;
}

static inline void vec3_addf(struct vec3 *dst, const struct vec3 *v,
		float f)
{
	dst->m = _mm_add_ps(v->m, _mm_set1_ps(f));
	dst->w = 0.0f;
}

static inline void vec3_subf(struct vec3 *dst, const struct vec3 *v,
		float f)
{
	dst->m = _mm_sub_ps(v->m, _mm_set1_ps(f));
	dst->w = 0.0f;
}

static inline void vec3_mulf(struct vec3 *dst, const struct vec3 *v,
		float f)
{
	dst->m = _mm_mul_ps(v->m, _mm_set1_ps(f));
}

static inline void vec3_divf(struct vec3 *dst, const struct vec3 *v,
		float f)
{
	dst->m = _mm_div_ps(v->m, _mm_set1_ps(f));
	dst->w = 0.0f;
}

static inline float vec3_dot(const struct vec3 *v1, const struct vec3 *v2)
{
	struct vec3 add;
	__m128 mul = _mm_mul_ps(v1->m, v2->m);
	add.m = _mm_add_ps(_mm_movehl_ps(mul, mul), mul);
	add.m = _mm_add_ps(_mm_shuffle_ps(add.m, add.m, 0x55), add.m);
	return add.x;
}

static inline void vec3_cross(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	__m128 s1v1 = _mm_shuffle_ps(v1->m, v1->m, _MM_SHUFFLE(3, 0, 2, 1));
	__m128 s1v2 = _mm_shuffle_ps(v2->m, v2->m, _MM_SHUFFLE(3, 1, 0, 2));
	__m128 s2v1 = _mm_shuffle_ps(v1->m, v1->m, _MM_SHUFFLE(3, 1, 0, 2));
	__m128 s2v2 = _mm_shuffle_ps(v2->m, v2->m, _MM_SHUFFLE(3, 0, 2, 1));
	dst->m = _mm_sub_ps(_mm_mul_ps(s1v1, s1v2), _mm_mul_ps(s2v1, s2v2));
}

static inline void vec3_neg(struct vec3 *dst, const struct vec3 *v)
{
	dst->x = -v->x;
	dst->y = -v->y;
	dst->z = -v->z;
	dst->w = 0.0f;
}

static inline float vec3_len(const struct vec3 *v)
{
	float dot_val = vec3_dot(v, v);
	return (dot_val > 0.0f) ? sqrtf(dot_val) : 0.0f;
}

static inline float vec3_dist(const struct vec3 *v1, const struct vec3 *v2)
{
	struct vec3 temp;
	float dot_val;

	vec3_sub(&temp, v1, v2);
	dot_val = vec3_dot(&temp, &temp);
	return (dot_val > 0.0f) ? sqrtf(dot_val) : 0.0f;
}

static inline void vec3_norm(struct vec3 *dst, const struct vec3 *v)
{
	float dot_val = vec3_dot(v, v);
	dst->m = (dot_val > 0.0f) ?
		_mm_mul_ps(v->m, _mm_set1_ps(1.0f/sqrtf(dot_val))) :
		_mm_setzero_ps();
}

static inline bool vec3_close(const struct vec3 *v1, const struct vec3 *v2,
		float epsilon)
{
	struct vec3 test;
	vec3_sub(&test, v1, v2);
	return test.x < epsilon && test.y < epsilon && test.z < epsilon;
}

static inline void vec3_min(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	dst->m = _mm_min_ps(v1->m, v2->m);
	dst->w = 0.0f;
}

static inline void vec3_minf(struct vec3 *dst, const struct vec3 *v,
		float f)
{
	dst->m = _mm_min_ps(v->m, _mm_set1_ps(f));
	dst->w = 0.0f;
}

static inline void vec3_max(struct vec3 *dst, const struct vec3 *v1,
		const struct vec3 *v2)
{
	dst->m = _mm_max_ps(v1->m, v2->m);
	dst->w = 0.0f;
}

static inline void vec3_maxf(struct vec3 *dst, const struct vec3 *v,
		float f)
{
	dst->m = _mm_max_ps(v->m, _mm_set1_ps(f));
	dst->w = 0.0f;
}

static inline void vec3_abs(struct vec3 *dst, const struct vec3 *v)
{
	dst->x = fabsf(v->x);
	dst->y = fabsf(v->y);
	dst->z = fabsf(v->z);
	dst->w = 0.0f;
}

static inline void vec3_floor(struct vec3 *dst, const struct vec3 *v)
{
	dst->x = floorf(v->x);
	dst->y = floorf(v->y);
	dst->z = floorf(v->z);
	dst->w = 0.0f;
}

static inline void vec3_ceil(struct vec3 *dst, const struct vec3 *v)
{
	dst->x = ceilf(v->x);
	dst->y = ceilf(v->y);
	dst->z = ceilf(v->z);
	dst->w = 0.0f;
}

EXPORT float vec3_plane_dist(const struct vec3 *v, const struct plane *p);

EXPORT void vec3_transform(struct vec3 *dst, const struct vec3 *v,
		const struct matrix4 *m);

EXPORT void vec3_rotate(struct vec3 *dst, const struct vec3 *v,
		const struct matrix3 *m);
EXPORT void vec3_transform3x4(struct vec3 *dst, const struct vec3 *v,
		const struct matrix3 *m);

EXPORT void vec3_mirror(struct vec3 *dst, const struct vec3 *v,
		const struct plane *p);
EXPORT void vec3_mirrorv(struct vec3 *dst, const struct vec3 *v,
		const struct vec3 *vec);

EXPORT void vec3_rand(struct vec3 *dst, int positive_only);

#ifdef __cplusplus
}
#endif