<commit_before>{GameObject} = require './gameobject.coffee'
{mat2, mat3, mat4, vec2, vec3, vec4, quat} = require 'gl-matrix'

# FUTURE OPTIMIZATION STRATEGIES
# Make a single flat array for positions and rotations,
# Sending them as textures where available
# Or as uniform16fv where not
# Baking animation loops into spare framebuffer texture
# sending bone locations in parent space instead of local

# Uniforms (in armature space) = parent uniform * base pose * local

#UNIT_MAT4 = mat4.create()

class Bone extends GameObject

    constructor: (@context)->
        # Base pose position and rotation in PARENT space
        @base_position = new(Float32Array)(3)
        @base_rotation = new(Float32Array)(4)
        # Position and rotation in LOCAL (base) space
        @position = [0, 0, 0]
        @rotation = [0, 0, 0, 1]
        #@rotation_order = 'Q'
        @scale = [1, 1, 1]
        # parents and constraints will set those
        @final_position = [0, 0, 0]
        @final_rotation = [0, 0, 0, 1]
        @final_scale = [1, 1, 1]
        # which will be used to compute
        @matrix = mat4.create() # World matrix
        # Object local matrix (relative to rest pose)
        @ol_matrix = mat4.create()
        # TODO: probably it was faster to use this for constraintless
        #       armatures (test)
        #@parent_matrix = UNIT_MAT4 # pointer to parent's

        # Set at the beginning, using recalculate_bone_matrices
        # with the rest pose and without constraints<commit_msg>Creating VECTOR_Y and added changed some Float32Array creation syntax to be more "coffeescript-like"<commit_after>{GameObject} = require './gameobject.coffee'
{mat2, mat3, mat4, vec2, vec3, vec4, quat} = require 'gl-matrix'

# FUTURE OPTIMIZATION STRATEGIES
# Make a single flat array for positions and rotations,
# Sending them as textures where available
# Or as uniform16fv where not
# Baking animation loops into spare framebuffer texture
# sending bone locations in parent space instead of local

# Uniforms (in armature space) = parent uniform * base pose * local

#UNIT_MAT4 = mat4.create()
VECTOR_Y = [0, 1, 0]

class Bone extends GameObject

    constructor: (@context)->
        # Base pose position and rotation in PARENT space
        @base_position = new Float32Array 3
        @base_rotation = new Float32Array 4
        # Position and rotation in LOCAL (base) space
        @position = [0, 0, 0]
        @rotation = [0, 0, 0, 1]
        #@rotation_order = 'Q'
        @scale = [1, 1, 1]
        # parents and constraints will set those
        @final_position = [0, 0, 0]
        @final_rotation = [0, 0, 0, 1]
        @final_scale = [1, 1, 1]
        # which will be used to compute
        @matrix = mat4.create() # World matrix
        # Object local matrix (relative to rest pose)
        @ol_matrix = mat4.create()
        # TODO: probably it was faster to use this for constraintless
        #       armatures (test)
        #@parent_matrix = UNIT_MAT4 # pointer to parent's

        # Set at the beginning, using recalculate_bone_matrices
        # with the rest pose and without constraints
{'fraction_non_alphanumeric': 0.08648302370275464, 'fraction_numerical': 0.026585522101217167, 'mean_word_length': 2.8225214198286412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2060952', 'n_tokens_mistral': 963, 'n_tokens_neox': 899, 'n_words': 359}