Skip to content

Commit afde1b6

Browse files
authored
Merge pull request #24 from neguse/agent/use-native-modulo
Use native modulo in Tonton sample
2 parents 87e681a + ab0f3cd commit afde1b6

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

samples/22_tonton/Tonton22.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
// Phys3d の desc 匿名構造体は lub_stub の desc class。end() は End()、
1919
// char() は Char()。Renderer3d / Mesh3d / MeshText は cs-lib の load 順の
2020
// 都合で static 初期化子から呼べないため onFrame で遅延生成する。
21-
// 整数 % は tcs 未対応なので imod (Math.Floor 分解) で書く。
2221

2322
using System;
2423
using System.Collections.Generic;
@@ -202,11 +201,6 @@ public static void onQuit()
202201
{
203202
}
204203

205-
/// <summary>整数剰余 (tcs は % 未対応)。a, b > 0 前提。</summary>
206-
static int imod(int a, int b)
207-
{
208-
return a - (int)Math.Floor((float)a / (float)b) * b;
209-
}
210204

211205
// --- SDF だるま力士 -----------------------------------------------------
212206
// bone 付き SDF ツリーからメッシュ化。体色だけ違う 2 体分を焼く。
@@ -775,10 +769,10 @@ static void updateTap(BodyRef3d dohyo, Vec3 eye, Vec3 target, float fovDeg,
775769
// 自動トントン: 決定論の擬似乱数で縁寄りを叩き続ける (勝負中のみ)
776770
if (auto)
777771
{
778-
if (state != ST_FIGHT || imod(frame, 24) != 12)
772+
if (state != ST_FIGHT || frame % 24 != 12)
779773
return;
780-
float aa = imod(frame * 7919, 628) / 100.0f;
781-
float rr = DOHYO_R * (0.45f + imod(frame * 337, 50) / 100.0f);
774+
float aa = (frame * 7919) % 628 / 100.0f;
775+
float rr = DOHYO_R * (0.45f + (frame * 337) % 50 / 100.0f);
782776
tapAt(dohyo, (float)Math.Cos(aa) * rr, (float)Math.Sin(aa) * rr);
783777
return;
784778
}

0 commit comments

Comments
 (0)