Back to Mame

0.9.8: type_vec3.hpp Source File

3rdparty/glm/doc/api/a00130_source.html

latest17.6 KB
Original Source

| | 0.9.8 |

type_vec3.hpp

Go to the documentation of this file.

1

4 #pragma once

5

6 #include "type_vec.hpp"

7 #if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED

8 # if GLM_HAS_UNRESTRICTED_UNIONS

9 # include "_swizzle.hpp"

10 # else

11 # include "_swizzle_func.hpp"

12 # endif

13 #endif //GLM_SWIZZLE == GLM_SWIZZLE_ENABLED

14 #include <cstddef>

15

16 namespace glm

17 {

18template <typename T, precision P = defaultp>

19struct tvec3

20 {

21// -- Implementation detail --

22

23typedef T value_type;

24typedef tvec3<T, P> type;

25typedef tvec3<bool, P> bool_type;

26

27// -- Data --

28

29 # if GLM_HAS_ALIGNED_TYPE

30 # if GLM_COMPILER & GLM_COMPILER_GCC

31 # pragma GCC diagnostic push

32 # pragma GCC diagnostic ignored "-pedantic"

33 # endif

34 # if GLM_COMPILER & GLM_COMPILER_CLANG

35 # pragma clang diagnostic push

36 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"

37 # pragma clang diagnostic ignored "-Wnested-anon-types"

38 # endif

39

40union

41 {

42struct{ T x, y, z; };

43struct{ T r, g, b; };

44struct{ T s, t, p; };

45

46 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED

47 _GLM_SWIZZLE3_2_MEMBERS(T, P, glm::tvec2, x, y, z)

48 _GLM_SWIZZLE3_2_MEMBERS(T, P, glm::tvec2, r, g, b)

49 _GLM_SWIZZLE3_2_MEMBERS(T, P, glm::tvec2, s, t, p)

50 _GLM_SWIZZLE3_3_MEMBERS(T, P, glm::tvec3, x, y, z)

51 _GLM_SWIZZLE3_3_MEMBERS(T, P, glm::tvec3, r, g, b)

52 _GLM_SWIZZLE3_3_MEMBERS(T, P, glm::tvec3, s, t, p)

53 _GLM_SWIZZLE3_4_MEMBERS(T, P, glm::tvec4, x, y, z)

54 _GLM_SWIZZLE3_4_MEMBERS(T, P, glm::tvec4, r, g, b)

55 _GLM_SWIZZLE3_4_MEMBERS(T, P, glm::tvec4, s, t, p)

56 # endif//GLM_SWIZZLE

57 };

58

59 # if GLM_COMPILER & GLM_COMPILER_CLANG

60 # pragma clang diagnostic pop

61 # endif

62 # if GLM_COMPILER & GLM_COMPILER_GCC

63 # pragma GCC diagnostic pop

64 # endif

65 # else

66union { T x, r, s; };

67union { T y, g, t; };

68union { T z, b, p; };

69

70 # if GLM_SWIZZLE == GLM_SWIZZLE_ENABLED

71 GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P, tvec3, tvec2, tvec3, tvec4)

72 # endif//GLM_SWIZZLE

73 # endif//GLM_LANG

74

75// -- Component accesses --

76

78typedef length_t length_type;

79 GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;

80

81 GLM_FUNC_DECL T & operator[](length_type i);

82 GLM_FUNC_DECL T const & operator[](length_type i) const;

83

84// -- Implicit basic constructors --

85

86 GLM_FUNC_DECL GLM_CONSTEXPR tvec3() GLM_DEFAULT_CTOR;

87 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec3<T, P> const & v) GLM_DEFAULT;

88 template <precision Q>

89 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec3<T, Q> const & v);

90

91// -- Explicit basic constructors --

92

93 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit tvec3(ctor);

94 GLM_FUNC_DECL GLM_CONSTEXPR explicit tvec3(T scalar);

95 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(T a, T b, T c);

96

97// -- Conversion scalar constructors --

98

100 template <typename A, typename B, typename C>

101 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(A a, B b, C c);

