Jump to content

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 254
  • kekw 1
  • Eyes 2
  • Dislove 1
  • Angry 1
  • Cry 1
  • Think 3
  • Scream 1
  • Lmao 2
  • Good 47
  • Love 10
  • Love 73

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

Link to comment
https://metin2.dev/topic/29288-caniimagebox-loading-optimized/
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
  • 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
My Services

  • Honorable Member
7 hours ago, meneleos said:

A necessary function for some systems that were added later.

Then it's not a fix, it's in your code only.

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

  • 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
  • kekw 1

Ulthar

  • Honorable Member

That’s the function of another class.

992404397646696589.png
Former C++ Developer at Gameloft on DML
Join my Discord: Distraught Labs

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.