avm2: Convert invalid rectangle to zero rectangle in getBounds
This commit is contained in:
parent
f31d9bc491
commit
1cf669c75e
|
@ -960,7 +960,7 @@ pub fn get_bounds<'gc>(
|
|||
.and_then(|o| o.as_display_object())
|
||||
.unwrap_or(dobj);
|
||||
let bounds = dobj.bounds();
|
||||
let out_bounds = if DisplayObject::ptr_eq(dobj, target) {
|
||||
let mut out_bounds = if DisplayObject::ptr_eq(dobj, target) {
|
||||
// Getting the clips bounds in its own coordinate space; no AABB transform needed.
|
||||
bounds
|
||||
} else {
|
||||
|
@ -972,6 +972,9 @@ pub fn get_bounds<'gc>(
|
|||
let to_target_matrix = target.global_to_local_matrix().unwrap_or_default();
|
||||
to_target_matrix * to_global_matrix * bounds
|
||||
};
|
||||
if !out_bounds.is_valid() {
|
||||
out_bounds = Rectangle::ZERO;
|
||||
}
|
||||
|
||||
return Ok(new_rectangle(activation, out_bounds)?.into());
|
||||
}
|
||||
|
|
|
@ -65,6 +65,13 @@ impl<T: Coordinate> Rectangle<T> {
|
|||
y_max: T::INVALID,
|
||||
};
|
||||
|
||||
pub const ZERO: Self = Self {
|
||||
x_min: T::ZERO,
|
||||
x_max: T::ZERO,
|
||||
y_min: T::ZERO,
|
||||
y_max: T::ZERO,
|
||||
};
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn is_valid(&self) -> bool {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package {
|
||||
|
||||
import flash.display.MovieClip;
|
||||
|
||||
|
||||
public class Test extends MovieClip {
|
||||
|
||||
|
||||
public function Test() {
|
||||
trace("Bounds: " + this.getBounds(this));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Bounds: (x=0, y=0, w=0, h=0)
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
num_ticks = 1
|
Loading…
Reference in New Issue