102 template <typename A, typename B, typename C>

103 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c);

104

105// -- Conversion vector constructors --

106

108 template <typename A, typename B, precision Q>

109 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec2<A, Q> const & a, B b);

111 template <typename A, typename B, precision Q>

112 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec2<A, Q> const & a, tvec1<B, Q> const & b);

114 template <typename A, typename B, precision Q>

115 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(A a, tvec2<B, Q> const & b);

117 template <typename A, typename B, precision Q>

118 GLM_FUNC_DECL GLM_CONSTEXPR tvec3(tvec1<A, Q> const & a, tvec2<B, Q> const & b);

120 template <typename U, precision Q>

121 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec3(tvec4<U, Q> const & v);

122

124 template <typename U, precision Q>

125 GLM_FUNC_DECL GLM_CONSTEXPR GLM_EXPLICIT tvec3(tvec3<U, Q> const & v);

126

127// -- Swizzle constructors --

128 # if GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)

129template <int E0, int E1, int E2>

130 GLM_FUNC_DECL tvec3(detail::_swizzle<3, T, P, glm::tvec3, E0, E1, E2, -1> const & that)

131 {

132 *this = that();

133 }

134

135template <int E0, int E1>

136 GLM_FUNC_DECL tvec3(detail::_swizzle<2, T, P, glm::tvec2, E0, E1, -1, -2> const & v, T const & scalar)

137 {

138 *this = tvec3<T, P>(v(), scalar);

139 }

140

141template <int E0, int E1>

142 GLM_FUNC_DECL tvec3(T const & scalar, detail::_swizzle<2, T, P, glm::tvec2, E0, E1, -1, -2> const & v)

143 {

144 *this = tvec3<T, P>(scalar, v());

145 }

146 # endif// GLM_HAS_UNRESTRICTED_UNIONS && (GLM_SWIZZLE == GLM_SWIZZLE_ENABLED)

147

148// -- Unary arithmetic operators --

149

150 GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<T, P> const & v) GLM_DEFAULT;

151

152template <typename U>

153 GLM_FUNC_DECL tvec3<T, P> & operator=(tvec3<U, P> const & v);

154template <typename U>

155 GLM_FUNC_DECL tvec3<T, P> & operator+=(U scalar);

156template <typename U>

157 GLM_FUNC_DECL tvec3<T, P> & operator+=(tvec1<U, P> const & v);

158template <typename U>

159 GLM_FUNC_DECL tvec3<T, P> & operator+=(tvec3<U, P> const & v);

160template <typename U>

161 GLM_FUNC_DECL tvec3<T, P> & operator-=(U scalar);

162template <typename U>

163 GLM_FUNC_DECL tvec3<T, P> & operator-=(tvec1<U, P> const & v);

164template <typename U>

165 GLM_FUNC_DECL tvec3<T, P> & operator-=(tvec3<U, P> const & v);

166template <typename U>

167 GLM_FUNC_DECL tvec3<T, P> & operator*=(U scalar);

168template <typename U>

169 GLM_FUNC_DECL tvec3<T, P> & operator*=(tvec1<U, P> const & v);

170template <typename U>

171 GLM_FUNC_DECL tvec3<T, P> & operator*=(tvec3<U, P> const & v);

172template <typename U>

173 GLM_FUNC_DECL tvec3<T, P> & operator/=(U scalar);

174template <typename U>

175 GLM_FUNC_DECL tvec3<T, P> & operator/=(tvec1<U, P> const & v);

176template <typename U>

177 GLM_FUNC_DECL tvec3<T, P> & operator/=(tvec3<U, P> const & v);

178

179// -- Increment and decrement operators --

180

181 GLM_FUNC_DECL tvec3<T, P> & operator++();

182 GLM_FUNC_DECL tvec3<T, P> & operator--();

183 GLM_FUNC_DECL tvec3<T, P> operator++(int);

184 GLM_FUNC_DECL tvec3<T, P> operator--(int);

185

186// -- Unary bit operators --

187

188template <typename U>

189 GLM_FUNC_DECL tvec3<T, P> & operator%=(U scalar);

