mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 09:59:10 -07:00
New mouse handling implemented in LOD. trace in camera removed. And bonus: now lights can be placed in LOD.
This commit is contained in:
@@ -328,8 +328,6 @@ public class Camera3D extends Object3D {
|
||||
}
|
||||
raysLength = view.raysLength;
|
||||
|
||||
trace(raysLength, globalMouseHandlingType);
|
||||
|
||||
// Check getting in frustum and occluding
|
||||
if (root.culling >= 0 && (root.boundBox == null || occludersLength == 0 || !root.boundBox.checkOcclusion(occluders, occludersLength, root.localToCameraTransform))) {
|
||||
// Check if the ray crossing the bounding box
|
||||
|
||||
@@ -169,14 +169,17 @@ package alternativa.engine3d.objects {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Holds current level
|
||||
private var level:Object3D;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
override alternativa3d function collectDraws(camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
||||
override alternativa3d function calculateVisibility(camera:Camera3D):void {
|
||||
var distance:Number = Math.sqrt(localToCameraTransform.d*localToCameraTransform.d + localToCameraTransform.h*localToCameraTransform.h + localToCameraTransform.l*localToCameraTransform.l);
|
||||
for (var level:Object3D = levelList; level != null; level = level.next) {
|
||||
for (level = levelList; level != null; level = level.next) {
|
||||
if (distance <= level.distance) {
|
||||
collectChildDraws(level, this, camera, lights, lightsLength, useShadow);
|
||||
calculateChildVisibility(level, this, camera);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -185,15 +188,39 @@ package alternativa.engine3d.objects {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
alternativa3d function collectChildDraws(child:Object3D, parent:Object3D, camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
||||
alternativa3d function calculateChildVisibility(child:Object3D, parent:Object3D, camera:Camera3D):void {
|
||||
// Composing direct and reverse matrices
|
||||
if (child.transformChanged) child.composeTransforms();
|
||||
// Calculation of transfer matrix from camera to local space.
|
||||
child.cameraToLocalTransform.combine(child.inverseTransform, parent.cameraToLocalTransform);
|
||||
// Calculation of transfer matrix from local space to camera.
|
||||
child.localToCameraTransform.combine(parent.localToCameraTransform, child.transform);
|
||||
|
||||
if (child.mouseEnabled) camera.globalMouseHandlingType |= child.mouseHandlingType;
|
||||
// Pass
|
||||
child.culling = parent.culling;
|
||||
// Calculating visibility of the self content
|
||||
if (child.culling >= 0) child.calculateVisibility(camera);
|
||||
|
||||
// Hierarchical call
|
||||
for (var c:Object3D = child.childrenList; c != null; c = c.next) {
|
||||
calculateChildVisibility(c, child, camera);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
override alternativa3d function collectDraws(camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
||||
// Level must be choosen in CalculateVisibility
|
||||
if (level != null) collectChildDraws(level, this, camera, lights, lightsLength, useShadow);
|
||||
level = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
alternativa3d function collectChildDraws(child:Object3D, parent:Object3D, camera:Camera3D, lights:Vector.<Light3D>, lightsLength:int, useShadow:Boolean):void {
|
||||
child.listening = parent.listening;
|
||||
// If object needs on light sources.
|
||||
if (lightsLength > 0 && child.useLights) {
|
||||
|
||||
Reference in New Issue
Block a user