Skip to content

Commit

Permalink
gl2: Properly cache MVP matrices of objects; Fixes azul3d-legacy/gfx-…
Browse files Browse the repository at this point in the history
  • Loading branch information
slimsag committed Nov 19, 2014
1 parent aa3dbf2 commit 1517b66
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gl2/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ func (n nativeObject) needRebuild(o *gfx.Object, c *gfx.Camera) bool {
}

func (n nativeObject) rebuild(o *gfx.Object, c *gfx.Camera) nativeObject {
objMat := o.Transform.Mat4()
n.Transform = objMat

// The "Model" matrix is the Object's transformation matrix, we feed it
// directly in.
n.model = gfx.ConvertMat4(o.Transform.Mat4())
n.model = gfx.ConvertMat4(objMat)

// The "View" matrix is the coordinate system conversion, multiplied
// against the camera object's transformation matrix
Expand All @@ -117,7 +120,7 @@ func (n nativeObject) rebuild(o *gfx.Object, c *gfx.Camera) nativeObject {
n.projection = gfx.ConvertMat4(projection)

// The "MVP" matrix is Model * View * Projection matrix.
mvp := o.Transform.Mat4()
mvp := objMat
mvp = mvp.Mul(view)
mvp = mvp.Mul(projection)
n.mvp = gfx.ConvertMat4(mvp)
Expand Down

0 comments on commit 1517b66

Please sign in to comment.