190template <typename U>

191 GLM_FUNC_DECL tvec3<T, P> & operator%=(tvec1<U, P> const & v);

192template <typename U>

193 GLM_FUNC_DECL tvec3<T, P> & operator%=(tvec3<U, P> const & v);

194template <typename U>

195 GLM_FUNC_DECL tvec3<T, P> & operator&=(U scalar);

196template <typename U>

197 GLM_FUNC_DECL tvec3<T, P> & operator&=(tvec1<U, P> const & v);

198template <typename U>

199 GLM_FUNC_DECL tvec3<T, P> & operator&=(tvec3<U, P> const & v);

200template <typename U>

201 GLM_FUNC_DECL tvec3<T, P> & operator|=(U scalar);

202template <typename U>

203 GLM_FUNC_DECL tvec3<T, P> & operator|=(tvec1<U, P> const & v);

204template <typename U>

205 GLM_FUNC_DECL tvec3<T, P> & operator|=(tvec3<U, P> const & v);

206template <typename U>

207 GLM_FUNC_DECL tvec3<T, P> & operator^=(U scalar);

208template <typename U>

209 GLM_FUNC_DECL tvec3<T, P> & operator^=(tvec1<U, P> const & v);

210template <typename U>

211 GLM_FUNC_DECL tvec3<T, P> & operator^=(tvec3<U, P> const & v);

212template <typename U>

213 GLM_FUNC_DECL tvec3<T, P> & operator<<=(U scalar);

214template <typename U>

215 GLM_FUNC_DECL tvec3<T, P> & operator<<=(tvec1<U, P> const & v);

216template <typename U>

217 GLM_FUNC_DECL tvec3<T, P> & operator<<=(tvec3<U, P> const & v);

218template <typename U>

219 GLM_FUNC_DECL tvec3<T, P> & operator>>=(U scalar);

220template <typename U>

221 GLM_FUNC_DECL tvec3<T, P> & operator>>=(tvec1<U, P> const & v);

222template <typename U>

223 GLM_FUNC_DECL tvec3<T, P> & operator>>=(tvec3<U, P> const & v);

224 };

225

226// -- Unary operators --

227

228template <typename T, precision P>

229 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v);

230

231template <typename T, precision P>

232 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);

233

234// -- Binary operators --

235

236template <typename T, precision P>

237 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, T scalar);

238

239template <typename T, precision P>

240 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, tvec1<T, P> const & scalar);

241

242template <typename T, precision P>

243 GLM_FUNC_DECL tvec3<T, P> operator+(T scalar, tvec3<T, P> const & v);

244

245template <typename T, precision P>

246 GLM_FUNC_DECL tvec3<T, P> operator+(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

247

248template <typename T, precision P>

249 GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

250

251template <typename T, precision P>

252 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v, T scalar);

253

254template <typename T, precision P>

255 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

256

257template <typename T, precision P>

258 GLM_FUNC_DECL tvec3<T, P> operator-(T scalar, tvec3<T, P> const & v);

259

260template <typename T, precision P>

261 GLM_FUNC_DECL tvec3<T, P> operator-(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

262

263template <typename T, precision P>

264 GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

265

266template <typename T, precision P>

267 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v, T scalar);

268

269template <typename T, precision P>

270 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

271

272template <typename T, precision P>

273 GLM_FUNC_DECL tvec3<T, P> operator*(T scalar, tvec3<T, P> const & v);

274

275template <typename T, precision P>

