Jump to content

CAniImageBox Loading Optimized


Recommended Posts

  • Honorable Member

Hello guys,

As we know, if you have a lot of images in an ani-image, it can be really slow to load and may makes the game freeze for a moment. It really limits us, because we can't use a longer image sequence as it would have a bad impact on user experience.

I created a sequence of 126 images by concatenating some of our tutorials, so here's a comparison GIF that shows the old (left) and new (right) version.

.gif

The main problem is that it loads all the images in a loop when we initialize it.

.png

And they are loaded when we call AppendImage function.

.png

 

We can delay and separate the loading of images in the update cycle to different frames, so the game won't freeze because just one image per frame will be loaded instead of them all at once.

 

How to do this? Step by step tutorial.

This is the hidden content, please

 

That's all, we're finished! 🙂

Good luck!

Edited by Distraught
  • Metin2 Dev 198
  • kekw 1
  • Eyes 1
  • Dislove 1
  • Angry 1
  • Cry 1
  • Think 4
  • Confused 1
  • Scream 1
  • Lmao 2
  • Good 30
  • Love 5
  • Love 47

WRnRW3H.gif

Link to comment
Share on other sites

  • 2 weeks later...

There is a problem with clearimages function.

	void CAniImageBox::ClearImages()
	{
		while (!m_ImageFileNames.empty())
			m_ImageFileNames.pop();

		for_each(m_ImageVector.begin(), m_ImageVector.end(), CGraphicExpandedImageInstance::DeleteExpandedImageInstance);
		m_ImageVector.clear();
	}

fixed.

 

Edited by meneleos
Link to comment
Share on other sites

  • Forum Moderator
On 7/20/2022 at 2:28 PM, meneleos said:

There is a problem with clearimages function.

	void CAniImageBox::ClearImages()
	{
		while (!m_ImageFileNames.empty())
			m_ImageFileNames.pop();

		for_each(m_ImageVector.begin(), m_ImageVector.end(), CGraphicExpandedImageInstance::DeleteExpandedImageInstance);
		m_ImageVector.clear();
	}

fixed.

 

Are you talking about the destructor? Because there is no "ClearImages" function in clean sources

  • Metin2 Dev 1

Gurgarath
coming soon

Link to comment
Share on other sites

  • 5 months later...
  • Premium
On 7/8/2022 at 2:12 AM, Distraught said:

Go to CAniImageBox::SetDiffuseColor function and overwrite with 

	void CAniImageBox::SetDiffuseColor(float fR, float fG, float fB, float fA)
	{
		m_SetDiffuseColor = std::bind(&CGraphicExpandedImageInstance::SetDiffuseColor, std::placeholders::_1, fR, fG, fB, fA);
		std::for_each(m_ImageVector.begin(), m_ImageVector.end(), m_SetDiffuseColor);
	}

Instead of this function,


 have this:

	void CImageBox::SetDiffuseColor(float fr, float fg, float fb, float fa)
	{
		if (!m_pImageInstance)
			return;

		m_pImageInstance->SetDiffuseColor(fr, fg, fb, fa);
	}

Is it okey if i overwrite this?

Edited by Ulthar

Ulthar

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.