Skip to content

Commit

Permalink
obs, moving: Fix setting source index.
Browse files Browse the repository at this point in the history
  • Loading branch information
sathya-pramodh committed Jan 30, 2024
1 parent 7590e0c commit d22d6ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/ctl/moving.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,20 @@ func (m *MovingWall) layoutGroup(group cfg.Group, startZ int, instances []int) {
func (m *MovingWall) layoutObs() {
m.obs.BatchAsync(obs.SerialFrame, func(b *obs.Batch) {
visible := make([]bool, len(m.instances))
var minIndex int = 1e2
for i := len(m.hitboxes) - 1; i >= 0; i -= 1 {
h := m.hitboxes[i]
name := fmt.Sprintf("Wall MC %d", h.id+1)
idx := b.GetSceneItemIndex("Wall", name)
if minIndex > idx {
minIndex = idx
}
}
for i := len(m.hitboxes) - 1; i >= 0; i -= 1 {
h := m.hitboxes[i]
visible[h.id] = true
name := fmt.Sprintf("Wall MC %d", h.id+1)
b.SetItemIndex("Wall", name, 0)
b.SetItemIndex("Wall", name, minIndex)
b.SetItemBounds(
"Wall",
name,
Expand Down
8 changes: 8 additions & 0 deletions internal/obs/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ func (b *Batch) SetItemIndex(scene, name string, index int) {
b.requests = append(b.requests, req)
}

func (b *Batch) GetSceneItemIndex(scene, name string) int {
idx, err := b.client.GetSceneItemIndex(scene, name)
if err != nil {
panic(batchError{err})
}
return idx
}

func (b *Batch) SetItemVisibility(scene, name string, visible bool) {
id, err := b.client.getSceneItemId(scene, name)
if err != nil {
Expand Down

0 comments on commit d22d6ad

Please sign in to comment.