Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2018-02-08 16:29:13 +01:00
commit 814dcf302b
6 changed files with 26 additions and 7 deletions

View File

@ -33,6 +33,7 @@
* Added support for rotated regions in texture atlas loaded via StarlingAtlasAttachmentLoader.
* Added support for vertex effects. See `RaptorExample.as`
* Added 'getTexture()' method to 'StarlingTextureAtlasAttachmentLoader'
* Breaking change: if a skeleton requires two color tinting, you have to enable it via `SkeletonSprite.twoColorTint = true`. In this case the skeleton will use the `TwoColorMeshStyle`, which internally uses a different vertex layout and shader. This means that skeletons with two color tinting enabled will break batching and hence increase the number of draw calls in your app.
## C
* **Breaking changes**

View File

@ -72,6 +72,11 @@ package spine.examples {
skeleton.state.timeScale = 0.5;
skeleton.state.update(0.25);
skeleton.state.apply(skeleton.skeleton);
// enable two color tinting, which breaks batching between this skeleton
// and other Starling objects.
skeleton.twoColorTint = true;
skeleton.skeleton.updateWorldTransform();
addChild(skeleton);

View File

@ -59,9 +59,9 @@ package spine.starling {
static private var _tempMatrix : Matrix = new Matrix();
static private var _tempVertices : Vector.<Number> = new Vector.<Number>(8);
static internal var blendModes : Vector.<String> = new <String>[BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN];
private var _skeleton : Skeleton;
public var batchable : Boolean = true;
private var _skeleton : Skeleton;
private var _smoothing : String = "bilinear";
private var _twoColorTint : Boolean = false;
private static var clipper: SkeletonClipping = new SkeletonClipping();
private static var QUAD_INDICES : Vector.<uint> = new <uint>[0, 1, 2, 2, 3, 0];
@ -112,7 +112,7 @@ package spine.starling {
region.rendererObject = mesh = new SkeletonMesh(Image(region.rendererObject).texture);
if (region.rendererObject is AtlasRegion)
region.rendererObject = mesh = new SkeletonMesh(Image(AtlasRegion(region.rendererObject).rendererObject).texture);
mesh.setStyle(new TwoColorMeshStyle());
if (_twoColorTint) mesh.setStyle(new TwoColorMeshStyle());
indexData = mesh.getIndexData();
for (ii = 0; ii < indices.length; ii++)
indexData.setIndex(ii, indices[ii]);
@ -136,7 +136,7 @@ package spine.starling {
meshAttachment.rendererObject = mesh = new SkeletonMesh(Image(meshAttachment.rendererObject).texture);
if (meshAttachment.rendererObject is AtlasRegion)
meshAttachment.rendererObject = mesh = new SkeletonMesh(Image(AtlasRegion(meshAttachment.rendererObject).rendererObject).texture);
mesh.setStyle(new TwoColorMeshStyle());
if (_twoColorTint) mesh.setStyle(new TwoColorMeshStyle());
indexData = mesh.getIndexData();
indicesLength = meshAttachment.triangles.length;
@ -198,13 +198,13 @@ package spine.starling {
tempVertex.dark.setFromColor(tempDark);
vertexEffect.transform(tempVertex);
vertexData.colorize("color", Color.rgb(tempVertex.light.r * 255, tempVertex.light.g * 255, tempVertex.light.b * 255), tempVertex.light.a, ii, 1);
vertexData.colorize("color2", Color.rgb(tempVertex.dark.r * 255, tempVertex.dark.g * 255, tempVertex.dark.b * 255), a, ii, 1);
if (_twoColorTint) vertexData.colorize("color2", Color.rgb(tempVertex.dark.r * 255, tempVertex.dark.g * 255, tempVertex.dark.b * 255), a, ii, 1);
mesh.setVertexPosition(ii, tempVertex.x, tempVertex.y);
mesh.setTexCoords(ii, tempVertex.u, tempVertex.v);
}
} else {
vertexData.colorize("color", rgb, a);
vertexData.colorize("color2", dark);
if (_twoColorTint) vertexData.colorize("color2", dark);
for (ii = 0, iii = 0; ii < verticesCount; ii++, iii += 2) {
mesh.setVertexPosition(ii, worldVertices[iii], worldVertices[iii + 1]);
mesh.setTexCoords(ii, uvs[iii], uvs[iii + 1]);
@ -303,5 +303,13 @@ package spine.starling {
public function set smoothing(smoothing : String) : void {
_smoothing = smoothing;
}
public function get twoColorTint() : Boolean {
return _twoColorTint;
}
public function set twoColorTint(tint : Boolean) : void {
_twoColorTint = tint;
}
}
}

View File

@ -39,6 +39,7 @@ package spine.starling {
public class TwoColorEffect extends MeshEffect {
public static const VERTEX_FORMAT : VertexDataFormat = TwoColorMeshStyle.VERTEX_FORMAT;
private static const VECTOR_ONES:Vector.<Number> = Vector.<Number>([1, 1, 1, 1]);
override protected function createProgram() : Program {
// v0 -> tex coords
@ -75,7 +76,7 @@ package spine.starling {
vertexFormat.setVertexBufferAt(3, vertexBuffer, "color2");
// fc0 -> (1, 1, 1, 1)
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, Vector.<Number>([1, 1, 1, 1]));
context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT, 0, VECTOR_ONES);
}
override protected function afterDraw(context : Context3D) : void {

View File

@ -159,6 +159,10 @@ namespace Spine.Unity.Editor {
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.slot; } }
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) {
if (TargetAttribute.includeNone)
menu.AddItem(new GUIContent(NoneString), string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
for (int i = 0; i < data.Slots.Count; i++) {
string name = data.Slots.Items[i].Name;
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) {