MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / compute

Method compute

src/Bullet3Geometry/b3ConvexHullComputer.cpp:1943–2062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1941}
1942
1943void b3ConvexHullInternal::compute(const void* coords, bool doubleCoords, int stride, int count)
1944{
1945 b3Vector3 min = b3MakeVector3(b3Scalar(1e30), b3Scalar(1e30), b3Scalar(1e30)), max = b3MakeVector3(b3Scalar(-1e30), b3Scalar(-1e30), b3Scalar(-1e30));
1946 const char* ptr = (const char*)coords;
1947 if (doubleCoords)
1948 {
1949 for (int i = 0; i < count; i++)
1950 {
1951 const double* v = (const double*)ptr;
1952 b3Vector3 p = b3MakeVector3((b3Scalar)v[0], (b3Scalar)v[1], (b3Scalar)v[2]);
1953 ptr += stride;
1954 min.setMin(p);
1955 max.setMax(p);
1956 }
1957 }
1958 else
1959 {
1960 for (int i = 0; i < count; i++)
1961 {
1962 const float* v = (const float*)ptr;
1963 b3Vector3 p = b3MakeVector3(v[0], v[1], v[2]);
1964 ptr += stride;
1965 min.setMin(p);
1966 max.setMax(p);
1967 }
1968 }
1969
1970 b3Vector3 s = max - min;
1971 maxAxis = s.maxAxis();
1972 minAxis = s.minAxis();
1973 if (minAxis == maxAxis)
1974 {
1975 minAxis = (maxAxis + 1) % 3;
1976 }
1977 medAxis = 3 - maxAxis - minAxis;
1978
1979 s /= b3Scalar(10216);
1980 if (((medAxis + 1) % 3) != maxAxis)
1981 {
1982 s *= -1;
1983 }
1984 scaling = s;
1985
1986 if (s[0] != 0)
1987 {
1988 s[0] = b3Scalar(1) / s[0];
1989 }
1990 if (s[1] != 0)
1991 {
1992 s[1] = b3Scalar(1) / s[1];
1993 }
1994 if (s[2] != 0)
1995 {
1996 s[2] = b3Scalar(1) / s[2];
1997 }
1998
1999 center = (min + max) * b3Scalar(0.5);
2000

Callers 4

optimizeConvexHullMethod · 0.45
DrawMethod · 0.45

Calls 15

b3MakeVector3Function · 0.85
getVertexCopyFunction · 0.70
EdgeClass · 0.70
setMinMethod · 0.45
setMaxMethod · 0.45
resizeMethod · 0.45
quickSortMethod · 0.45
resetMethod · 0.45
setArraySizeMethod · 0.45
newObjectMethod · 0.45
clearMethod · 0.45
shrinkMethod · 0.45

Tested by

no test coverage detected