Page MenuHomeFeedback Tracker

lineIntersectsSurfaces returns the parent selection instead of the selection itself
Feedback, NormalPublic

Description

The selectionName that lineIntersectsSurfaces returns is incorrect, and inconsistent with the one returned by intersect command.

That's because the returned name is the topmost parent of the bone.

Edit: After more tests it seems that it only happens in some cases. I'm not sure exactly when.

Details

Severity
Minor
Resolution
Open
Reproducibility
Sometimes
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce
  1. Run the following code to create the apc object. It also opens one of the top hatches.
apc = createSimpleObject ["a3\armor_f_beta\apc_wheeled_01\apc_wheeled_01_cannon_f.p3d", player modelToWorldWorld [0, 10, 3], true];
apc animate ["poklop_gunner", 1, true];
  1. Run the following code. It returns the selection name using the intersect command (correct one):
onEachFrame {
	_p1 = AGLToASL positionCameraToWorld [0,0,0];
	_p2 = AGLToASL positionCameraToWorld [0,0,100];
	
	_draw = [];

	lineIntersectsSurfaces [_p1, _p2, objNull, objNull, true, 1, "FIRE", "NONE"] apply {
		if (getModelInfo (_x#3)#2) then {
			
			[_x#3, "FIRE"] intersect [ASLToAGL _p1, ASLToAGL _p2] apply {
				_draw pushBack [_p1 vectorAdd (_p1 vectorFromTo _p2 vectorMultiply _x#1), _x#0];
			};
		};
	};
	
	{
		drawIcon3D ["", [1,0,0,1], ASLToAGL (_x#0), 0.05, 0.05, 0, _x#1];
	} forEach _draw;
}
  1. If you look at the hatch while the above code is running, selection name is poklop_gunner which is correct.
  1. Run the following code. It returns the selection name using the lineIntersectsSurfaces command (incorrect one):
onEachFrame {
	_p1 = AGLToASL positionCameraToWorld [0,0,0];
	_p2 = AGLToASL positionCameraToWorld [0,0,100];
	
	_draw = [];

	lineIntersectsSurfaces [_p1, _p2, objNull, objNull, true, 1, "FIRE", "NONE"] apply {
		_draw pushBack [_x#0, _x#4];
	};
	
	{
		drawIcon3D ["", [1,0,0,1], ASLToAGL (_x#0), 0.05, 0.05, 0, _x#1];
	} forEach _draw;
}
  1. Look at the top hatch again. This time you get otocvez for selection name, which is the turret bone, not the hatch. The turret bone is the parent of hatch.

Event Timeline

Leopard20 created this task.Jul 1 2022, 5:02 PM
Leopard20 updated the task description. (Show Details)
Leopard20 changed Reproducibility from Always to Sometimes.Jul 2 2022, 2:37 AM
Leopard20 updated the task description. (Show Details)
dedmen added a subscriber: dedmen.Jul 4 2022, 1:29 PM

our stuff thing, returns name of all selections that were found.
In this case otocvez AND poklop_gunner, but it returns only the first one.

If we return the last one we would return the correct one here.

dedmen claimed this task.Jul 4 2022, 6:25 PM
dedmen changed the task status from New to Feedback.
dedmen set Ref Ticket to AIII-55238.