그리고 Debug.Log를 거의 지우고, 이 모든 작업을 100번 반복하는데 얼마나 걸리는지 확인해봤습니다.
(일단 기본 데이터는 같은 걸 썼지만, 최종적으로는 각 층이 고유한 메쉬를 가진 개체입니다.)
Coroutine 코드를 어디서든 사용할 수 있게 코드 개편을 한번 더 했고요. (그 도중에 무한 루프가 몇 번 터져서 Unity 셧다운 몇 번 되고)
그래서 중간중간 Update(프레임 시작)부터 계산 후까지 시간이 20ms가 넘으면 다음 프레임에서 다시 계산하게 했습니다.
이러니 바쁘게 계산해도 30fps는 유지가 되더군요. (60fps는 이 방법으로 안 될 것 같음... 그냥 로딩할 때의 랙이라 생각하시길)
하여튼 이렇게 타원벽, 꺾인 벽, 그냥 벽을 100번 만드는 데 1.143초가 걸렸습니다.
사실 가장 병목인 부분은 Debug.Log에요. (...)
벡터 다루면서 도배한 Debug.Log만 싹 정리해주니 시간이 몇 배로 줄었어요.
이제 다음 주까지 벽을 다룰 건지, 아니면 이제 바닥같은 걸로 넘어갈 건지죠.
일단 바닥을 만들어보죠.
The Shadow Bug, Messing with Vector Math
The first problem of this week was the shadow.
As you can see, shadow isn't drew outside of certain area.
Changing ShadowDistance in Quality doesn't make any difference.
The solution was simple.
When changing projectionMatrix, also do orthgraphicSize, accordingly.
And this fix made the bug in Unity3D 5 visible.
.
<Well, I can't put gfycat in here. Just scroll up, and sorry for this inconvenience>
[Nothing but Camera.projectionMatrix[1,2] changing]
It seems I'm not the only one having this issue. (Link)
The only solution right now is to make my own ShadowMap.
Or I can just wait for the bug fix.
I can wait.
And the next problem is,
Offset Problem
the Offset problem.
When making multiple lines of walls connected, you need to know where outer and inner lines meet, using center lines(Red and Blue in the illustration) and the thickness of walls(Green).
Very easy in CAD, but what I should do is to recreate this function in C#.
After messing with vector math for two days, I made it.
Additionally I readded the section code for easy look.
Once I can connect many points, I can improvise this.
First I made ellipse wall code. (And yes, you can adjust the height of the wall)
And the circle is also an ellipse, too.
I wanted to make rotated ellipses too, but saved it for later.
And I checked how long will doing this 100 times takes, after removing most of Debug.Logs.
(I copied the basic data for all of floors, but lastly each floors have their unique meshes.)
I refined the Coroutine code to it can be used whenever I want. (and I killed Unity several times 'cause of infinite loops)
So when the calculation time exceeds 20ms after Update function called(when frame started), hold calculating 'til next frame.
This makes the game stay in 30fps even if the calculation is running. (I think it's hard to keep 60fps with this way... just consider this as a loading lag)
Anyway making 100 floor building took 1.143 seconds to build.
Actually, the slowest bottle neck is Debug.Logs.
Just cleaning most of Debug.Logs which I sprayed all over the place while doing vector thingly reduced the loading time significantly.
Now I need to decide that should I do the wall next week, or do the floor(not the 1, 2, 3 floor, a slab one)