Subversion Repository Public Repository

Divide-Dependencies

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
// ================================================================================================
// -*- C++ -*-
// File: vectormath.h
// Author: Guilherme R. Lampert
// Created on: 15/11/15
// Brief: This header exposes the Sony Vector Math library types into the global scope.
// ================================================================================================

#ifndef VECTORMATH_H_
#define VECTORMATH_H_

// We're using the generic Array of Structures (AoS) format.
#include "cpp/vectormath_aos.h"
using namespace Vectormath::Aos;

inline float * toFloatPtr(Point3  & p) { return reinterpret_cast<float *>(&p); }
inline float * toFloatPtr(Vector3 & v) { return reinterpret_cast<float *>(&v); }
inline float * toFloatPtr(Vector4 & v) { return reinterpret_cast<float *>(&v); }
inline float * toFloatPtr(Quat    & q) { return reinterpret_cast<float *>(&q); }
inline float * toFloatPtr(Matrix3 & m) { return reinterpret_cast<float *>(&m); }
inline float * toFloatPtr(Matrix4 & m) { return reinterpret_cast<float *>(&m); }

inline const float * toFloatPtr(const Point3  & p) { return reinterpret_cast<const float *>(&p); }
inline const float * toFloatPtr(const Vector3 & v) { return reinterpret_cast<const float *>(&v); }
inline const float * toFloatPtr(const Vector4 & v) { return reinterpret_cast<const float *>(&v); }
inline const float * toFloatPtr(const Quat    & q) { return reinterpret_cast<const float *>(&q); }
inline const float * toFloatPtr(const Matrix3 & m) { return reinterpret_cast<const float *>(&m); }
inline const float * toFloatPtr(const Matrix4 & m) { return reinterpret_cast<const float *>(&m); }

// Shorthand to discard the last element of a Vector4 and get a Point3.
inline Point3 toPoint3(const Vector4 & v4)
{
    return Point3(v4[0], v4[1], v4[2]);
}

// Convert from world (global) coordinates to local model coordinates.
// Input matrix must be the inverse of the model matrix, e.g.: 'inverse(modelMatrix)'.
inline Point3 worldPointToModel(const Matrix4 & invModelToWorldMatrix, const Point3 & point)
{
    return toPoint3(invModelToWorldMatrix * point);
}

#endif // VECTORMATH_H_

Commits for Divide-Dependencies/debug-draw/samples/vectormath/vectormath.h

Diff revisions: vs.
Revision Author Commited Message
70 IonutCava picture IonutCava Wed 26 Jul, 2017 20:21:42 +0000

[Ionut]
- Added Hodgman’s variant of the debug-draw library. ref: https://github.com/hodgman/debug-draw