MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / Render

Method Render

LuaSTGPlus/GameObjectPool.cpp:214–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214bool GameObjectBentLaser::Render(const char* tex_name, BlendMode blend, fcyColor c, float tex_left, float tex_top, float tex_width, float tex_height, float scale)LNOEXCEPT
215{
216 // ����ֻ��һ���ڵ�����
217 if (m_Queue.Size() <= 1)
218 return true;
219
220 fcyRefPointer<ResTexture> pTex = LRES.FindTexture(tex_name);
221 if (!pTex)
222 {
223 LERROR("lstgBentLaserData: �Ҳ���������Դ'%m'", tex_name);
224 return false;
225 }
226
227 f2dGraphics2DVertex renderVertex[4] = {
228 { 0, 0, 0.5f, c.argb, 0, tex_top },
229 { 0, 0, 0.5f, c.argb, 0, tex_top },
230 { 0, 0, 0.5f, c.argb, 0, tex_top + tex_height },
231 { 0, 0, 0.5f, c.argb, 0, tex_top + tex_height }
232 };
233
234 float tVecLength = 0;
235 for (size_t i = 0; i < m_Queue.Size() - 1; ++i)
236 {
237 LaserNode& cur = m_Queue[i];
238 LaserNode& next = m_Queue[i + 1];
239
240 // === ���������������� ===
241 // �����cur��next������
242 fcyVec2 offsetA = cur.pos - next.pos;
243 float lenOffsetA = offsetA.Length();
244 if (lenOffsetA < 0.0001f && i + 1 != m_Queue.Size() - 1)
245 continue;
246
247 // ��������ϵ���չ����(��ת270��)
248 fcyVec2 expandVec = offsetA.GetNormalize();
249 std::swap(expandVec.x, expandVec.y);
250 expandVec.y = -expandVec.y;
251
252 if (i == 0) // ����ǵ�һ���ڵ㣬���������չʹ��expandVec����
253 {
254 float expX = expandVec.x * scale * cur.half_width;
255 float expY = expandVec.y * scale * cur.half_width;
256 renderVertex[0].x = cur.pos.x + expX;
257 renderVertex[0].y = cur.pos.y + expY;
258 renderVertex[0].u = tex_left;
259 renderVertex[3].x = cur.pos.x - expX;
260 renderVertex[3].y = cur.pos.y - expY;
261 renderVertex[3].u = tex_left;
262 }
263 else // ���򣬿���1��2
264 {
265 renderVertex[0].x = renderVertex[1].x;
266 renderVertex[0].y = renderVertex[1].y;
267 renderVertex[0].u = renderVertex[1].u;
268 renderVertex[3].x = renderVertex[2].x;
269 renderVertex[3].y = renderVertex[2].y;
270 renderVertex[3].u = renderVertex[2].u;
271 }

Callers 1

DoDefaultRenderMethod · 0.45

Calls 3

FindTextureMethod · 0.80
SizeMethod · 0.45
RenderTextureMethod · 0.45

Tested by

no test coverage detected