Skip to content

Commit e9b1786

Browse files
committed
we're breaking a lot of things in this push
- Groups and Cubes that aren't visible in blockbench (using the visiblity toggle) will not export. Useful for debugging. - Fixed animation cache not working in some cases - Fixed animation cache not updating when bone structure is changed - Started mega settings overhaul
1 parent bdd67b7 commit e9b1786

File tree

11 files changed

+486
-204
lines changed

11 files changed

+486
-204
lines changed

debug_resourcepack/armor_stand.ajmodel

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"meta": {
33
"format_version": "0.0",
4-
"creation_time": 1641669797,
4+
"creation_time": 1641691376,
55
"model_format": "animated_java/ajmodel",
66
"box_uv": false,
77
"settings": {
@@ -32,7 +32,7 @@
3232
"animatedJava_exporter_animationExporter": {
3333
"rootEntityType": "minecraft:marker",
3434
"rootEntityNbt": "{}",
35-
"markerArmorStands": false,
35+
"markerArmorStands": true,
3636
"autoDistance": true,
3737
"autoDistanceMovementThreshold": 1,
3838
"manualDistance": 10,
@@ -47,13 +47,35 @@
4747
"animatingFlagScoreboardObjective": "aj.%projectName.animating",
4848
"animationLoopModeScoreboardObjective": "aj.%projectName.%animationName.loopMode",
4949
"exportMode": "mcb",
50-
"mcbFilePath": "C:\\Users\\Snave\\AppData\\Roaming\\.minecraft\\saves\\Animated Java Dev\\datapacks\\Animated Java Development\\src\\armor_stand.mc",
50+
"mcbFilePath": "",
5151
"mcbConfigPath": "",
52-
"dataPackPath": "C:\\Users\\Snave\\AppData\\Roaming\\.minecraft\\saves\\Animated Java Dev\\datapacks\\armor_stand"
52+
"dataPackPath": ""
5353
}
5454
},
5555
"variants": {
56-
"default": {}
56+
"red": {
57+
"29f44b0b-5027-de28-9958-e95a32a0cf4c": "52d3d034-24bc-3a1c-49d8-98899a3aa5bd"
58+
},
59+
"blue": {},
60+
"green": {
61+
"29f44b0b-5027-de28-9958-e95a32a0cf4c": "f422a623-6d8c-1bd1-4da1-c61940601aaf"
62+
},
63+
"all_blue": {
64+
"dfa38dd5-689f-f447-7d28-63645345c25d": "transparent",
65+
"9aa33630-8f09-269e-1ff8-4006c170cc10": "29f44b0b-5027-de28-9958-e95a32a0cf4c"
66+
},
67+
"all_red": {
68+
"9aa33630-8f09-269e-1ff8-4006c170cc10": "52d3d034-24bc-3a1c-49d8-98899a3aa5bd",
69+
"29f44b0b-5027-de28-9958-e95a32a0cf4c": "52d3d034-24bc-3a1c-49d8-98899a3aa5bd"
70+
},
71+
"all_green": {
72+
"9aa33630-8f09-269e-1ff8-4006c170cc10": "f422a623-6d8c-1bd1-4da1-c61940601aaf",
73+
"29f44b0b-5027-de28-9958-e95a32a0cf4c": "transparent"
74+
},
75+
"no_head": {
76+
"29f44b0b-5027-de28-9958-e95a32a0cf4c": "transparent",
77+
"dfa38dd5-689f-f447-7d28-63645345c25d": "transparent"
78+
}
5779
},
5880
"uuid": "6315712c-d94e-91d8-dc54-eb2877b25239"
5981
},
@@ -929,6 +951,7 @@
929951
],
930952
"autouv": 0,
931953
"color": 1,
954+
"visibility": false,
932955
"rotation": [
933956
-45,
934957
0,

src/animatedJava.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import './exporters/statueExporter'
1313
import './exporters/animationExporter'
1414
import './bbmods/modelFormatMod'
1515
import './bbmods/faceTint'
16+
import './util/minecraft/items'
17+
import './util/minecraft/entities'
1618
import { intl } from './util/intl'
1719
import { CustomError } from './util/customError'
1820
import { format } from './util/replace'
@@ -103,6 +105,14 @@ Blockbench.events['animated-java-ready'].length = 0
103105

104106
// WOOO TYPING, YAAAAAAY
105107

108+
export interface SettingDescriptor {
109+
readonly value: any
110+
error?: string
111+
isValid?: boolean
112+
setting: any
113+
event: 'get' | 'set' | 'update' | 'dummy'
114+
}
115+
106116
export interface Settings {
107117
projectName: string
108118
exporter: string

src/animationRenderer.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { settings } from './settings'
33
import { Async } from './util/async'
44
import { bus } from './util/bus'
55
import { roundToN } from './util/misc'
6-
import { hashAnim } from './util/hashAnim'
6+
import * as hash from './util/hash'
77
import { store } from './util/store'
88
import * as os from 'os'
99
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs'
@@ -127,7 +127,7 @@ const struct = StructTypes.Object({
127127
StructTypes.String,
128128
StructTypes.Object({
129129
pos: vec3,
130-
rot: StructTypes.ArrayOf(StructTypes.Float),
130+
rot: vec3,
131131
scale: vec3,
132132
})
133133
),
@@ -182,7 +182,7 @@ const Cache = new (class {
182182
if (!settings.animatedJava.useCache) return null
183183
if (this.cache.has(anim.uuid)) {
184184
const old_hash = this.cache.get(anim.uuid)
185-
const new_hash = hashAnim(anim)
185+
const new_hash = hash.animation(anim)
186186
const hit = old_hash !== new_hash
187187
if (!hit) {
188188
if (settings.animatedJava.cacheMode === 'memory') {
@@ -198,8 +198,7 @@ const Cache = new (class {
198198
}
199199
return null
200200
} else {
201-
const hash = hashAnim(anim)
202-
this.cache.set(anim.uuid, hash)
201+
this.cache.set(anim.uuid, hash.animation(anim))
203202
return null
204203
}
205204
}
@@ -213,7 +212,7 @@ const Cache = new (class {
213212
animToWriteable(value)
214213
)
215214
}
216-
this.cache.set(anim.uuid, hashAnim(anim))
215+
this.cache.set(anim.uuid, hash.animation(anim))
217216
}
218217
clear() {
219218
this.data = new Map()
@@ -222,14 +221,17 @@ const Cache = new (class {
222221
})()
223222

224223
// clear the animation cache if the origin or rotation of a group changes
225-
const $original_func = NodePreviewController.prototype.updateTransform
226-
NodePreviewController.prototype.updateTransform = function (el) {
227-
if (Group.selected) Cache.clear()
228-
return $original_func.bind(this)(el)
229-
}
230-
bus.on(events.LIFECYCLE.CLEANUP, () => {
231-
NodePreviewController.prototype.updateTransform = $original_func
232-
})
224+
// const $original_func = NodePreviewController.prototype.updateTransform
225+
// NodePreviewController.prototype.updateTransform = function (el) {
226+
// if (Group.selected) Cache.clear()
227+
// return $original_func.bind(this)(el)
228+
// }
229+
// bus.on(events.LIFECYCLE.CLEANUP, () => {
230+
// NodePreviewController.prototype.updateTransform = $original_func
231+
// })
232+
233+
let boneStructureHash
234+
233235
async function renderAnimation(options) {
234236
console.groupCollapsed('Render Animations')
235237
// const timeline_save = get_timeline_save_point();
@@ -271,11 +273,18 @@ async function renderAnimation(options) {
271273
const renderedGroups = Group.all.filter(
272274
(group) =>
273275
!isSceneBased(group) &&
276+
group.visibility &&
274277
group.children.find((child) => child instanceof Cube)
275278
)
276279
console.log('All Groups:', Group.all)
277280
console.log('Rendered Groups:', renderedGroups)
278281

282+
const newBoneStructureHash = hash.boneStructure()
283+
if (boneStructureHash !== newBoneStructureHash) {
284+
boneStructureHash = newBoneStructureHash
285+
Cache.clear()
286+
}
287+
279288
for (const animation of Animator.animations.sort()) {
280289
if (animation.snapping != 20) {
281290
throw new CustomError('Invalid Snapping Value Error', {

0 commit comments

Comments
 (0)