276 GLM_FUNC_DECL tvec3<T, P> operator*(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

277

278template <typename T, precision P>

279 GLM_FUNC_DECL tvec3<T, P> operator*(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

280

281template <typename T, precision P>

282 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v, T scalar);

283

284template <typename T, precision P>

285 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

286

287template <typename T, precision P>

288 GLM_FUNC_DECL tvec3<T, P> operator/(T scalar, tvec3<T, P> const & v);

289

290template <typename T, precision P>

291 GLM_FUNC_DECL tvec3<T, P> operator/(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

292

293template <typename T, precision P>

294 GLM_FUNC_DECL tvec3<T, P> operator/(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

295

296template <typename T, precision P>

297 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v, T scalar);

298

299template <typename T, precision P>

300 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

301

302template <typename T, precision P>

303 GLM_FUNC_DECL tvec3<T, P> operator%(T const & scalar, tvec3<T, P> const & v);

304

305template <typename T, precision P>

306 GLM_FUNC_DECL tvec3<T, P> operator%(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

307

308template <typename T, precision P>

309 GLM_FUNC_DECL tvec3<T, P> operator%(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

310

311template <typename T, precision P>

312 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v1, T scalar);

313

314template <typename T, precision P>

315 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

316

317template <typename T, precision P>

318 GLM_FUNC_DECL tvec3<T, P> operator&(T scalar, tvec3<T, P> const & v);

319

320template <typename T, precision P>

321 GLM_FUNC_DECL tvec3<T, P> operator&(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

322

323template <typename T, precision P>

324 GLM_FUNC_DECL tvec3<T, P> operator&(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

325

326template <typename T, precision P>

327 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v, T scalar);

328

329template <typename T, precision P>

330 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

331

332template <typename T, precision P>

333 GLM_FUNC_DECL tvec3<T, P> operator|(T scalar, tvec3<T, P> const & v);

334

335template <typename T, precision P>

336 GLM_FUNC_DECL tvec3<T, P> operator|(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

337

338template <typename T, precision P>

339 GLM_FUNC_DECL tvec3<T, P> operator|(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

340

341template <typename T, precision P>

342 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v, T scalar);

343

344template <typename T, precision P>

345 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

346

347template <typename T, precision P>

348 GLM_FUNC_DECL tvec3<T, P> operator^(T scalar, tvec3<T, P> const & v);

349

350template <typename T, precision P>

351 GLM_FUNC_DECL tvec3<T, P> operator^(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

352

353template <typename T, precision P>

354 GLM_FUNC_DECL tvec3<T, P> operator^(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

355

356template <typename T, precision P>

357 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v, T scalar);

358

359template <typename T, precision P>

360 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

361

362template <typename T, precision P>

363 GLM_FUNC_DECL tvec3<T, P> operator<<(T scalar, tvec3<T, P> const & v);

364

365template <typename T, precision P>

366 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

367

368template <typename T, precision P>

369 GLM_FUNC_DECL tvec3<T, P> operator<<(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

370

371template <typename T, precision P>

372 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v, T scalar);

373

374template <typename T, precision P>

375 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v1, tvec1<T, P> const & v2);

376

377template <typename T, precision P>

378 GLM_FUNC_DECL tvec3<T, P> operator>>(T scalar, tvec3<T, P> const & v);

379

380template <typename T, precision P>

381 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec1<T, P> const & v1, tvec3<T, P> const & v2);

382

383template <typename T, precision P>

384 GLM_FUNC_DECL tvec3<T, P> operator>>(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

385

386template <typename T, precision P>

387 GLM_FUNC_DECL tvec3<T, P> operator~(tvec3<T, P> const & v);

388

389// -- Boolean operators --

390

391template <typename T, precision P>

392 GLM_FUNC_DECL bool operator==(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

393

394template <typename T, precision P>

395 GLM_FUNC_DECL bool operator!=(tvec3<T, P> const & v1, tvec3<T, P> const & v2);

396

397template <precision P>

398 GLM_FUNC_DECL tvec3<bool, P> operator&&(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2);

399

400template <precision P>

401 GLM_FUNC_DECL tvec3<bool, P> operator||(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2);

402 }//namespace glm

403

404 #ifndef GLM_EXTERNAL_TEMPLATE

405 #include "type_vec3.inl"

406 #endif//GLM_EXTERNAL_TEMPLATE

type_vec.hpp

GLM Core

glm

Definition: _noise.hpp:11

_swizzle_func.hpp

GLM Core

glm::length

GLM_FUNC_DECL T length(vecType< T, P > const &x)

Returns the length of x, i.e., sqrt(x * x).

_swizzle.hpp

GLM Core


Generated by 1.8.10