MCPcopy
hub / github.com/g3n/engine / decFloat32Sequence

Function decFloat32Sequence

loader/collada/common.go:352–376  ·  view source on GitHub ↗

decFloat32Sequence receives a byte slice with float numbers separated by spaces and a preallocated destination slice. It reads numbers from the source byte slice, converts them to float32 and stores in the destination array.

(cdata []byte, dest []float32)

Source from the content-addressed store, hash-verified

350// It reads numbers from the source byte slice, converts them to float32 and
351// stores in the destination array.
352func decFloat32Sequence(cdata []byte, dest []float32) error {
353
354 var br bytesReader
355 br.Init(cdata)
356 idx := 0
357 for {
358 tok := br.TokenNext()
359 if tok == nil {
360 break
361 }
362 if idx >= len(dest) {
363 return fmt.Errorf("To much float array data")
364 }
365 v, err := strconv.ParseFloat(string(tok), 32)
366 if err != nil {
367 return err
368 }
369 dest[idx] = float32(v)
370 idx++
371 }
372 if idx < len(dest)-1 {
373 return fmt.Errorf("Expected %d floats, got %d", len(dest), idx)
374 }
375 return nil
376}
377
378// decStringSequence receives a byte slice with strings separated
379// by spaces and a preallocated destination slice.

Callers 6

decFloatArrayMethod · 0.85
decMatrixMethod · 0.85
decRotateMethod · 0.85
decTranslateMethod · 0.85
decScaleMethod · 0.85
decLightColorMethod · 0.85

Calls 2

InitMethod · 0.95
TokenNextMethod · 0.95

Tested by

no test coverage detected