Skip to content

why Multiply 2 when Compute the cost? #5

@bellpo

Description

@bellpo

in AABBTree.cpp at 144 row

float newParentNodeCost = 2.0f * combinedAabb.surfaceArea;

here why Multiply 2 ? because here only add combinedSurfaceArea oncetime for add new node.

And I think here should be
---------START------------
{

	float newParentNodeCost =   combinedAabb.surfaceArea;
	float minimumPushDownCost =  (combinedAabb.surfaceArea - treeNode.aabb.surfaceArea);

	// use the costs to figure out whether to create a new parent here or descend
	float costLeft;
	float costRight;
	if (leftNode.isLeaf())
	{
		costLeft = leafNode.aabb.merge(leftNode.aabb).surfaceArea + minimumPushDownCost;
	}
	else
	{
		AABB newLeftAabb = leafNode.aabb.merge(leftNode.aabb);
		costLeft = (newLeftAabb.surfaceArea - leftNode.aabb.surfaceArea) + minimumPushDownCost;			
	}
	if (rightNode.isLeaf())
	{
		costRight = leafNode.aabb.merge(rightNode.aabb).surfaceArea + minimumPushDownCost;
	}

}
---------END------------
so compare cost and costLeft , can get the smallest Bounding box for all tree .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions