Method: CGLM::AABB#crop_until

Defined in:
ext/cglm/rb_cglm_aabb.c

#crop_until(crop, clamp[, dest]) ⇒ Object

Crops this AABB by crop, placing the result in dest or creating a new one. Returns dest. If the result would be smaller than clamp, it is restricted to the extents of clamp instead.

This could be useful for gettng a bbox which fits with view frustum and object bounding boxes. In this case you crop view frustum box with objects box.



71
72
73
74
75
76
77
78
79
80
81
82
# File 'ext/cglm/rb_cglm_aabb.c', line 71

VALUE rb_cglm_aabb_crop_until(int argc, VALUE *argv, VALUE self) {
  VALUE other, clamp, dest;
  rb_scan_args(argc, argv, "21", &other, &clamp, &dest);
  if (NIL_P(dest)) dest = AABB_NEW(ALLOC_AABB);
  aabb *a, *b, *c, *out;
  a = &VAL2AABB(self);
  b = &VAL2AABB(other);
  c = &VAL2AABB(clamp);
  out = &VAL2AABB(dest);
  glm_aabb_crop_until(a->corners, b->corners, c->corners, out->corners);
  return dest;
}