MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / boundBox

Method boundBox

source/game/StarDrawable.cpp:216–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216RectF Drawable::boundBox(bool cropImages) const {
217 RectF boundBox = RectF::null();
218 if (auto line = part.ptr<LinePart>()) {
219 boundBox.combine(line->line.min());
220 boundBox.combine(line->line.max());
221
222 } else if (auto poly = part.ptr<PolyPart>()) {
223 boundBox.combine(poly->poly.boundBox());
224
225 } else if (auto image = part.ptr<ImagePart>()) {
226 auto imageMetadata = Root::singleton().imageMetadataDatabase();
227 RectF imageRegion = RectF::null();
228 if (cropImages) {
229 RectU nonEmptyRegion = imageMetadata->nonEmptyRegion(image->image);
230 if (!nonEmptyRegion.isNull())
231 imageRegion = RectF(nonEmptyRegion);
232 } else {
233 imageRegion = RectF::withSize(Vec2F(), Vec2F(imageMetadata->imageSize(image->image)));
234 }
235
236 if (!imageRegion.isNull()) {
237 boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMin(), imageRegion.yMin())));
238 boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMax(), imageRegion.yMin())));
239 boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMin(), imageRegion.yMax())));
240 boundBox.combine(image->transformation.transformVec2(Vec2F(imageRegion.xMax(), imageRegion.yMax())));
241 }
242 }
243
244 if (!boundBox.isNull())
245 boundBox.translate(position);
246
247 return boundBox;
248}
249
250DataStream& operator>>(DataStream& ds, Drawable::LinePart& line) {
251 ds >> line.line;

Callers 15

spawnInCellMethod · 0.45
collisionAreaMethod · 0.45
WorldTemplateMethod · 0.45
addCustomSpaceRegionMethod · 0.45
localBoundBoxMethod · 0.45
collisionBoundBoxMethod · 0.45
validateEdgeMethod · 0.45
movingCollisionMethod · 0.45
renderCollisionDebugMethod · 0.45
boundBoxAllMethod · 0.45
queryHitMethod · 0.45

Calls 14

singletonClass · 0.85
imageMetadataDatabaseMethod · 0.80
transformVec2Method · 0.80
xMinMethod · 0.80
yMinMethod · 0.80
xMaxMethod · 0.80
yMaxMethod · 0.80
combineMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
nonEmptyRegionMethod · 0.45
isNullMethod · 0.45

Tested by

no test coverage detected