forked from LeenkxTeam/LNXSDK
Repe [T3DU] Update - 31f26d171bba0355ce2a77031e3aad4c64dbc7e9
This commit is contained in:
@ -28,13 +28,15 @@ class MeshObject extends Object {
|
||||
public var cameraList: Array<String> = null;
|
||||
public var screenSize = 0.0;
|
||||
public var frustumCulling = true;
|
||||
public var tilesheet: Tilesheet = null;
|
||||
public var activeTilesheet: Tilesheet = null;
|
||||
public var tilesheets: Array<Tilesheet> = null;
|
||||
public var skip_context: String = null; // Do not draw this context
|
||||
public var force_context: String = null; // Draw only this context
|
||||
static var lastPipeline: PipelineState = null;
|
||||
#if lnx_morph_target
|
||||
public var morphTarget: MorphTarget = null;
|
||||
#end
|
||||
public var vertexGroups: Map<String, Array<Vec4>> = null;
|
||||
|
||||
#if lnx_veloc
|
||||
public var prevMatrix = Mat4.identity();
|
||||
@ -50,6 +52,10 @@ class MeshObject extends Object {
|
||||
|
||||
public function setData(data: MeshData) {
|
||||
this.data = data;
|
||||
|
||||
if (this.materials != null && this.materials.length > 0)
|
||||
data.geom.instanceElements = @:privateAccess this.materials[0].shader.contexts[0].instanceElements;
|
||||
|
||||
data.refcount++;
|
||||
|
||||
#if (!lnx_batch)
|
||||
@ -87,7 +93,8 @@ class MeshObject extends Object {
|
||||
particleSystems = null;
|
||||
}
|
||||
#end
|
||||
if (tilesheet != null) tilesheet.remove();
|
||||
if (activeTilesheet != null) activeTilesheet.remove();
|
||||
if (tilesheets != null) { for (ts in tilesheets) { ts.remove(); } tilesheets = null; }
|
||||
if (Scene.active != null) Scene.active.meshes.remove(this);
|
||||
#if (rp_renderer == "Deferred")
|
||||
if (Scene.active != null) Scene.active.markMaterialParamsDirty();
|
||||
@ -126,12 +133,34 @@ class MeshObject extends Object {
|
||||
#end
|
||||
|
||||
public function setupTilesheet(tilesheetData: iron.data.SceneFormat.TTilesheetData) {
|
||||
tilesheet = new Tilesheet(tilesheetData, this);
|
||||
activeTilesheet = new Tilesheet(tilesheetData, this);
|
||||
if (tilesheets == null) tilesheets = new Array<Tilesheet>();
|
||||
tilesheets.push(activeTilesheet);
|
||||
}
|
||||
|
||||
public function setActiveTilesheet(tilesheetData: iron.data.SceneFormat.TTilesheetData, tilesheetActionRef: String = null) {
|
||||
var set = false;
|
||||
if (tilesheets != null) {
|
||||
for (ts in tilesheets) {
|
||||
if (ts.raw == tilesheetData) {
|
||||
if (activeTilesheet != null) activeTilesheet.pause();
|
||||
activeTilesheet = ts;
|
||||
if (tilesheetActionRef != null) activeTilesheet.play(tilesheetActionRef);
|
||||
set = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!set) {
|
||||
if (activeTilesheet != null) activeTilesheet.pause();
|
||||
setupTilesheet(tilesheetData);
|
||||
if (tilesheetActionRef != null) activeTilesheet.play(tilesheetActionRef);
|
||||
}
|
||||
}
|
||||
|
||||
public function setTilesheetAction(actionRef: String) {
|
||||
if (tilesheet != null) {
|
||||
tilesheet.play(actionRef);
|
||||
if (activeTilesheet != null) {
|
||||
activeTilesheet.play(actionRef);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +193,7 @@ class MeshObject extends Object {
|
||||
}
|
||||
|
||||
function cullMesh(context: String, camera: CameraObject, light: LightObject): Bool {
|
||||
var isShadow = context == "shadowmap";
|
||||
if (camera == null) return false;
|
||||
|
||||
if (camera.data.raw.frustum_culling && frustumCulling) {
|
||||
@ -172,11 +202,12 @@ class MeshObject extends Object {
|
||||
var radiusScale = data.isSkinned ? 2.0 : 1.0;
|
||||
#if lnx_gpu_particles
|
||||
// particleSystems for update, particleOwner for render
|
||||
if (particleSystems != null || particleOwner != null) radiusScale *= 1000;
|
||||
if (particleSystems != null && particleSystems.length > 0) return setCulled(isShadow, false);
|
||||
#end
|
||||
/*
|
||||
if (context == "voxel") radiusScale *= 100;
|
||||
if (data.geom.instanced) radiusScale *= 100;
|
||||
var isShadow = context == "shadowmap";
|
||||
if (data.geom.instanced) radiusScale *= 100;*/
|
||||
if (data.geom.instanced) return setCulled(isShadow, false);
|
||||
var frustumPlanes = isShadow ? light.frustumPlanes : camera.frustumPlanes;
|
||||
|
||||
if (isShadow && light.data.raw.type != "sun") { // Non-sun light bounds intersect camera frustum
|
||||
@ -191,8 +222,9 @@ class MeshObject extends Object {
|
||||
}
|
||||
}
|
||||
|
||||
culled = false;
|
||||
return culled;
|
||||
//culled = false;
|
||||
//return culled;
|
||||
return setCulled(isShadow, false);
|
||||
}
|
||||
|
||||
function skipContext(context: String, mat: MaterialData): Bool {
|
||||
@ -227,11 +259,6 @@ class MeshObject extends Object {
|
||||
if (cullMesh(context, Scene.active.camera, RenderPath.active.light)) return;
|
||||
var meshContext = raw != null ? context == "mesh" : false;
|
||||
|
||||
// Update tilesheet
|
||||
if (tilesheet != null && meshContext) {
|
||||
tilesheet.update();
|
||||
}
|
||||
|
||||
if (cameraList != null && cameraList.indexOf(Scene.active.camera.name) < 0) return;
|
||||
|
||||
#if lnx_gpu_particles
|
||||
|
||||
Reference in New Issue
Block a user