nodeLocalBoundingBox gives different result in max2020 and max2022

nodeLocalBoundingBox gives different result in max2020 and max2022

miauuuu
Collaborator Collaborator
414 Views
3 Replies
Message 1 of 4

nodeLocalBoundingBox gives different result in max2020 and max2022

miauuuu
Collaborator
Collaborator

Hi!

 

Here is the test scene - a teapot, at [0,0,0] and rotated 45 deg on its Y axis.

When I use

 

nodeLocalBoundingBox selection[1]

 

the results are:

max2020:   #([-14.11,-13.303,14.11], [30.9627,13.303,-1.33177])

max2022:   #([-14.11,-13.303,-16.1472], [30.9627,13.303,28.9254]) -> The same scene, opened in 3ds max 2022

 

The Z values are different:

max2020          max2022

14.11                    -16.1472

-1.33177              28.9254

 

When I use:

 

(nodeGetBoundingBox selection[1] selection[1].transform)[1] * selection[1].transform

 

the results are:

max2020:   [-14.11,-13.303,14.11] -> match the nodeLocalBoundingBox value

max2022:   [-14.11,-13.303,14.11] -> does not match the nodeLocalBoundingBox value(Z component)

 

 

(nodeGetBoundingBox selection[1] selection[1].transform)[2] * selection[1].transform

 

the results are:

max2020:   [30.9627,13.303,-1.33176] -> match the nodeLocalBoundingBox value

max2022:   [30.9627,13.303,-1.33176] -> does not match the nodeLocalBoundingBox value in max2022, but does match the nodeLocalBoundingBox in max2020.

 

This difference between nax2020 and max2022 when nodeLocalBoundingBox  is used is a bug or a feature?

 

https://miauu-maxscript.com/
0 Likes
Accepted solutions (1)
415 Views
3 Replies
Replies (3)
Message 2 of 4

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

from the point of view of common sense, the nodeLocalBoundingBox has never worked correctly since its publishing... it is easy to see this if you look at the size of the resulting bounding box:
[30.9627,13.303,-1.33177] - [-14.11,-13.303,14.11] =
[45.0727,26.606,-15.4418]

 

so in +2022 in this sense the bug is fixed

 

PS. because of this, I used my own "get local bbox" method instead of built-in nodeLocalBoundingBox, which are surprisingly match now in 2022+ versions.

0 Likes
Message 3 of 4

denisT.MaxDoctor
Advisor
Advisor

 

 

/*************** Version 2020 *************/

Value*
	nodeLocalBoundingBox_cf(Value** arg_list, int count)
{
	check_arg_count(nodeLocalBoundingBox, 1, count);
	INode* node = get_valid_node((MAXNode*)arg_list[0], nodeLocalBoundingBox);
	MAXScript_TLS* _tls = (MAXScript_TLS*)TlsGetValue(thread_locals_index);
	const ObjectState& os = node->EvalWorldState(MAXScript_time_tls());
	Object* ob = os.obj;
	if (ob) 
	{
		Box3 bbox;
		ob->GetDeformBBox(MAXScript_time_tls(), bbox, NULL, FALSE);
		Point3 pmin = bbox.Min();
		((MAXNode*)arg_list[0])->object_to_current_coordsys(pmin);
		Point3 pmax = bbox.Max();
		((MAXNode*)arg_list[0])->object_to_current_coordsys(pmax);
		one_typed_value_local_tls(Array* result);
		vl.result = new Array (2);
		vl.result->append(new Point3Value (pmin));
		vl.result->append(new Point3Value (pmax));
		return_value_tls(vl.result);
	}
	return &undefined;
}

/*************** Version 2023 *************/

Value*
	nodeLocalBoundingBox_cf(Value** arg_list, int count)
{
	// nodeLocalBoundingBox <node> asBox3:<bool>
	check_arg_count_with_keys(nodeLocalBoundingBox, 1, count);
	INode* node = get_valid_node((MAXNode*)arg_list[0], nodeLocalBoundingBox);
	Value* tmp;
	BOOL asBox3 = bool_key_arg(asBox3, tmp, FALSE);
	MAXScript_TLS* _tls = (MAXScript_TLS*)TlsGetValue(thread_locals_index);
	const ObjectState& os = node->EvalWorldState(MAXScript_time_tls());
	Object* ob = os.obj;
	if (ob) 
	{
		Box3 bbox;
		ob->GetDeformBBox(MAXScript_time_tls(), bbox, NULL, FALSE);
		((MAXNode*)arg_list[0])->object_to_current_coordsys(bbox);
		if (asBox3)
		{
			return_value_tls(new Box3Value(bbox));
		}
		Point3 pmin = bbox.Min();
		Point3 pmax = bbox.Max();
		one_typed_value_local_tls(Array* result);
		vl.result = new Array (2);
		vl.result->append(new Point3Value (pmin));
		vl.result->append(new Point3Value (pmax));
		return_value_tls(vl.result);
	}
	return &undefined;
}

 

 

 

there is a difference .... 

0 Likes
Message 4 of 4

miauuuu
Collaborator
Collaborator

Thank you, Denis!

 

Here are the values when (nodeGetBoundingBox selection[1] selection[1].transform)[2] is used:

 

max2020: [22.8356, 13.303, 20.9522]

max2022: [22.8356, 13.303, 20.9522]

 

They are the same. But this:

 

(nodeGetBoundingBox selection[1] selection[1].transform)[2] * selection[1].transform

 

returns:

max2020: [30.9627,13.303,-1.33176]  == (nodeLocalBoundingBox selection[1])[2] -> [30.9627,13.303,-1.33177]

max2022: [30.9627,13.303,-1.33176]  != (nodeLocalBoundingBox selection[1])[2] -> [30.9627,13.303,28.9254]

 

 

Here is how the issue was found:

nglbb_max2020-2022.jpg

https://miauu-maxscript.com/
0 Likes