Perfect leg/hip rig?

I first started using blender cause I wanted to make 3d models of my drawings and I finally managed to make my first sculpt.
I retopologized it and attempt to make a simple rig for it to test it because in the past I noticed that rigs for the hip and thigh is hard. the thigh will cave into the hip when going to far(for me around 45 degrees)
I want to get the thigh up straight if possible.


I am aware that there are similar topics around but I haven’t yet seen any helping answer to my problem.
I tried to improve topology/rigging and weight-painting but still same results.

I’m not really sure if this is even possible so is there examples of this happening? best way for me to so an example is this:
GoalExample

If you have problems with weight painting you can mix it with shape keys. Add a shape key and smooth (in sculpt mode) the areas which were distorted by weight paint, use also other brushes like grab or inflate, to create a shape in joint that you want. It should be a lot easier for a beginner than using weight paint only. Then animate armature and that shape key simultaneously, like:

leg bone in rest (keyframe) = smoothing shape key with value 0 (keyframe)
leg bone moves forward (keyframe) = smoothing shape key with value 1 (keyframe)
etc.

You can always add another bone to just hold the deformation. Just put one in and parent it to your hip say and weight that bone. Now you have another bone that you can play with weighting for your leg. You might want one at the back to keep the hip shape deformation as well. (PS your drawing looks like a phallic symbol.)