blob: 68412ee2f845d1f60ff334c32af49d502f1ff38d [file] [log] [blame] [edit]
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package path
import (
"fmt"
"android.googlesource.com/platform/tools/gpu/framework/binary"
)
// MeshOptions provides parameters for the mesh returned by a Mesh path resolve.
type MeshOptions struct {
binary.Generate `java:"MeshPathOptions"`
Faceted bool // If true then normals are calculated from each face.
}
// Mesh is a path to a mesh representation of an object.
type Mesh struct {
binary.Generate
Object Path // The path to the object that is providing the mesh.
Options *MeshOptions // Optional parameters
}
// String returns the string representation of the path.
func (n *Mesh) String() string { return n.Path() }
// Path implements the Path interface.
func (n *Mesh) Path() string {
return fmt.Sprintf("%s.<mesh>", n.Object)
}
// Base implements the Path interface, returning the path to the atom list.
func (n *Mesh) Base() Path {
return n.Object
}
// Clone implements the Path interface, returning a deep-copy of this path.
func (n *Mesh) Clone() Path {
return &Mesh{Object: n.Object.Clone()}
}
// Validate implements the Path interface.
func (n *Mesh) Validate() error {
switch {
case n.Object == nil:
return fmt.Errorf("Mesh.Object is nil")
}
return n.Object.Validate()
}