Skip to content

Commit

Permalink
avm2: Use NativeCallable in Context3D code
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Jan 22, 2025
1 parent de61d87 commit cfbb110
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/avm2/globals/flash/display3D/context_3d.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::avm2::error::{argument_error, error, make_error_2008};
use crate::avm2::globals::methods::flash_geom_matrix_3d as matrix3d_methods;
use crate::avm2::globals::slots::flash_geom_matrix_3d as matrix3d_slots;
use crate::avm2::globals::slots::flash_geom_rectangle as rectangle_slots;
use crate::avm2::parameters::ParametersExt;
Expand Down Expand Up @@ -321,11 +322,11 @@ pub fn set_program_constants_from_matrix<'gc>(
// See https://github.com/openfl/openfl/blob/971a4c9e43b5472fd84d73920a2b7c1b3d8d9257/src/openfl/display3D/Context3D.hx#L1532-L1550
if user_transposed_matrix {
matrix = Value::from(matrix)
.call_public_property("clone", &[], activation)?
.call_method(matrix3d_methods::CLONE, &[], activation)?
.as_object()
.expect("Matrix3D.clone returns Object");

Value::from(matrix).call_public_property("transpose", &[], activation)?;
Value::from(matrix).call_method(matrix3d_methods::TRANSPOSE, &[], activation)?;
}

let matrix_raw_data = matrix
Expand Down
3 changes: 3 additions & 0 deletions core/src/avm2/globals/flash/geom/Matrix3D.as
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ package flash.geom {
}
}

[Ruffle(NativeCallable)]
public function transpose():void {
// Make a copy
var oRawData = this._rawData.AS3::concat();
Expand All @@ -237,6 +238,7 @@ package flash.geom {
this._rawData[13] = oRawData[7];
this._rawData[14] = oRawData[11];
}

public function append(lhs:Matrix3D):void {
var m111:Number = this._rawData[0],
m121:Number = this._rawData[4],
Expand Down Expand Up @@ -403,6 +405,7 @@ package flash.geom {
}
}

[Ruffle(NativeCallable)]
public function clone():Matrix3D {
return new Matrix3D(this.rawData);
}
Expand Down

0 comments on commit cfbb110

Please sign in to comment.