fix errors on rendering objects with subtimelines

This commit is contained in:
Skyler Lehmkuhl 2024-12-07 18:35:33 -05:00
parent 10fc546e61
commit 22cb543214
1 changed files with 13 additions and 11 deletions

View File

@ -954,6 +954,7 @@ function selectCurve(context, mouse) {
let closestCurve = undefined let closestCurve = undefined
let closestShape = undefined let closestShape = undefined
for (let shape of context.activeObject.currentFrame.shapes) { for (let shape of context.activeObject.currentFrame.shapes) {
if (shape instanceof TempShape) continue;
if (mouse.x > shape.boundingBox.x.min - mouseTolerance && if (mouse.x > shape.boundingBox.x.min - mouseTolerance &&
mouse.x < shape.boundingBox.x.max + mouseTolerance && mouse.x < shape.boundingBox.x.max + mouseTolerance &&
mouse.y > shape.boundingBox.y.min - mouseTolerance && mouse.y > shape.boundingBox.y.min - mouseTolerance &&
@ -979,8 +980,8 @@ function selectVertex(context, mouse) {
let closestDist = mouseTolerance; let closestDist = mouseTolerance;
let closestVertex = undefined let closestVertex = undefined
let closestShape = undefined let closestShape = undefined
console.log(context.activeObject.currentFrame.shapes)
for (let shape of context.activeObject.currentFrame.shapes) { for (let shape of context.activeObject.currentFrame.shapes) {
if (shape instanceof TempShape) continue;
if (mouse.x > shape.boundingBox.x.min - mouseTolerance && if (mouse.x > shape.boundingBox.x.min - mouseTolerance &&
mouse.x < shape.boundingBox.x.max + mouseTolerance && mouse.x < shape.boundingBox.x.max + mouseTolerance &&
mouse.y > shape.boundingBox.y.min - mouseTolerance && mouse.y > shape.boundingBox.y.min - mouseTolerance &&
@ -1296,6 +1297,15 @@ class BaseShape {
this.starty = starty this.starty = starty
this.curves = [] this.curves = []
this.regions = []; this.regions = [];
this.boundingBox = {
x: {min: startx, max: starty},
y: {min: starty, max: starty}
}
}
recalculateBoundingBox() {
for (let curve of this.curves) {
growBoundingBox(this.boundingBox, curve.bbox())
}
} }
draw(context) { draw(context) {
let ctx = context.ctx; let ctx = context.ctx;
@ -1373,6 +1383,7 @@ class TempShape extends BaseShape {
this.strokeStyle = strokeStyle this.strokeStyle = strokeStyle
this.fillStyle = fillStyle this.fillStyle = fillStyle
this.inProgress = false this.inProgress = false
this.recalculateBoundingBox()
} }
} }
@ -1387,10 +1398,6 @@ class Shape extends BaseShape {
this.lineWidth = context.lineWidth this.lineWidth = context.lineWidth
this.filled = context.fillShape; this.filled = context.fillShape;
this.stroked = context.strokeShape; this.stroked = context.strokeShape;
this.boundingBox = {
x: {min: startx, max: starty},
y: {min: starty, max: starty}
}
this.quadtree = new Quadtree({x: {min: 0, max: 500}, y: {min: 0, max: 500}}, 4) this.quadtree = new Quadtree({x: {min: 0, max: 500}, y: {min: 0, max: 500}}, 4)
if (!uuid) { if (!uuid) {
this.idx = uuidv4() this.idx = uuidv4()
@ -1463,11 +1470,6 @@ class Shape extends BaseShape {
return newShape return newShape
} }
recalculateBoundingBox() {
for (let curve of this.curves) {
growBoundingBox(this.boundingBox, curve.bbox())
}
}
simplify(mode="corners") { simplify(mode="corners") {
this.quadtree.clear() this.quadtree.clear()
this.inProgress = false this.inProgress = false
@ -1939,6 +1941,7 @@ class GraphicsObject {
newGO.rotation = this.rotation; newGO.rotation = this.rotation;
newGO.scale_x = this.scale_x; newGO.scale_x = this.scale_x;
newGO.scale_y = this.scale_y; newGO.scale_y = this.scale_y;
newGO.parent = this.parent;
pointerList[this.idx] = this pointerList[this.idx] = this
newGO.layers = [] newGO.layers = []
@ -2793,7 +2796,6 @@ function stage() {
} }
break; break;
case "select": case "select":
if (context.activeObject.currentFrame.frameType!="keyframe") break;
if (context.dragging) { if (context.dragging) {
if (context.activeVertex) { if (context.activeVertex) {
let vert = context.activeVertex let vert = context.activeVertex