MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / iSphereBoundVec

Function iSphereBoundVec

src/SB/Core/gc/iMath3.cpp:109–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void iSphereBoundVec(xSphere* o, const xSphere* s, const xVec3* v)
110{
111 F32 scale;
112 xSphere temp;
113 xSphere* tp;
114 U32 usetemp;
115 xIsect isx;
116
117 usetemp = (o == s);
118
119 iSphereIsectVec(s, v, &isx);
120
121 if (isx.penned <= 0.0f)
122 {
123 if (!usetemp)
124 {
125 memcpy(o, s, sizeof(xSphere));
126 }
127 }
128 else
129 {
130 if (usetemp)
131 {
132 tp = &temp;
133 }
134 else
135 {
136 tp = o;
137 }
138
139 xVec3Copy(&tp->center, &isx.norm);
140
141 scale = (isx.dist - s->r) / (2.0f * isx.dist);
142
143 xVec3SMul(&tp->center, &tp->center, scale);
144 xVec3Add(&tp->center, &tp->center, &s->center);
145
146 tp->r = 0.5f * (isx.dist + s->r);
147
148 if (usetemp)
149 {
150 memcpy(o, tp, sizeof(xSphere));
151 }
152 }
153}
154
155void iCylinderIsectVec(const xCylinder* c, const xVec3* v, xIsect* isx)
156{

Callers 1

iSphereForModelFunction · 0.70

Calls 5

iSphereIsectVecFunction · 0.85
memcpyFunction · 0.85
xVec3CopyFunction · 0.85
xVec3SMulFunction · 0.85
xVec3AddFunction · 0.85

Tested by

no test coverage detected