<commit_before>package h3d.scene;

class DummyScene extends h2d.Sprite {
	
	override function updatePos() {
	}
	
}

class Sprite extends Object {
	
	var dummy : DummyScene;
	public var depthTest : Bool;
	public var element(default,set) : h2d.Drawable;
	
	public function new(element, ?parent) {
		super(parent);
		dummy = new DummyScene();
		depthTest = true;
		this.element = element;
	}
	
	function set_element(e) {
		if( element == e ) return e;
		if( element != null && element.parent == dummy ) element.remove();
		element = e;
		if( element != null ) dummy.addChild(element);
		return e;
	}
	
	@:access(h2d)
	override function draw( ctx : RenderContext ) {
		if( element == null )
			return;
		var p = new h3d.Vector(absPos._41, absPos._42, absPos._43);
		p.project(ctx.camera.m);
		element.shader.zValue = depthTest ? p.z : 0;
		if( !dummy.allocated )
			dummy.onAlloc();
		// base transformation
		dummy.matA = 2 * scaleX / ctx.engine.width;
		dummy.matB = 0;
		dummy.matC = 0;
		dummy.matD = -2 * scaleY / ctx.engine.height;
		dummy.absX = p.x;
		dummy.absY = p.y;
		dummy.posChanged = true;
		// temporary enable z-compare
		var c = h2d.Tools.getCoreObjects();
		c.tmpMaterial.depthTest = LessEqual;
		dummy.render(ctx.engine);
		c.tmpMaterial.depthTest = Always;
	}
	
}<commit_msg>added renderPass, used fixed 1024 scaling instead of screen one (prevents screen-dependent rendering)<commit_after>package h3d.scene;

class DummyScene extends h2d.Sprite {
	
	override function updatePos() {
	}
	
}

class Sprite extends Object {
	
	var dummy : DummyScene;
	public var depthTest : Bool;
	public var element(default, set) : h2d.Drawable;
	public var renderPass : Int;
	
	public function new(element, ?parent) {
		super(parent);
		dummy = new DummyScene();
		depthTest = true;
		this.element = element;
	}
	
	function set_element(e) {
		if( element == e ) return e;
		if( element != null && element.parent == dummy ) element.remove();
		element = e;
		if( element != null ) dummy.addChild(element);
		return e;
	}
	
	@:access(h2d)
	override function draw( ctx : RenderContext ) {
		if( element == null )
			return;
		if( renderPass > ctx.currentPass ) {
			ctx.addPass(draw);
			return;
		}
		var p = new h3d.Vector(absPos._41, absPos._42, absPos._43);
		p.project(ctx.camera.m);
		element.shader.zValue = depthTest ? p.z : 0;
		if( !dummy.allocated )
			dummy.onAlloc();
		// base transformation
		dummy.matA = 2 * scaleX / 1024;
		dummy.matB = 0;
		dummy.matC = 0;
		dummy.matD = -2 * scaleY / 1024 * (ctx.engine.width / ctx.engine.height);
		dummy.absX = p.x;
		dummy.absY = p.y;
		dummy.posChanged = true;
		// temporary enable z-compare
		var c = h2d.Tools.getCoreObjects();
		c.tmpMaterial.depthTest = LessEqual;
		dummy.render(ctx.engine);
		c.tmpMaterial.depthTest = Always;
	}
	
}
{'fraction_non_alphanumeric': 0.1334525939177102, 'fraction_numerical': 0.016457960644007157, 'mean_word_length': 3.3348837209302324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6496284', 'n_tokens_mistral': 1105, 'n_tokens_neox': 990, 'n_words': 248}