A name that a sprite already owns cannot name a property, and a division by zero cannot answer (#63, #64)
game-maker / suite (push) Failing after 11m29s
game-maker / suite (push) Failing after 11m29s
#63: a shader Property node named "width" quietly took over the sprite row of the same name. isSpriteProp lives in PropertySchema now and is derived from FULL_SCHEMAS.sprite instead of being a second list that drifts. isValidPropertyName rejects those ten names, and the compiler reports it at the node as its own problem: "width" is a sprite property, told apart from "not a word" and from a duplicate. #64: Divide emitted (a / b) and handed NaN to the driver. It emits divide(a, b) now, with the guard in the prologue next to straight(), scalar and per channel: zero divided by zero is zero. That was already the house rule in the behavior and particle graphs - only the shader had never been told. Clamp comes along as a shader node for the same reason: the behavior catalog has had it all along.
This commit is contained in:
1 parent
150f2e0906
commit
c990dbcb26
6 files changed
+203
-6
No files matched your search
@@ -306,6 +306,17 @@ export function schemaFor(type: AssetType): PropertySchema {
|
||||
return FULL_SCHEMAS[type];
|
||||
}
|
||||
|
||||
const SPRITE_KEYS = new Set(FULL_SCHEMAS.sprite.map((d) => d.key));
|
||||
|
||||
/**
|
||||
* A row every sprite has already: the switch, the transform and the sprite's own. A shader
|
||||
* parameter under one of these names would be a second row on the same bag key, and its uniform
|
||||
* would read the sprite's value instead of the default the Property node declares (#63).
|
||||
*/
|
||||
export function isSpriteProp(key: string): boolean {
|
||||
return SPRITE_KEYS.has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type schema, for behaviors followed by their declared variables, for sprites by the
|
||||
* parameters of the shader asset their bag names – which is why the project is needed.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Graph, GraphNode } from '../graph/Graph';
|
||||
import { type PropertyBag, textOf } from '../model/Properties';
|
||||
import { type FlatDef, isValidFieldName } from './PropertySchema';
|
||||
import { type FlatDef, isSpriteProp, isValidFieldName } from './PropertySchema';
|
||||
|
||||
/** The sprite property naming the shader asset it wears; `''` is no shader and no render pass. */
|
||||
export const SHADER_KEY = 'shader';
|
||||
@@ -27,9 +27,13 @@ export function propertyName(node: GraphNode): string {
|
||||
return textOf(node.params[PROPERTY_NAME_PARAM] ?? '');
|
||||
}
|
||||
|
||||
/** A property's name is a bag key and a uniform, so it has to be an identifier. */
|
||||
/**
|
||||
* A property's name is a bag key and a uniform, so it has to be an identifier – and not one of the
|
||||
* rows the sprite brings itself: both rows would share the key and the uniform would read the
|
||||
* sprite's width instead of the declared default (#63). The compiler names which of the two it is.
|
||||
*/
|
||||
export function isValidPropertyName(name: string): boolean {
|
||||
return isValidFieldName(name);
|
||||
return isValidFieldName(name) && !isSpriteProp(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user