Skip to content

Commit

Permalink
コンチベンチ更新
Browse files Browse the repository at this point in the history
  • Loading branch information
hiryma committed Apr 4, 2019
1 parent dd7f4fe commit 6a572ab
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 23 deletions.
62 changes: 45 additions & 17 deletions KonchiBench/Assets/FillTest/FillRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,84 @@ public class FillRenderer : MonoBehaviour
[SerializeField]
MeshRenderer _renderer;

public void SetCount(int count)
public void SetCount(float count)
{
_newCount = count;
}
public void SetMaterial(Material material)
{
_renderer.material = material;
}
int _currentCount;
int _newCount;
float _currentCount;
float _newCount;
Mesh _mesh;
Vector3 _quadVertices;
int[] _indices;
Vector3[] _vertices;
Vector2[] _uv;

public void ManualStart()
{
_mesh = new Mesh();
_mesh.vertices = new Vector3[4]{
_vertices = new Vector3[6]{
new Vector3(-1f, -1f, 0f),
new Vector3(-1f, 1f, 0f),
new Vector3(1f, -1f, 0f),
new Vector3(1f, 1f, 0f),
// 以下2つは動的に書き換える
new Vector3(1f, -1f, 0f),
new Vector3(1f, 1f, 0f),
};
_mesh.uv = new Vector2[4]{
_uv = new Vector2[6]{
new Vector2(0f, 0f),
new Vector2(0f, 1f),
new Vector2(1f, 0f),
new Vector2(1f, 1f),
// 以下2つは動的に書き換える
new Vector2(1f, 0f),
new Vector2(1f, 1f),
};
_mesh.triangles = new int[]{};
_filter.mesh = _mesh;
}

public void ManualUpdate()
{
if (_newCount != _currentCount)
int newCountCeil = Mathf.CeilToInt(_newCount);
// 基本小数部だが、ピッタリ整数だった場合は1にする
float u1 = _newCount - (float)(newCountCeil - 1);
var x1 = (u1 * 2f) - 1f;
// 頂点を修正
_vertices[4] = new Vector3(x1, -1f, 0f);
_vertices[5] = new Vector3(x1, 1f, 0f);
_mesh.vertices = _vertices;
_uv[4] = new Vector2(u1, 0f);
_uv[5] = new Vector2(u1, 1f);
_mesh.uv = _uv;

int currentCountCeil = Mathf.CeilToInt(_currentCount);
if (newCountCeil != currentCountCeil) // 数が変わった時には配列を再確保
{
_currentCount = _newCount;
var indices = new int[_currentCount * 6];
_indices = new int[newCountCeil * 6];
var pos = 0;
for (int i = 0; i < _currentCount; i++)
for (int i = 0; i < (newCountCeil - 1); i++)
{
indices[pos + 0] = 0;
indices[pos + 1] = 1;
indices[pos + 2] = 2;
indices[pos + 3] = 2;
indices[pos + 4] = 1;
indices[pos + 5] = 3;
_indices[pos + 0] = 0;
_indices[pos + 1] = 1;
_indices[pos + 2] = 2;
_indices[pos + 3] = 2;
_indices[pos + 4] = 1;
_indices[pos + 5] = 3;
pos += 6;
}
_mesh.triangles = indices;
// 最後の矩形は2つ目の矩形頂点を参照
_indices[pos + 0] = 0;
_indices[pos + 1] = 1;
_indices[pos + 2] = 4;
_indices[pos + 3] = 4;
_indices[pos + 4] = 1;
_indices[pos + 5] = 5;
}
_mesh.triangles = _indices;
_currentCount = _newCount;
}
}
8 changes: 5 additions & 3 deletions KonchiBench/Assets/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void Update()
_countVelocity += accel;
_count += _countVelocity;
_count = Mathf.Clamp(_count, 0f, 10000f);
_fillRenderer.SetCount((int)_count);
_fillRenderer.SetCount(_count);
_fillRenderer.SetMaterial(_fillTestMaterials[_fillTestMaterialIndex]);
_fillRenderer.ManualUpdate();
}
Expand Down Expand Up @@ -149,11 +149,11 @@ void OnGUI()
var latest = ((_timeIndex - 1) < 0) ? (_times.Length - 1) : (_timeIndex - 1);
var avg = (_times[latest] - _times[_timeIndex]) / (_times.Length - 1);
var sb = new System.Text.StringBuilder();
sb.Append("v0.2.4: " + SystemInfo.deviceModel + "\n");
sb.Append("v0.2.5: " + SystemInfo.deviceModel + "\n");
sb.Append("Os: " + SystemInfo.operatingSystem + "\n");
sb.Append("Gpu: " + SystemInfo.graphicsDeviceName + "\n");
sb.Append("FrameTime: " + (avg * 1000f).ToString("N2") + " frame:" + Time.frameCount + "\n");
sb.Append("Count: " + _count.ToString("N0") + "\n");
sb.Append("Count: " + _count.ToString("N1") + "\n");
GUILayout.Label(sb.ToString());
if (_result != null)
{
Expand Down Expand Up @@ -213,6 +213,8 @@ public void OnClickSysInfoButton()
sb.Append("\tShadow: " + SystemInfo.supportsShadows + "\n");
sb.Append("\tDepthSampling: " + SystemInfo.supportsRawShadowDepthSampling + "\n");
sb.Append("\tRenderToCube: " + SystemInfo.supportsRenderToCubemap + "\n");
sb.Append("\tARGB2101010 RT: " + SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB2101010) + "\n");
sb.Append("\tRGB111110Float RT: " + SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGB111110Float) + "\n");
_result = sb.ToString();
sb.Length = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion KonchiBench/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"com.unity.ads": "2.0.8",
"com.unity.analytics": "3.2.2",
"com.unity.collab-proxy": "1.2.15",
"com.unity.package-manager-ui": "2.0.3",
"com.unity.package-manager-ui": "2.0.7",
"com.unity.purchasing": "2.0.3",
"com.unity.textmeshpro": "1.3.0",
"com.unity.modules.ai": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion KonchiBench/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
m_EditorVersion: 2018.3.1f1
m_EditorVersion: 2018.3.9f1
1 change: 0 additions & 1 deletion LdrBloom/ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ GraphicsSettings:
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
Expand Down

0 comments on commit 6a572ab

Please sign in to comment.