Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions src/com/uwsoft/editor/renderer/SceneLoader.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.uwsoft.editor.renderer;

import box2dLight.RayHandler;

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.Engine;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.EntityListener;
import com.badlogic.ashley.core.PooledEngine;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
Expand All @@ -20,20 +18,37 @@
import com.badlogic.gdx.utils.viewport.ScalingViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.uwsoft.editor.renderer.commons.IExternalItemType;
import com.uwsoft.editor.renderer.components.*;
import com.uwsoft.editor.renderer.components.MainItemComponent;
import com.uwsoft.editor.renderer.components.NodeComponent;
import com.uwsoft.editor.renderer.components.ParentNodeComponent;
import com.uwsoft.editor.renderer.components.ScriptComponent;
import com.uwsoft.editor.renderer.components.light.LightObjectComponent;
import com.uwsoft.editor.renderer.components.physics.PhysicsBodyComponent;
import com.uwsoft.editor.renderer.data.*;
import com.uwsoft.editor.renderer.data.CompositeItemVO;
import com.uwsoft.editor.renderer.data.CompositeVO;
import com.uwsoft.editor.renderer.data.ProjectInfoVO;
import com.uwsoft.editor.renderer.data.ResolutionEntryVO;
import com.uwsoft.editor.renderer.data.SceneVO;
import com.uwsoft.editor.renderer.factory.EntityFactory;
import com.uwsoft.editor.renderer.physics.PhysicsBodyLoader;
import com.uwsoft.editor.renderer.resources.IResourceRetriever;
import com.uwsoft.editor.renderer.resources.ResourceManager;
import com.uwsoft.editor.renderer.scripts.IScript;
import com.uwsoft.editor.renderer.systems.*;
import com.uwsoft.editor.renderer.systems.ButtonSystem;
import com.uwsoft.editor.renderer.systems.CompositeSystem;
import com.uwsoft.editor.renderer.systems.LabelSystem;
import com.uwsoft.editor.renderer.systems.LayerSystem;
import com.uwsoft.editor.renderer.systems.LightSystem;
import com.uwsoft.editor.renderer.systems.ParticleSystem;
import com.uwsoft.editor.renderer.systems.PhysicsSystem;
import com.uwsoft.editor.renderer.systems.ScriptSystem;
import com.uwsoft.editor.renderer.systems.SpriteAnimationSystem;
import com.uwsoft.editor.renderer.systems.action.ActionSystem;
import com.uwsoft.editor.renderer.systems.render.Overlap2dRenderer;
import com.uwsoft.editor.renderer.utils.ComponentRetriever;

import box2dLight.RayHandler;

