SabreCSG icon indicating copy to clipboard operation
SabreCSG copied to clipboard

Experimental: Introduction + Applied Brush visibility while paused

Open WallHackJack opened this issue 9 years ago • 2 comments

Hi all, I'm new to sabreCSG but it's clearly the tool for outputting rock-solid CSG operations. I've been playing around and I'll definitely be using it to create a randomly generated map in my game. I've written 2D CSG in the past and would love to help with SabreCSG's development, but I've never contributed to any open-source projects before. If anyone could point me in the right direction that'd be appreciated. For now I could help produce examples for the experimental API until I'm more familiar. I'm working on something that I'd be happy to submit as an example but I don't see the other two in the branch.

Also Is it possible to render subtraction brushes (or any brushes) while paused? It seems the AppliedBrush objects still exist after calling build, but you can't see the mesh or shape they represent at all. Enabling/disabling components on the right is prohibited. I have no experience scripting for the unity editor or I'd take a look at it myself.

WallHackJack avatar Jun 27 '17 18:06 WallHackJack

All applied brushes are of type PrimitiveBrush. Find PrimitiveBrush.cs and set the code for onGizmosSelected to this:

void OnDrawGizmosSelected(){

	Mesh MESH = GetComponent<MeshFilter>().mesh;

	Matrix4x4 newMatrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);
	Matrix4x4 oldMatrix = Gizmos.matrix;

	Gizmos.matrix *= newMatrix;


	Color mainColor = new Color(0,1,1,0.2f);
	Color outlineColor = new Color(0,1,1,0.5f);

	if(this.mode == CSGMode.Subtract){
		mainColor =  new Color(1,0,0,0.2f);
		outlineColor =  new Color(1,0,0,0.5f);
	}

	Gizmos.color = mainColor;
	Gizmos.DrawMesh(MESH);

	Gizmos.color = outlineColor;
	Gizmos.DrawWireMesh(MESH);

	Gizmos.matrix = oldMatrix;
}

This approach may cause some artifacts if you use primitive brushes before run time, so the code could be fixed to only run post-build.

WallHackJack avatar Sep 17 '17 07:09 WallHackJack

@sabresaurus Code above allows people using experimental API to see their brushes, without this there is no way to see the building blocks. Must only be enabled once the brush has been built/wiped in experimental

WallHackJack avatar Sep 17 '17 08:09 WallHackJack