<commit_before>package aerys.minko.scene.controller.mesh.skinning
{
	import aerys.minko.Minko;
	import aerys.minko.ns.minko_math;
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.controller.IRebindableController;
	import aerys.minko.scene.node.Group;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Mesh;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.animation.SkinningMethod;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.log.DebugLevel;
	import aerys.minko.type.math.Matrix4x4;
	
	import flash.display.BitmapData;
	import flash.geom.Matrix3D;
	import flash.utils.Dictionary;
	
	public final class SkinningController extends EnterFrameController implements IRebindableController
	{
		public static const MAX_NUM_INFLUENCES	: uint	= 8;
		public static const MAX_NUM_JOINTS		: uint	= 51;
		
		private var _skinningHelper		: AbstractSkinningHelper;
		private var _isDirty			: Boolean;
		
		private var _method				: uint;
		private var _bindShapeMatrix	: Matrix3D;
		private var _skeletonRoot		: Group;
		private var _joints				: Vector.<Group>;
		private var _invBindMatrices	: Vector.<Matrix3D>;
		
		private var _numVisibleTargets	: uint;
		
		public function get skinningMethod() : uint
		{
			return _method;
		}
		
		public function get bindShape() : Matrix4x4
		{
			var bindShape : Matrix4x4 = new Matrix4x4();
			bindShape.minko_math::_matrix = _bindShapeMatrix;
			
			return bindShape;
		}
		
		public function get skeletonRoot() : Group
		{
			return _skeletonRoot;
		}
		
		public function get joints() : Vector.<Group>
		{
			return _joints;
		}
		
		public function get invBindMatrices() : Vector.<Matrix4x4>
		{
			var numMatrices		: uint					= _invBindMatrices.length;
			var invBindMatrices : Vector.<Matrix4x4>	= new Vector.<Matrix4x4>(numMatrices);
			
			for (var matrixId : uint = 0; matrixId < numMatrices; ++matrixId)
			{
				invBindMatrices[matrixId] = new Matrix4x4();
				invBindMatrices[matrixId].minko_math::_matrix = _invBindMatrices[matrixId];
			}
			
			return invBindMatrices;
		}
		
		public function SkinningController(method			: uint,
										   skeletonRoot		: Group,
										   joints			: Vector.<Group>,
										   bindShape		: Matrix4x4,
										   invBindMatrices	: Vector.<Matrix4x4>)
		{
			super(Mesh);
			
			_method				= method;
			_skeletonRoot		= skeletonRoot;
			_bindShapeMatrix	= bindShape.minko_math::_matrix;
			_isDirty			= false;
			
			initialize(joints, invBindMatrices);
		}
		
		private function initialize(joints			: Vector.<Group>,
									invBindMatrices	: Vector.<Matrix4x4>) : void
		{
			var numJoints : uint = joints.length;
			
			_joints	= joints.slice();
			
			_invBindMatrices	= new Vector.<Matrix3D>(numJoints, true);
			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_invBindMatrices[jointId] = invBindMatrices[jointId].minko_math::_matrix;
		}
		
		override protected function targetAddedToSceneHandler(target	: ISceneNode,
															  scene		: Scene) : void
		{
			super.targetAddedToSceneHandler(target, scene);
			
			if (numTargetsInScene == 1)
				subscribeToJoints();
			
			var mesh : Mesh = target as Mesh;
			<commit_msg>throw an error when the skeletonRoot passed to SkinningController constructor is null<commit_after>package aerys.minko.scene.controller.mesh.skinning
{
	import aerys.minko.Minko;
	import aerys.minko.ns.minko_math;
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.controller.IRebindableController;
	import aerys.minko.scene.node.Group;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Mesh;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.animation.SkinningMethod;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.log.DebugLevel;
	import aerys.minko.type.math.Matrix4x4;
	
	import flash.display.BitmapData;
	import flash.geom.Matrix3D;
	import flash.utils.Dictionary;
	
	public final class SkinningController extends EnterFrameController implements IRebindableController
	{
		public static const MAX_NUM_INFLUENCES	: uint	= 8;
		public static const MAX_NUM_JOINTS		: uint	= 51;
		
		private var _skinningHelper		: AbstractSkinningHelper;
		private var _isDirty			: Boolean;
		
		private var _method				: uint;
		private var _bindShapeMatrix	: Matrix3D;
		private var _skeletonRoot		: Group;
		private var _joints				: Vector.<Group>;
		private var _invBindMatrices	: Vector.<Matrix3D>;
		
		private var _numVisibleTargets	: uint;
		
		public function get skinningMethod() : uint
		{
			return _method;
		}
		
		public function get bindShape() : Matrix4x4
		{
			var bindShape : Matrix4x4 = new Matrix4x4();
			bindShape.minko_math::_matrix = _bindShapeMatrix;
			
			return bindShape;
		}
		
		public function get skeletonRoot() : Group
		{
			return _skeletonRoot;
		}
		
		public function get joints() : Vector.<Group>
		{
			return _joints;
		}
		
		public function get invBindMatrices() : Vector.<Matrix4x4>
		{
			var numMatrices		: uint					= _invBindMatrices.length;
			var invBindMatrices : Vector.<Matrix4x4>	= new Vector.<Matrix4x4>(numMatrices);
			
			for (var matrixId : uint = 0; matrixId < numMatrices; ++matrixId)
			{
				invBindMatrices[matrixId] = new Matrix4x4();
				invBindMatrices[matrixId].minko_math::_matrix = _invBindMatrices[matrixId];
			}
			
			return invBindMatrices;
		}
		
		public function SkinningController(method			: uint,
										   skeletonRoot		: Group,
										   joints			: Vector.<Group>,
										   bindShape		: Matrix4x4,
										   invBindMatrices	: Vector.<Matrix4x4>)
		{
			super(Mesh);
			
            if (!skeletonRoot)
                throw new Error('skeletonRoot cannot be null');
            
			_method				= method;
			_skeletonRoot		= skeletonRoot;
			_bindShapeMatrix	= bindShape.minko_math::_matrix;
			_isDirty			= false;
			
			initialize(joints, invBindMatrices);
		}
		
		private function initialize(joints			: Vector.<Group>,
									invBindMatrices	: Vector.<Matrix4x4>) : void
		{
			var numJoints : uint = joints.length;
			
			_joints	= joints.slice();
			
			_invBindMatrices	= new Vector.<Matrix3D>(numJoints, true);
			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_invBindMatrices[jointId] = invBindMatrices[jointId].minko_math::_matrix;
		}
		
		override protected function targetAddedToSceneHandler(target	: ISceneNode,
															  scene		: Scene) : void
		{
			super.targetAddedToSceneHandler(target, scene);
			
			if (numTargetsInScene == 1)
				subscribeToJoints();
			
			var mesh : Mesh = target as Mesh;
			
{'fraction_non_alphanumeric': 0.0911214953271028, 'fraction_numerical': 0.009345794392523364, 'mean_word_length': 3.4502923976608186, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2654085', 'n_tokens_mistral': 2793, 'n_tokens_neox': 2298, 'n_words': 464}