forked from bartvdbraak/blender
a12a8a71bb
The goal is to solve confusion of the "All rights reserved" for licensing code under an open-source license. The phrase "All rights reserved" comes from a historical convention that required this phrase for the copyright protection to apply. This convention is no longer relevant. However, even though the phrase has no meaning in establishing the copyright it has not lost meaning in terms of licensing. This change makes it so code under the Blender Foundation copyright does not use "all rights reserved". This is also how the GPL license itself states how to apply it to the source code: <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software ... This change does not change copyright notice in cases when the copyright is dual (BF and an author), or just an author of the code. It also does mot change copyright which is inherited from NaN Holding BV as it needs some further investigation about what is the proper way to handle it.
104 lines
3.1 KiB
C++
104 lines
3.1 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2020 Blender Foundation */
|
|
|
|
/** \file
|
|
* \ingroup intern_rigidbody
|
|
*/
|
|
|
|
#include "LinearMath/btConvexHullComputer.h"
|
|
#include "RBI_hull_api.h"
|
|
|
|
plConvexHull plConvexHullCompute(float (*coords)[3], int count)
|
|
{
|
|
btConvexHullComputer *computer = new btConvexHullComputer;
|
|
computer->compute(reinterpret_cast<float *>(coords), sizeof(*coords), count, 0, 0);
|
|
return reinterpret_cast<plConvexHull>(computer);
|
|
}
|
|
|
|
void plConvexHullDelete(plConvexHull hull)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
delete computer;
|
|
}
|
|
|
|
int plConvexHullNumVertices(plConvexHull hull)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
return computer->vertices.size();
|
|
}
|
|
|
|
int plConvexHullNumLoops(plConvexHull hull)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
return computer->edges.size();
|
|
}
|
|
|
|
int plConvexHullNumFaces(plConvexHull hull)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
return computer->faces.size();
|
|
}
|
|
|
|
void plConvexHullGetVertex(plConvexHull hull, int n, float coords[3], int *original_index)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
const btVector3 &v(computer->vertices[n]);
|
|
coords[0] = v[0];
|
|
coords[1] = v[1];
|
|
coords[2] = v[2];
|
|
(*original_index) = computer->original_vertex_index[n];
|
|
}
|
|
|
|
void plConvexHullGetLoop(plConvexHull hull, int n, int *v_from, int *v_to)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
(*v_from) = computer->edges[n].getSourceVertex();
|
|
(*v_to) = computer->edges[n].getTargetVertex();
|
|
}
|
|
|
|
int plConvexHullGetReversedLoopIndex(plConvexHull hull, int n)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
return computer->edges[n].getReverseEdge() - &computer->edges[0];
|
|
}
|
|
|
|
int plConvexHullGetFaceSize(plConvexHull hull, int n)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
const btConvexHullComputer::Edge *e_orig, *e;
|
|
int count;
|
|
|
|
for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0;
|
|
count == 0 || e != e_orig;
|
|
e = e->getNextEdgeOfFace(), count++) {
|
|
;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
void plConvexHullGetFaceLoops(plConvexHull hull, int n, int *loops)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
const btConvexHullComputer::Edge *e_orig, *e;
|
|
int count;
|
|
|
|
for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0;
|
|
count == 0 || e != e_orig;
|
|
e = e->getNextEdgeOfFace(), count++) {
|
|
loops[count] = e - &computer->edges[0];
|
|
}
|
|
}
|
|
|
|
void plConvexHullGetFaceVertices(plConvexHull hull, int n, int *vertices)
|
|
{
|
|
btConvexHullComputer *computer(reinterpret_cast<btConvexHullComputer *>(hull));
|
|
const btConvexHullComputer::Edge *e_orig, *e;
|
|
int count;
|
|
|
|
for (e_orig = &computer->edges[computer->faces[n]], e = e_orig, count = 0;
|
|
count == 0 || e != e_orig;
|
|
e = e->getNextEdgeOfFace(), count++) {
|
|
vertices[count] = e->getTargetVertex();
|
|
}
|
|
}
|