/**
* SceneLoader is important part of runtime that utilizes provided
* IResourceRetriever (or creates default one shipped with runtime) in order to
Expand All @@ -46,7 +61,7 @@ public class SceneLoader {
private SceneVO sceneVO;
private IResourceRetriever rm = null;

public Engine engine = null;
public PooledEngine engine = null;
public RayHandler rayHandler;
public World world;
public Entity rootEntity;
Expand All @@ -66,14 +81,14 @@ public SceneLoader(World world, RayHandler rayHandler) {

this.rm = rm;

this.engine = new Engine();
this.engine = new PooledEngine();
initSceneLoader();
}

public SceneLoader(IResourceRetriever rm, World world, RayHandler rayHandler) {
this.world = world;
this.rayHandler = rayHandler;
this.engine = new Engine();
this.engine = new PooledEngine();
this.rm = rm;
initSceneLoader();
}
Expand Down Expand Up @@ -109,7 +124,7 @@ private void initSceneLoader() {
}

addSystems();
entityFactory = new EntityFactory(rayHandler, world, rm);
entityFactory = new EntityFactory(engine,rayHandler, world, rm);
}

public void setResolution(String resolutionName) {
Expand Down Expand Up @@ -142,7 +157,7 @@ public SceneVO loadScene(String sceneName, Viewport viewport, boolean customLigh
engine.addEntity(rootEntity);

if(sceneVO.composite != null) {
entityFactory.initAllChildren(engine, rootEntity, sceneVO.composite);
entityFactory.initAllChildren(rootEntity, sceneVO.composite);
}
if (!customLight) {
setAmbienceInfo(sceneVO);
Expand Down Expand Up @@ -328,7 +343,7 @@ public IResourceRetriever getRm() {
return rm;
}

public Engine getEngine() {
public PooledEngine getEngine() {
return engine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;
import com.uwsoft.editor.renderer.systems.action.data.ActionData;

/**
* Created by ZeppLondon on 10/13/2015.
*/
public class ActionComponent implements Component {
public class ActionComponent implements Component,Pool.Poolable {
public Array<ActionData> dataArray = new Array<ActionData>(true, 0);

@Override
public void reset() {
dataArray.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.math.Affine2;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.utils.Pool;

public class CompositeTransformComponent implements Component {
public class CompositeTransformComponent implements Component,Pool.Poolable {
public boolean automaticResize = false;
public boolean transform = false;
public final Affine2 worldTransform = new Affine2();
public final Matrix4 computedTransform = new Matrix4();
public final Matrix4 oldTransform = new Matrix4();

@Override
public void reset() {
automaticResize = false;
transform = false;
worldTransform.idt();
computedTransform.idt();
oldTransform.idt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
import com.badlogic.gdx.math.Polygon;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Pool;
import com.uwsoft.editor.renderer.data.ShapeVO;
import com.uwsoft.editor.renderer.utils.PolygonUtils;

public class DimensionsComponent implements Component {
public class DimensionsComponent implements Component,Pool.Poolable {
public float width = 0;
public float height = 0;

Expand Down Expand Up @@ -59,4 +60,12 @@ public void setFromShape(ShapeVO shape) {
height = maxPoint.y - minPoint.y;
}
}

@Override
public void reset() {
width=0;
height=0;
boundBox=null;
polygon=null;
}
}
11 changes: 10 additions & 1 deletion src/com/uwsoft/editor/renderer/components/LayerMapComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import java.util.HashMap;

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Pool;
import com.uwsoft.editor.renderer.data.LayerItemVO;

public class LayerMapComponent implements Component {
public class LayerMapComponent implements Component,Pool.Poolable {

public boolean autoIndexing = true;
private ArrayList<LayerItemVO> layers = new ArrayList<LayerItemVO>();

Expand Down Expand Up @@ -73,4 +75,11 @@ public void swap(String source, String target) {
LayerItemVO targetVO = getLayer(target);
Collections.swap(layers, layers.indexOf(sourceVO), layers.indexOf(targetVO));
}

@Override
public void reset() {
autoIndexing=true;
layerMap.clear();
layers.clear();
}
}
14 changes: 13 additions & 1 deletion src/com/uwsoft/editor/renderer/components/MainItemComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;

import java.util.HashSet;
import java.util.Set;

public class MainItemComponent implements Component {
public class MainItemComponent implements Component,Pool.Poolable {
public int uniqueId = 0;
public String itemIdentifier = "";
public String libraryLink = "";
public Set<String> tags = new HashSet<String>();
public String customVars = "";
public int entityType;
public boolean visible = true;

@Override
public void reset() {
uniqueId = 0;
itemIdentifier = "";
libraryLink = "";
tags.clear();
customVars = "";
entityType=0;
visible = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.utils.Pool;

public class NinePatchComponent implements Component {
public class NinePatchComponent implements Component,Pool.Poolable {
public String textureRegionName;
public NinePatch ninePatch;

@Override
public void reset() {
textureRegionName=null;
ninePatch=null;
}
}
9 changes: 8 additions & 1 deletion src/com/uwsoft/editor/renderer/components/NodeComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.utils.Pool;
import com.badlogic.gdx.utils.SnapshotArray;

public class NodeComponent implements Component {
public class NodeComponent implements Component,Pool.Poolable {

public SnapshotArray<Entity> children = new SnapshotArray<Entity>(true, 1, Entity.class);

public void removeChild(Entity entity) {
Expand All @@ -14,4 +16,9 @@ public void removeChild(Entity entity) {
public void addChild(Entity entity) {
children.add(entity);
}

@Override
public void reset() {
children.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.utils.Pool;

public class ParentNodeComponent implements Component {
public class ParentNodeComponent implements Component,Pool.Poolable {
public Entity parentEntity = null;

@Override
public void reset() {
parentEntity=null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Pool;

/**
* Created by azakhary on 7/2/2015.
*/
public class PolygonComponent implements Component {
public class PolygonComponent implements Component,Pool.Poolable {
public Vector2[][] vertices;

public void makeRectangle(float width, float height) {
Expand All @@ -49,4 +50,9 @@ public void makeRectangle(float x, float y, float width, float height) // Overlo
vertices = new Vector2[1][4];
vertices[0] = points;
}

@Override
public void reset() {
vertices=null;
}
}
12 changes: 11 additions & 1 deletion src/com/uwsoft/editor/renderer/components/ScissorComponent.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package com.uwsoft.editor.renderer.components;

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Pool;

public class ScissorComponent implements Component {
public class ScissorComponent implements Component,Pool.Poolable {
public float scissorX;
public float scissorY;
public float scissorWidth;
public float scissorHeight;


@Override
public void reset() {
scissorX=0f;
scissorY=0f;
scissorWidth=0f;
scissorHeight=0f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.ReflectionException;
import com.uwsoft.editor.renderer.scripts.IScript;
Expand All @@ -11,7 +12,7 @@
/**
* Created by azakhary on 6/19/2015.
*/
public class ScriptComponent implements Component {
public class ScriptComponent implements Component,Pool.Poolable {

public Array<IScript> scripts = new Array<IScript>();

Expand All @@ -37,4 +38,9 @@ public void removeScript(Class className) {
}
}
}

@Override
public void reset() {
scripts.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Pool;

public class ShaderComponent implements Component {
public class ShaderComponent implements Component,Pool.Poolable {
public String shaderName;
private ShaderProgram shaderProgram = null;

Expand All @@ -20,4 +21,10 @@ public void clear() {
shaderName = null;
shaderProgram = null;
}

@Override
public void reset() {
shaderName=null;
shaderProgram=null;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package com.uwsoft.editor.renderer.components;

import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.utils.Pool;

public class SpineDataComponent implements Component {
public class SpineDataComponent implements Component,Pool.Poolable {
public String animationName = "";
public String currentAnimationName = "";

@Override
public void reset() {
animationName="";
currentAnimationName="";
}
}
Loading